[A83] Re: The Working Of Floating Point Numbers


[Prev][Next][Index][Thread]

[A83] Re: The Working Of Floating Point Numbers




> What is the DAA instruction and what is 8.8 format?
> 
1. DAA is the "Decimal Adjust after Addition" instruction, 
which does a BCD correction of the A register. I rather 
copy it from my guide, because I'm just lazy to write it 
down again. :) So:

"Decimal Adjust after Addition; no operands are needed. 
When this instruction is executed, the A register is BCD 
corrected. The exact process is the following: if the least 
significant four bits of A contain a non-BCD digit (i. e. 
it is greater than 9), then $06 is added to the register. 
Then the four most significant bits are checked. If this 
more significant digit also happens to be greater than 9, 
then $60 is added. If this second addition was needed, the 
C flag is set, otherwise it is reset. The N flag is 
preserved, P/V is <i>parity</i> and the others are altered 
by definition."

2. 8.8 means that 8 bits are used for the integer part, and 
another 8 for the fractional part. I.e. a 8.8 fixed point 
number can be loaded into a 16-bit register, so you can add 
and subtract them easily with single ADD/ADC/SBC 
instructions. When multiplying two 8.8 numbers, you have to 
divide the result by 256, naturally. Fixed points basically 
means that you have an integer that you do not interpret as 
an integer but as a N-digit number whose decimal point is 
fixed to the same place.

Example: 5.25 as a 8.8 fixed point number:

%00000101 01000000 = 256*5+256*0.25 = 1280+64 = 1344d

PG



Follow-Ups: References: