I am attempting to analyze a string such as "20times30", storing 20 in one memory or register location, then 30 in an alternate memory location. I am able to do it with single digit integers such as "2times3" however, I am unsure as to storing more than 1 digit sequentially.
I have tried storing the first digit into a memory location, then looping and shifting the store location to store the second digit. The issue is that it creates 0x00000002 and 0x00000002 for example in memory rather than 22.
AREA Lab6, CODE, READONLY
ENTRY
LDR r0,=ASCII_STRING ;Load ASCII string into r0 for processing
LDR r2,=operand_1 ;Create essentially a variable that the numbers can be stored to
LDR r3,=operand_2 ; Load an inititial value of 0 into register 3
MOV r5,#0x0
MOV r6,#0x0
numbers
LDRB r1,[r0]
CMP r1,'9'
BHI letters
CMP r1,'0'
BLS stop
BHI convertnumbers
CMP r1,'G'
BEQ stop
letters
CMP r1,'t'
MOVEQ r4,'t'
ADDEQ r0,#5
BEQ numbers2
CMP r1,'a'
MOVEQ r4,'a'
ADDEQ r0,#3
BEQ numbers2
BNE stop
convertnumbers
SUB r1,r1,#0x30
STRB r1,[r2,r5]
ADD r5,r5,#1
B numbers
numbers2
LDRB r1,[r0]
CMP r1,'9'
BHI letters
CMP r1,'0'
BLS stop
BHI convertnumbers2
CMP r1,'G'
BEQ stop
convertnumbers2
SUB r1,r1,#0x30
STRB r1,[r3,r5]
ADD r6,r6,#1
B numbers
stop b stop
AREA asciiCode, DATA, READONLY
ASCII_STRING DCB "2times3",'G' ;ASCII code string
AREA binary_form, DATA, READWRITE
operand_1 SPACE 20 ;area to store converted binary string
operand_2 SPACE 20 ; op2
END
The memory value at the effective address of operand_1 should be 22 rather than 02 02. I realize the loop currently infinitely stores 02 into the memory; however, I believe I can fix that.
User contributions licensed under CC BY-SA 3.0