> Did any one need REAL BCD math like the Big Boys
had?
On Sat, 27 Apr 2024, Jon Elson via cctalk wrote:
No, this is a fallacy. Binary arithmetic is as
"accurate" as decimal.
Handling VERY large numbers in floating point loses some precision, but any
computer can do multiple word binary quite well. And, the obvious example
is doing division in decimal still can end up with remainders. Back in the
day, banks were terribly worried about defalcation by the guys who maintain
the daily interest program. The classic story is the guy who adjusts the
code to take those fractional cents that get rounded back to the bank and
sends 10% to their own account. Now, there are so many really serious ways
fraudsters can steal from banks and their customers that nobody is too
worried about that sort of inside job.
A common beginer mistake was to use floating point for money.
i told my students to use a long int, and then print a period before the
last two digits.
On the PC, I used a little decimal arithmetic in the "Sales Tax
Genie" TSR, but mostly, I just used AAM and DAA in binary/decima
conversion.
How many know that AAM is a two byte instruction, with te second byte
beint 0Ah?
Changing the second byte to 8 gave division by 8, etc.
What is the smallest code to screen display a 16 bit number in hex?
anything smaller than?: (I expect some clever alternatives)
PUSH CX
MOV CX, 0404h ; CH and CL are independent
N1: ROL AX, CL
PUSH AX
AND AL, 0Fh
DAA
ADD AL, 0F0h
ADC AL, 40h
MOV AH, 0Eh ;displays char in AL at cursor position
INT 10h
POP AX
DEC CH
JNZ N1
PO CX
--
Grumpy Ol' Fred cisin(a)xenosoft.com