직사각형의 면적을 계산하는 코드를 생성하고 있습니다. 곱셈을했는데 숫자 0-9 만 표시합니다. 교수님은 2 자리 숫자를 표시하기 위해 10을 루프에서 빼고 루프가 몇 번 발생하는지 계산해야한다고했습니다. 나는 그것을 시험해 보았고 누군가가 나를 도와 줄 수 없다.lc3에 두 자리 숫자를 표시하는 방법
.ORIG x3000
AND R3, R3, #0 ;r3 stores the sum, set r3 to zero
AND R4, R4, #0 ;r4 is the counter
LD R5, INVERSE_ASCII_OFFSET ;inverse ascii offset
LD R6, DECIMAL_OFFSET ;decimal offset
;---------------------
;storing first input digits
LEA R0, display1 ;load the address of the 'display1' message string
PUTS ;Prints the message string
GETC ;get the first number
OUT ;print the first number
ADD R1, R0, #0 ;store input value(ascii) to r1
ADD R1, R1, R5 ;get real value of r1
;storing second input digits
LEA R0, display2 ;load the address of the 'display2' message string
PUTS ;Prints the message string
GETC ;get the first number
OUT ;print the first number
ADD R2, R0, #0 ;store input value(ascii) to r2
ADD R2, R2, R5 ;get real value of r2
;----------------------
ADD R4, R2, #0 ;fill counter with multiplier
MULTIPLICATION:
ADD R3, R3, R1 ;add to sum
ADD R4, R4, #-1 ;decrease counter by one
BRp MULTIPLICATION ;continue loop until multiplier is 0
;----------------------
;Product in R3
AND R1, R1, #0 ;r1 will hold -10
AND R2, R2, #0 ;r2 = 10's counter
AND R4, R4, #0 ;r4 = 1's counter
AND R5, R5, #0 ;r5 will hold the answer
LD R1, NEG_TEN ;r1 = -10
ADD R5, R3, #0 ;copy answer to r5
Loop1
ADD R5, R5, R1 ;Product - 10
BRn EndDec
ADD R2, R2, #1 ;increment 10's counter by 1
BRnzp Loop1
;----------------------
LEA R0, stringResult
PUTS
ADD R0, R3, R6 ;move result to r0
OUT ;print result
HALT
display1 .STRINGZ "\nenter the length: "
display2 .STRINGZ "\nenter the width: "
stringResult .STRINGZ "\nArea: "
INVERSE_ASCII_OFFSET .fill xFFD0 ; Negative of x0030.
DECIMAL_OFFSET .fill #48
NEG_TEN .fill #-10 ; -10