Guest User

Untitled

a guest
Apr 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Part3 where
  2.  
  3. import TAMCode
  4. import TAMInterpreter
  5.  
  6. test = [LOADL 1, LOADL 2, ADD, PUTINT, LABEL "end", STORE (SB (-0))]
  7.  
  8.    
  9. part1   =   [   GETINT,         -- Read integer n onto stack
  10.                 LOADL 1,        -- Load integer 1 onto stack
  11.                 LOAD (SB 0),    -- Duplicate top of stack
  12.                 LSS,            -- Check if n < 1
  13.                 JUMPIFZ "end",
  14.                 LOADL 1,
  15.                 LABEL "loop",
  16.                 LOAD (SB 1),    -- Load current number to top of stack
  17.                 PUTINT,         -- Print the current number
  18.                 LOADL 1,        -- Load 1 (ready to add)
  19.                 ADD,            -- Add 1 to the current number             
  20.                 LOAD (SB 0),
  21.                 LOAD (SB 1),
  22.                 LSS,
  23.                 JUMPIFNZ "end",
  24.                 JUMP "loop",
  25.                 LABEL "end" -- End block]
Add Comment
Please, Sign In to add comment