-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.asm
83 lines (83 loc) · 752 Bytes
/
test.asm
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//Storing 8 in a
@8
D=A
@A
M=D
//storing 9 in b
@9
D=A
@B
M=D
//Now for x = a+b
//store a in x
@A
D=M
@X
M=D
//and add 1 to x,(b times)
@B
D=M
@Temp //variable for counting
M=D
//LOOP
(LOOP)
@Temp
D=M
@PART2
D;JEQ
@X
M=M+1
@Temp
M=M-1
@LOOP
0;JMP
//x=a+b part is done Now
//Add a in x and store in y
(PART2)
@A
D=M
@Temp2 //2nd variable for counting
M=D
@X
D=M
@Y
M=D
(LOOP2)
@Temp2
D=M
@PART3
D;JEQ
@Y
M=M+1
@Temp2
M=M-1
@LOOP2
0;JMP
//multiply y with b
//for multiplying add y to y b for b times
(PART3)
@B
D=M
@Temp3 //3rd variable for counting
M=D
M=M-1 //decreasing it for 1 time because 1 25 is already present,so we will add 8 times 25
@Y
D=M
@New
M=D
(LOOP3)
@Temp3
D=M
@End
D;JEQ
@New
D=M
@Y
M=D+M
@Temp3
M=M-1
@LOOP3
0;JMP
(End)
@End
0;JMP