; ; Author: Ney Calazans ; Date: 31/05/2006 ; ; Description: This code depicts a binary tree example, to help students understand how this ; kind of data structure is organized in Cleopatra Assembly Language. The ; binary tree example has a root node (the contents of the three memory positions ; starting at address root) and 6 nodes, each occupying three consecutive memory words. ; The first memory word of any node is the data contents field, while the second and ; third fields are the left son and right son links respectively. These contain ; the address of the successors of the current node in the tree. Each end of the ; tree is marked by a node with both left and right sons being null pointers ; (equal to 0). A node with two null links is called a leaf node of the tree. ; Note the use of the org directive to insert nodes at random places in memory. This ; is not necessary, but makes clear the possible memory sparsity of this kind ; of data structure. ; ; .data org #60h ; Below this line is an example binary tree root: db #0Ah ; tree root contents field db #node1 ; root left son link field db #node2 ; root right son link field node1: db #10h ; node1 contents field db #0 ; node1 left son link field db #node5 ; node1 right son link field org #67h node2: db #0ffh ; node2 contents field db #node4 ; node2 left son link field db #node3 ; node2 right son link field org #73h node3: db #0FAh ; node3 contents field db #0 ; node4 left son link field db #0 ; node4 right son link field org #0C7h node4: db #0ABh ; node4 contents field db #node6 ; node4 left son link field db #0 ; node4 right son link field org #70h node5: db #35h ; node5 contents field db #0h ; node5 left son link field db #0h ; node5 right son link field org #80h node6: db #22h ; node6 contents field db #0h ; node6 left son link field db #0h ; node6 right son link field .enddata