Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 ASCII, Machine Code, Basic Assembly Language
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Okapi




PostPosted: Wed Oct 24, 2007 1:09 pm   Post subject: ASCII, Machine Code, Basic Assembly Language

So I've to write a program to add two four digit values stored as ASCII strings. The strings are represented by values in decimal notation. The strings are stored at addresses $2000 and $2004. Store the result in d5 - and I need some help

I need help with the thoery and instructions. I don't want anyone to do it for me, just maybe explain how/why.

So far..

org $2000 * set the address at which the next instruction will be stored
move.b $2000,d3 * move byte at address $2000 to d3
move.b $2004,d4 * move byte at address $2004 to d4
add d3,d4 * add information stored in d3 to information stored in d4
trap #0 * return to monitor

Basically I don't understand the ASCII part, can someone exlpain?
Sponsor
Sponsor
Sponsor
sponsor
md




PostPosted: Wed Oct 24, 2007 2:10 pm   Post subject: RE:ASCII, Machine Code, Basic Assembly Language

not knowing if this is MIPS, Intel (which it seems to be...) or something else; and not recognizing the assembler syntax...

step 1 would be to convert your tow strings into integers; a simple function would work.

step 2 is to add the two integers; that's as simple as loading them into registers (if they aren't there already) and calling add (or some form thereof).

Lastly move the result into d5 if it isn't there already.

ASCII to integer is actually pretty easy to do. Try writing it in C first, then convert the C code to assembly.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: