tisc

tiny instruction set computer
Log | Files | Refs | README

fibb_test.tac (660B)


      1 # fibb_test - This program computes the classic Fibbonacci sequence
      2 ###################### Set our memory pointer
      3         li 254
      4         sp GRA
      5 ###################### Set our inital state
      6         cin NIL GRC
      7 ###################### Printout current state
      8 loop:   sb GRB
      9 ###################### Swap GRB and GRC
     10         sop_xor
     11         op GRB GRC GRC
     12         op GRB GRC GRB 
     13         op GRB GRC GRC
     14 ###################### Add GRB and GRC
     15         sop_add
     16         op GRB GRC GRB
     17 ###################### Test if we've reached the limit if GRA+GRB overflows 
     18         cmp GRB GRC
     19         jmp loop
     20 ###################### Idle around forever
     21         sb GRB
     22 end:    jmp end