-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlt.asm
More file actions
50 lines (47 loc) · 777 Bytes
/
lt.asm
File metadata and controls
50 lines (47 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@256 //put base address of stack in SP (we don't need this in general)
D=A
@SP
M=D
@5 //value to be pushed on stack
D=A //D=5
@SP //load RAM[0]
A=M //put value at RAM[0] in A register
M=D //put 5 in RAM[256]
@SP
M=M+1 //increment stackpointer
@6 //value to be pushed on stack
D=A //D=5
@SP //load RAM[0]
A=M //put value at RAM[0] in A register
M=D //put 5 in RAM[256]
@SP
M=M+1 //increment stackpointer
//-------start of lt-------
@SP //get value at stack pointer
M=M-1 //decrement
A=M
D=M //put last value in D register
@SP
M=M-1
A=M
A=M //put next to last value in A register
// A<D
D=A-D //check to see if this is z
@AROUND
D;JLT
//return false A<D
@SP
A=M
M=0
//jump past around
@END_COMP
0;JMP
(AROUND)
//return true
@SP
A=M
M=-1
(END_COMP)
//increment SP
@SP
M=M+1