Help - Search - Members - Calendar
Full Version: output number from ascii char [solved]
MandrivaUsers.org > Advanced Topics > Command Line, Kernel and Programming
grimx
ok i have

###abbrev
.lcomm num1, 4
.lcomm num2, 4
.lcomm ans, 4

.section text
.globl _start
_start:
get input for num1 ###abbrev
## using system calls read to get inputs
get input for num2 ###abbrev

movl num1, %eax
addl num2, %eax

##how do i change the ascii char's into decimal
## so i can put the them into the ans buffer for output
## sorry thats about as clear as i can state my problem

## going to use system call write for output of ans buffer
grimx
ok i got it:
ok so you zero out ah and subtract 48 from al to get the decimal from ascii ??

so i need to do that for num1 and num2, before i add them
and the result should be in decimal ??
grimx
###abbrev
.lcomm num1, 4
.lcomm num2, 4
.lcomm ans, 4

.section text
.globl _start
_start:
get input for num1 ###abbrev
## using system calls read to get inputs
get input for num2 ###abbrev


i tryed this on both num1 and num2, it didn't work
i also tried it on all three (num1, num2) added them togather and put them
in ans, and tried it, it still doesn't work.
What Am I Doing Wrong

##abbrev

movl $0, %ecx
conversion_loop:
subb $48, num1(, %ecx, 1)
inc %ecx
cmp $3, %ecx
jne conversion_loop

## abbev

movl num1, %eax
addl num2, %eax

### abbrev
grimx
problem solved
i forgot to convert the numbers back to ascii to display them
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.