Jump to content
Sign in to follow this  
grimx

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...