![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Apr 2005
Posts: 1
Rep Power: 0
![]() |
ASCII Adjust after Multiplication
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? IF so how? IF not, should I just declare bunch of space at assembly and hope that is good enough? |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|