Add leading decimal output

This commit is contained in:
Michaelangel007 2017-06-11 07:45:23 -07:00
parent 21568e47be
commit 2d952db908
3 changed files with 16 additions and 11 deletions

View File

@ -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` 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 1. Multipy N by 10
2. Print the Integer Part digit 2. Print the Integer Part digit
@ -40,20 +40,21 @@ See file [print_fract.s](print_fract.s)
``` ```
CALL-151 CALL-151
0800:a2 b5 a0 e9 20 15 08 a2 00 bd 70 08 20 ed fd e8 0800:a2 b5 a0 e9 20 1a 08 a9 ae 20 ed fd a2 00 bd 76
0810:e0 05 d0 f5 60 a9 00 8d 6a 08 8e 6b 08 8c 6c 08 0810:08 20 ed fd e8 e0 05 d0 f5 60 8e 71 08 8c 72 08
0820:a2 00 20 60 08 20 54 08 20 60 08 20 60 08 20 44 0820:20 6a 08 aa 20 60 08 20 54 08 20 60 08 20 60 08
0830:08 ad 6a 08 09 b0 9d 70 08 a9 00 8d 6a 08 e8 e0 0830:20 44 08 ad 70 08 09 b0 9d 76 08 20 6a 08 e8 e0
0840:05 d0 df 60 18 a0 02 b9 6a 08 79 6d 08 99 6a 08 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 6a 08 99 6d 08 88 10 f7 60 0850:88 10 f4 60 a0 02 b9 70 08 99 73 08 88 10 f7 60
0860:0e 6c 08 2e 6b 08 2e 6a 08 60 00 00 00 00 00 00 0860:0e 72 08 2e 71 08 2e 70 08 60 a9 00 8d 70 08 60
0870:00 00 00 00 00 0870:00 00 00 00 00 00 00 00 00 00 00
800G 800G
E000G
``` ```
## Output ## Output
``` ```
71058 .71058
``` ```

BIN
print_fract.bin Normal file

Binary file not shown.

View File

@ -1,5 +1,7 @@
ORG $800 ORG $800
COUT EQU $FDED
; ==================== Demo ==================== ; ==================== Demo ====================
Demo Demo
@ -17,10 +19,12 @@ Demo
LDY #$E9 LDY #$E9
JSR PrintFract JSR PrintFract
LDA #'.'+$80
JSR COUT
LDX #0 LDX #0
PrintDigit PrintDigit
LDA D0,X LDA D0,X
JSR $FDED JSR COUT
INX INX
CPX #5 ; 5 decimal digits CPX #5 ; 5 decimal digits
BNE PrintDigit BNE PrintDigit