Problem 5 In this problem, you will write a LC-3 assembly code that removes blan
ID: 3817448 • Letter: P
Question
Problem 5
In this problem, you will write a LC-3 assembly code that removes blank spaces from a string. Assume that the string starts at memory location 0x4000, and is terminated by a ‘’ character (ASCII value = 0). Your program should store the modified string in the memory location starting at 0x4100. You do not need to modify the original string stored at 0x4000. You can assume that the original string at 0x4000 will always be less than 100 characters in length, and it will always start with a letter (A-Z, lowercase or uppercase possible).
Note: If the modified string has 7 characters, and the original string has 15 characters, the last 8 characters of your modified string should be all ‘’ (ASCII value = 0).
For example: If the original string at 0x4000 was “aa 12 d e f ”, the modified string at 0x4100 after your program completes execution should be “aa12def” . Note that the original string has 8 blank space characters, and the modified string has 8 extra “” in the end. Your code should start at memory location 0x3000.
Explanation / Answer
.ORIG x3000
LD R3, POSASC ;Loads R3 with #48
LD R4, NEGASC
LD R1, word ;R1 = word
Include R6, R6, #5 ;Length of word
GETC ;Gets the burn
OUT ;Prints the burn
Include R2, R2, R0 ;Stores the burn in R2
;Include R2, R2, R4 ;To ascii
What's more, R0, R0, #0 ;set R0 back to 0
Circle
Furthermore, R5, R2, R1 ;check if roast is equivalent
Include R1, R1, #1 ;augmentation to next roast in word
Include R6, R6, #-1
BRnp LOOP
Include R0, R0, R5 ;Set R0 to # of events
OUT ;Print # of events
End
POSASC .FILL x0030 ;#48
word .STRINGZ "hi" ;word to tally events of a scorch
NEGASC .FILL xFFD0 ;#-48
.END