I need to create a program that takes as the first input : A decimal number and as a second input the number of the base it will be converted to . then outputs the result of the conversion .
I looked everywhere on the internet but i cant seem to find anything that would help me move forward .
here is my code so far
INP number
STA number
INP base
STA base
LOOP LDA number
BRZ END
SUB base
STA number
LDA ANS
ADD ONE
STA ANS
BRA LOOP
END LDA ANS
STO number
SUB ANS
STA ANS
OUT
BRA LOOP
HLT
number DAT
base DAT
ANS DAT 0
ONE DAT 1
I had been trying to convert 12 to binary I expect to get : 0 as remainder for the first division 0 for second 1 for 3rd 1 for 4th but I actually get only the first 2 remainders before it loops indefinitely because of the negatives numbers on the accumulator .
thanks .