0

How do i convert char into integer. I am using arm komodo. so far i have managed to take an input from the user and print this out to the screen. However i need to covert this chosen char "number" into a integer "number". I have no idea where to start please help! Also i know I have a loop that will not stop. I will try fix that problem later on.

    B main

question    DEFB    "How many verses do you want to print?",0
answer      DEFB    "",0
input       DEFB    "a",0
newline     DEFB    "\n",0
done        DEFB    "done\n",0


    ALIGN

main    
loop    ADR R0,question
    SWI 3

    SWI 1

    STR R0,answer

    ADR R0,answer
    SWI 3

    ADR R0,newline
    SWI 3

    B loop

    ADR R0,done
    SWI 3

    SWI 2
ProtectorOfUbi
  • 317
  • 5
  • 13
  • Hint: have a look at the character codes in whatever character set you're using (presumably ASCII) and see if there's any obvious relationship between the _value_ of a digit character and the number it represents. – Notlikethat Nov 06 '15 at 09:06
  • I know that numbers have values 47 to 58 so from there is easy to find the integer equivalent however im not sure what syntax to use to get the ascii values of the chars the user inputs. – ProtectorOfUbi Nov 06 '15 at 13:33
  • Er, you already _have_ the value. If the input routine gives you back a "character", that "character" is still just a number in a register. – Notlikethat Nov 06 '15 at 14:33

0 Answers0