Files
PPL-Fall-2018/VPL/ex1b
2018-10-15 12:47:14 -06:00

34 lines
651 B
Plaintext
Executable File

0 Here's the map between local cells and names:
0 Local cell: Name:
0 0 n (input value)
0 1 2 (literal)
0 2 1 (literal)
0 3 n % 2
4 4 allocate space for 4 local cells
27 0 local cell 0 <- input value (n)
22 1 2 local cell 1 <- literal 2
22 2 1 local cell 2 <- literal 1
13 3 0 1 local cell 3 <- n % 2 (conveniently 0 or 1
8 1001 3 if n%2 is not 0 jump to 1001
0 case that n is even
28 1 display 2 to say that n is even
29
7 1002 hop over code for odd case
1 1001 case that n is odd
28 2 display 1 to say that n is odd
29
1 1002
26