Jump to content

output number from ascii char [solved]


Recommended Posts

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

Edited by grimx
Link to comment
Share on other sites

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 ??

Edited by grimx
Link to comment
Share on other sites

###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

Edited by grimx
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...