I tried looking high and low for a sample of writing a code for a Binary Tree, there isnt one or i must have missed it somewhere.

This is what i would need in assembly language.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                                                               
;   insert  Insert a new node in a binary search tree       
;                                                                               
;                                                                               
;   Entry   0(r14)= ->Pointer to the root of a binary tree  
;             4(r14)= Number to be added to the tree           
;             jal insert                                                        
;                                                                                
;   Result  r1 = ->Pointer to the root of the binary tree   
;                                                           
;   Uses    r1,r2                                      
;                                                           
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

i manage to come out with something in java, but i have no idea how to translate it into assembly (DLX assembly) language.

bst insert(bst tree, int n)      // add n to the tree
{
	if ( tree == 0 )         // an empty tree is replaced by a new node
	{
		tree = newNode(n) ;
	} else
	{
		if (n > tree.value)    // if n is > node, add n to the left sub-tree
		{
			tree.left = insert(tree.left,n) ;
		} else
		{                        // otherwise add n to the right sub-tree
			tree.right = insert(tree.right,n) ;
		}
	}
	return tree ;            // return a pointer to the tree
}

Can anyone give me a rough idea or let me know how can i find an assembly equivalent on the internet please? Thanks alot in advance.

Here is a outline of a data structure in the data region of a assembly program,
common intel syntax assembler directives are used:

ENT_TREE_1:      ; Tree structure consists of 8-byte records
dw 56,34            ;  Data
POINTER_NODE_L_1:  ; Here a pointer is stored, it will be essential when
dw ENT_TREE_1_2      ; using a dynamicly allocated structure to be able to
POINTER_NODE_R_1: ; store and retrieve the offsets of the allocated memory.
dw ENT_TREE_1_3      ; in a real program it will not be known where the offsets
                                 ; will be, and will be returned by the API.

ENT_TREE_L_1:   ; 8-Bytes for the left node
dw 0,0,0,0

ENT_TREE_L_2:   ; 8-Bytes for the right node
dw 0,0,0,0

The process then should be to have the room for the intended data,
a datatype large enough to hold an offset, and to allocate the
the total size of the whole record (data+pointer+pointer) bytes.

The actual low-level implementation varies by architecture and the
run time enviroment, that is, the operating system on which it is
intended to be executed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.