Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Assembly Language Questions
Closed Thread
Old 04-21-2005, 12:49 PM   #1 (permalink)
 
Newb Techie

Join Date: Apr 2005

Posts: 1

rick barclay

Default Assembly Language Questions

My newest project:
Develop a program that will allow a user to input
two numbers of any length.. and derive the product of the two numbers.

Strategy:
User enters numbers of any size into a string. Convert ascii to integer. Math is performed one digit at a time.

This a good opportunity to use AAM (ascii adjust after
multiplication); however, I have a couple questions on how to use this
operation.

From what I understand, one would load the AL (for 8bit 'char'
operations) and perform a normal MUL operation.. thus leaving the
product in the AX register. The AX now contains a value that is
(ascii*ascii). At this point, use AAM to convert to an unpacked
decimal representation.

Next, to turn this value back into an ascii character.. The closest
example on how to do this in Kip Irvine's book on page 252 (in the AAA program example) which indicates that one can OR the (ascii*ascii) product
with its unpacked decimal to obtain the comperable ascii value. Is
this a valid operation? If so, will this work in all cases? This
would seem to be a very cool property.. and I am suprised we were
never taught this technique in class..

Summary:
I think AAM is comperable to c++'s atoi( ) function.. whereas 'OR'ing
the product of two ascii with it's unpacked decimal resembles the
itoa( ) function.

So is my logic correct? If not, please point out any fallacies. Here is a simple explaination of ASCII Adjust Operators.. doesn't go into much detail at all: http://docs.sun.com/app/docs/doc/80...jct9o0ao?a=view


Another problem to tackle:
With this type of program, it would be nice to create new memory at runtime depending on the size of the numeric strings entered. Is it possible to declare new memory at runtime in assembly? IF so how? IF not, should I just declare bunch of space at assembly and hope that is good enough?
rick barclay is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On