linux - Understanding input and output in ASM -


can please me understand happening here? new assembly language , have written simple code follows: (i developing on linux)

what want accept integer user , display user has entered.

 .section .data  number:     .long 0  .section .text  .globl _start  _start:  movl $3, %eax           #read system call movl $0, %ebx                   #file descriptor (stdin) movl $number, %ecx              #the address data read into.   movl $4, %edx                   #number of bytes read  int $0x80  #the entered number stored in %ebx. can viewed using "echo $? " movl number , %ebx               movl $1, %eax int $0x80 

but not getting expected result. instead getting ascii codes character inputting.

for ex:

input - 2 output - 50  input - 1 output - 49   input - output - 97 ....  , on? 

what wrong? changes should make have desired result? basic concept missed understanding.

input done in system's native codepage. if want convert numeral's ascii code corresponding number need 2 things first:

  1. bounds check it. value must between '0' , '9' inclusive, otherwise wasn't numeral.

  2. subtract '0'. way '0' becomes 0, '5' becomes 5, etc.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -