.ORIG x3000
; Take Input from user
LEA R3,Label ; load array base addr in R3
LD R2,Ten ; load 10 in R2 (counter)
Input
TRAP x23 ; input character
STR R0,R3,#0 ; store inputted char in memory
ADD R3,R3,#1 ; increment array base addr
ADD R2,R2,#-1 ; decrement counter register R2
BRp Input ; branch to input if R2 is positive
; Add 1 to each inputted character
LEA R3,Label ; load array base addr in R3
LD R2,Ten ; load 10 in R2 (counter)
Add1
LDR R0,R3,#0 ; load value from mem in R0
ADD R0,R0,#1 ; increment R0 so it'll be plus 1 character
STR R0,R3,#0 ; store inputted char in memory
ADD R3,R3,#1 ; increment array base addr
ADD R2,R2,#-1 ; decrement counter register R2
BRp Add1 ; branch to Add1 if R2 is positive
; Output resultant Array character each in New Line
LEA R3,Label ; load array base addr in R3
LD R2,Ten ; load 10 in R2 (counter)
OutputByNewLine
LDR R0,R3,#0 ; load value from mem in R0
TRAP x21 ; display character stored in R0 on console
AND R0,R0,#0
LD R0,NewLine ; load ascii value of NewLine in R0
TRAP x21
ADD R3,R3,#1 ; increment array base addr
ADD R2,R2,#-1 ; decrement counter register R2
BRp OutputByNewLine ; branch to Output if R2 is positive
; Output resultant Array character each separated by Space
LEA R3,Label ; load array base addr in R3
LD R2,Ten ; load 10 in R2 (counter)
OutputBySpace
LDR R0,R3,#0 ; load value from mem in R0
TRAP x21 ; display character stored in R0 on console
AND R0,R0,#0
LD R0,Space ; load ascii value of Space in R0
TRAP x21
ADD R3,R3,#1 ; increment array base addr
ADD R2,R2,#-1 ; decrement counter register R2
BRp OutputBySpace ; branch to Output if R2 is positive
HALT
Label .BLKW #10
Ten .FILL #10
NewLine .FILL x000A
Space .FILL x0020
.END