mirror of
https://github.com/Michaelangel007/apple2_print_fixed16_fraction.git
synced 2024-10-31 13:06:18 +00:00
Add leading decimal output
This commit is contained in:
parent
21568e47be
commit
2d952db908
21
README.md
21
README.md
@ -6,7 +6,7 @@ Printing the fractional value of a 16-bit fixed point number in decimal is rathe
|
||||
|
||||
For example, the number `0.7106` in 16-bit fixed point is 0.71506 * 65536 = 46,569 = `$B5E9`
|
||||
|
||||
How do we convert the number `$B5E9` back into `7106` ? By _digit peeling._
|
||||
How do we convert the number `$B5E9` back into `.7106` ? By _digit peeling._
|
||||
|
||||
1. Multipy N by 10
|
||||
2. Print the Integer Part digit
|
||||
@ -40,20 +40,21 @@ See file [print_fract.s](print_fract.s)
|
||||
|
||||
```
|
||||
CALL-151
|
||||
0800:a2 b5 a0 e9 20 15 08 a2 00 bd 70 08 20 ed fd e8
|
||||
0810:e0 05 d0 f5 60 a9 00 8d 6a 08 8e 6b 08 8c 6c 08
|
||||
0820:a2 00 20 60 08 20 54 08 20 60 08 20 60 08 20 44
|
||||
0830:08 ad 6a 08 09 b0 9d 70 08 a9 00 8d 6a 08 e8 e0
|
||||
0840:05 d0 df 60 18 a0 02 b9 6a 08 79 6d 08 99 6a 08
|
||||
0850:88 10 f4 60 a0 02 b9 6a 08 99 6d 08 88 10 f7 60
|
||||
0860:0e 6c 08 2e 6b 08 2e 6a 08 60 00 00 00 00 00 00
|
||||
0870:00 00 00 00 00
|
||||
0800:a2 b5 a0 e9 20 1a 08 a9 ae 20 ed fd a2 00 bd 76
|
||||
0810:08 20 ed fd e8 e0 05 d0 f5 60 8e 71 08 8c 72 08
|
||||
0820:20 6a 08 aa 20 60 08 20 54 08 20 60 08 20 60 08
|
||||
0830:20 44 08 ad 70 08 09 b0 9d 76 08 20 6a 08 e8 e0
|
||||
0840:05 d0 e1 60 18 a0 02 b9 70 08 79 73 08 99 70 08
|
||||
0850:88 10 f4 60 a0 02 b9 70 08 99 73 08 88 10 f7 60
|
||||
0860:0e 72 08 2e 71 08 2e 70 08 60 a9 00 8d 70 08 60
|
||||
0870:00 00 00 00 00 00 00 00 00 00 00
|
||||
800G
|
||||
E000G
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
```
|
||||
71058
|
||||
.71058
|
||||
```
|
||||
|
||||
|
BIN
print_fract.bin
Normal file
BIN
print_fract.bin
Normal file
Binary file not shown.
@ -1,5 +1,7 @@
|
||||
ORG $800
|
||||
|
||||
COUT EQU $FDED
|
||||
|
||||
; ==================== Demo ====================
|
||||
|
||||
Demo
|
||||
@ -17,10 +19,12 @@ Demo
|
||||
LDY #$E9
|
||||
JSR PrintFract
|
||||
|
||||
LDA #'.'+$80
|
||||
JSR COUT
|
||||
LDX #0
|
||||
PrintDigit
|
||||
LDA D0,X
|
||||
JSR $FDED
|
||||
JSR COUT
|
||||
INX
|
||||
CPX #5 ; 5 decimal digits
|
||||
BNE PrintDigit
|
||||
|
Loading…
Reference in New Issue
Block a user