assembly language! please help me! thanks in advance!
how does AAA(ASCII adjust after addition) really works?
how does Binary-Coded Decimal addition really works? how to change 006Ah to 0100h after use aaa? Code:
mov ah, 0 |
The key thing about "Binary Coded Decimal" (BCD) is that each byte only holds decimal digits (values between 0..9). It's often used in controller applications (e.g. a clock or timer that needs to display decimal values).
So the number "123" (decimal "one hundred twenty three") is represented like this: Code:
Binary BCD "Unpacked BCD" is even LESS efficient: you only store ONE decimal digit per byte. Here are two good links: http://en.wikipedia.org/wiki/Intel_BCD_opcode http://www.arl.wustl.edu/~lockwood/c..._6/CH06-2.html <= Search for "aaa and daa instructions" PS: As you're probably aware, the general BCD instructions (the kind you're using above) only support signed arithmetic. PPS: A good book (if I haven't already recommended it to you), is: "Professional Assembly Language", Richard Blum |
Quote:
Now further down that page, if you look at http://mayaweb.upr.clu.edu/~borges/Chp5.pdf, you'll see an excellent tutorial on how the more complex circuits, including BCD are constructed. And now you know that, you should be able to work out why the original Z80 has a four bit alu, why it didn't look like that to a programmer (ie, took two passes through the 4 bit alu to do eight bith math) and why it was a bad idea. |
Quote:
|
Quote:
Code:
mov ah, 0 |
All times are GMT -5. The time now is 03:25 PM. |