Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/18/07 23:35
Read: times


 
#145929 - Leg up
Responding to: ???'s previous message
Rodrigo,

I gather we're talking about a x86 style cpu here. firstly, you need to formulate an algorithm, then you can write the code. I'm not going to write the code for you since my x86 assembler is a little rusty and you need to learn.

Anyway,

result = 0
loop:
result = result * 10
get one input character
end of characters? exit
is it a number? if not,exit
subtract ascii offset
result = result + number
goto loop

so for an input of "123"

result = 0, result * 10 = 0, result+number = 1
result = 1, result * 10 = 10,result+number = 12
result = 12, result * 10 = 120, result+number = 123

Now, just write some assembler to perform this task. Job done.


List of 19 messages in thread
TopicAuthorDate
ASCII to Binary in Assembly            01/01/70 00:00      
   What guidance do you need?            01/01/70 00:00      
      this might be part of the fun :-)            01/01/70 00:00      
         Not 8051?            01/01/70 00:00      
            Isn't a double 32 bits?            01/01/70 00:00      
               I think so            01/01/70 00:00      
                  No, it's not correct            01/01/70 00:00      
               No, that's wrong.            01/01/70 00:00      
                  Thanks            01/01/70 00:00      
      I'm here so far !!            01/01/70 00:00      
         Definitely not 8051!            01/01/70 00:00      
            you are on 8052.com...            01/01/70 00:00      
      Sorry Andy            01/01/70 00:00      
         Leg up            01/01/70 00:00      
            I think i got it! may u check it?            01/01/70 00:00      
               listen to your teacher            01/01/70 00:00      
               Check            01/01/70 00:00      
   Bonus question            01/01/70 00:00      
      Lol            01/01/70 00:00      

Back to Subject List