1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

stumped on decimal input to 16 bit binary...including negative input

Discussion in 'Assembly Language Programming (ALP) Forum' started by guitarlady3000, Mar 9, 2009.

  1. guitarlady3000

    guitarlady3000 New Member

    Joined:
    Mar 9, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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
     

Share This Page