Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   stumped on decimal input to 16 bit binary...including negative input (http://www.go4expert.com/forums/stumped-decimal-input-16-bit-t16477/)

guitarlady3000 9Mar2009 07:36

stumped on decimal input to 16 bit binary...including negative input
 
Hi everyone! I'm new here and I'm very new at this language so here it goes:

I am writing a little program that converts a decimal input to a 16 bit binary number, and it will keep asking for input until the user types in zero. I have already written a good portion of this, but I am not sure how to handle the case if the input is a negative number and I am also not sure how to output it in 16 bits...I think it has something to do with shifting??? If anyone could help it would be greatly appreciated. Thanks in advance....I am using PEP/8 to do this as well:

begin: stro prompt, d
deci num, d
lda num, d
sta num, d
getBin: lda num, d
cpa 0, i
breq stop
anda 1, i
sta bin, d
deco bin, d
lda num, d
asra
sta num, d
lda num, d
cpa 0, i
br getBin
stop: STOP
bin: .block 2
num: .block 2
num2:.block 2
prompt: .ascii " Please enter a decimal number:\x00"
.end


All times are GMT +5.5. The time now is 05:33.