Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 24th, 2005, 10:46 PM   #1
rick barclay
Newbie
 
Join Date: Apr 2005
Posts: 1
Rep Power: 0 rick barclay is on a distinguished road
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?
rick barclay is offline   Reply With Quote
Old Apr 25th, 2005, 9:42 PM   #2
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 4 lostcauz is on a distinguished road
Raymond Filiatreault discusses AAM here.
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:48 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC