-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab4.asm
79 lines (71 loc) · 1.2 KB
/
Lab4.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
.ORIG x4000
AND R0, R0, #0
AND R1, R1, #0
AND R2, R2, #0
AND R3, R3, #0
AND R4, R4, #0
AND R5, R5, #0
START LD R5, TEST
LEA R0, TAB
TRAP x22
LEA R0, QUESTION
LD R1, TEST
TRAP x22
TRAP x23
ADD R2, R0, R5
ADD R4, R0, R5
ADD R1, R0, R1
BRz EXIT
BRn LOOP2
LD R1, TEST2
ADD R1, R0, R1
BRp LOOP2
BRnz LOOP
LOOP LEA R0, NEXT
TRAP x22
TRAP x23
LD R1, TEST
ADD R1, R0, R1
BRz EXIT
LD R1, TEST3
ADD R1, R0, R1
BRn LOOP4
LD R1, TEST4
ADD R1, R0, R1
BRp LOOP4
BRnz LOOP3
LOOP2 LEA R0, AGAIN
TRAP x22
BRnzp START
LOOP3 LD R3, UPCASE
ADD R0, R0, R3
TRAP x21
NOT R3, R3
ADD R3, R3, #1
ADD R0, R0, R3
ADD R2, R2, #-1
BRp LOOP3
LD R3, UPCASE
ADD R0, R0, R3
ADD R0, R0, #1
BRp LOOP5
LOOP4 LEA R0, AGAIN
TRAP x22
BRnzp LOOP
LOOP5 TRAP x21
ADD R4, R4, #-1
BRp LOOP5
BRz START
EXIT LEA R0, EXITMSG
TRAP x22
TAB .STRINGZ "\n"
QUESTION .STRINGZ "Enter a number 'n' between 0 through 9: \n"
NEXT .STRINGZ "Enter a lowercase letter (0 to exit): \n"
AGAIN .STRINGZ "Try again!\n"
EXITMSG .STRINGZ "BYE!!\n"
TEST .FILL #-48
TEST2 .FILL #-57
TEST3 .FILL #-97
TEST4 .FILL #-122
UPCASE .FILL #-32
.END