LC3 continue getting a trap was executed with an illegal vector number

531 Views Asked by At

I am trying to create a program that will present the number input in binary to the user. Currently, all I have is the setup to get the user's number once they are finished typing all of their characters, however I don't understand why the code below will not run.

.ORIG x3000

RESET
AND R1, R1, #0
AND R2, R2, #0 
AND R3, R3, #0
AND R4, R4, #0

ASCII .FILL #-48   ;ASCII CONVERSION
LD R5, ASCII       ;

AND R6, R6, #0  ;NEGATIVE FLAG

DISPLAY .STRINGZ "\nTYPE A NUMBER THEN PRESS ENTER: "
LEA R0 DISPLAY
PUTS

loop

LOOP
GETC
OUT

AND R4, R4, #0   ;CHECK IF LF
ADD R4, R4, #-10 ;
ADD R4, R4, R0  ; 
BRZ READY

LD R4, CHECKN   ;check if negative
AND R4, R4, #0  ;
ADD R4, R4, R0  ;
BRZ NEGATIVE    ;

ADD R1, R0, R5
BRNZP MULTIPLY
ADD R2, R1, R3
BRNZP LOOP

NEGATIVE
ADD R6, R6, #1
BRNZP LOOP

multiply by adding the same number 10 times

MULTIPLY
ADD R3, R2, R2
ADD R3, R3, R2
ADD R3, R3, R2
ADD R3, R3, R2
ADD R3, R3, R2
ADD R3, R3, R2
ADD R3, R3, R2
ADD R3, R3, R2
ADD R3, R3, R2
BRNZP LOOP


CHECKN .FILL #-45

READY


HALT

.END
0

There are 0 best solutions below