Posts

Showing posts with the label Assembler

A Code from the past

  I wrote this when I got interested in assembler. Pulled from old emails. # # This program takes 10 integer values from user, # inserts them into a binary tree and then prints # the tree "inorder" # # # The tree_node is like this: #   struct tree_node { #       int value; #       struct tree_node *left; #       struct tree_node *right; #    } .text #----------------------------------------------------------- # # This function prints a given node. # The nodes pointer is provided in $a0. # print_node:     subu    $sp, $sp, 32            # space on stack     sw      $ra, 28($sp)            # store the return address     sw      $fp, 24($sp)            # store the current frame pointer.     addiu    $fp, $sp, 32           # $fp to start of stack.         move    $t0, $a0                # save the nodes pointer to $t0     lw      $a0, ($t0)              # move the integer value to $a0.     jal     print_int_with_newline  # print the integer.     nop     lw      $ra, 28(