dev: removing old printChar and instead using OS print vector

This commit is contained in:
A.M. Rowsell 2025-12-20 18:36:58 -05:00
commit cb332b7b05
Signed by: amr
GPG key ID: E0879EDBDB0CA7B1
6 changed files with 43 additions and 51 deletions

View file

@ -1,28 +1,26 @@
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: MPL-2.0
# SPDX-FileCopyrightText: (c) 2025 A.M. Rowsell
ASM=vasm_z80_std ASM=vasm_z80_std
LINK=vlink LINK=vlink
ASMFLAGS=-Fvobj ASMFLAGS=-Fvobj
LINKFLAGS=-b ihex -T linker.cmd LINKFLAGS=-b ihex -T linker.cmd
all: float.hex all: zone.hex
float.o: float.asm float.o: float.asm
$(ASM) $(ASMFLAGS) -o $@ $< $(ASM) $(ASMFLAGS) -o $@ $<
printChar.o: printChar.asm
$(ASM) $(ASMFLAGS) -o $@ $<
vectorTable.o: vectorTable.asm vectorTable.o: vectorTable.asm
$(ASM) $(ASMFLAGS) -o $@ $< $(ASM) $(ASMFLAGS) -o $@ $<
zone.o: zone.asm zone.o: zone.asm
$(ASM) $(ASMFLAGS) -o $@ $< $(ASM) $(ASMFLAGS) -o $@ $<
float.hex: float.o printChar.o vectorTable.o zone.o linker.cmd zone.hex: float.o vectorTable.o zone.o linker.cmd
$(LINK) $(LINKFLAGS) -o $@ float.o printChar.o vectorTable.o zone.o $(LINK) $(LINKFLAGS) -o $@ float.o vectorTable.o zone.o
clean: clean:
rm -f float.o printChar.o vectorTable.o zone.o float.hex rm -f float.o vectorTable.o zone.o zone.hex
.PHONY: all clean .PHONY: all clean

View file

@ -22,7 +22,7 @@
; fp_div: A = A / B ; fp_div: A = A / B
; ;
; Extra: ; Extra:
; fp_print: print float at (HL) using external printChar (A=ASCII) ; fp_print: print float at (HL) using external os_print_vec (A=ASCII)
; fp_parse: parse null-terminated string at (DE) into float at (HL) ; fp_parse: parse null-terminated string at (DE) into float at (HL)
; ;
; Limitations: ; Limitations:
@ -36,16 +36,16 @@
.equ FRAC_DIGITS,6 .equ FRAC_DIGITS,6
.equ MAX_FRAC,6 .equ MAX_FRAC,6
.extern printChar .extern os_print_vec
; ============================================================ ; ============================================================
; CODE ; CODE
; ============================================================ ; ============================================================
.section float .section "float","acrx"
; ------------------------------------------------------------ ; ------------------------------------------------------------
; External routine you provide: ; External routine you provide:
; printChar: prints ASCII character in A ; os_print_vec: prints ASCII character in A
; ------------------------------------------------------------ ; ------------------------------------------------------------
; printChar is external, not defined here. ; os_print_vec is external, not defined here.
; ============================================================ ; ============================================================
; Public API: fp_add / fp_sub / fp_mul / fp_div ; Public API: fp_add / fp_sub / fp_mul / fp_div
@ -94,7 +94,7 @@ fp_sub:
push de push de
inc de inc de
ld a,(de) ld a,(de)
xor 080h xor 0x80
ld (de),a ld (de),a
pop de pop de
pop hl pop hl
@ -106,7 +106,7 @@ fp_sub:
push de push de
inc de inc de
ld a,(de) ld a,(de)
xor 080h xor 0x80
ld (de),a ld (de),a
pop de pop de
pop hl pop hl
@ -254,7 +254,7 @@ fp_unpackA:
ld a,(hl) ld a,(hl)
ld b,a ld b,a
; sign bit -> A_sign (0/1) ; sign bit -> A_sign (0/1)
and 080h and 0x80
jp z,fp_unpackA_sa0 jp z,fp_unpackA_sa0
ld a,1 ld a,1
jr fp_unpackA_sa1 jr fp_unpackA_sa1
@ -265,8 +265,8 @@ fp_unpackA_sa1:
; mantissa bytes with hidden 1 inserted ; mantissa bytes with hidden 1 inserted
ld a,b ld a,b
and 07Fh and 0x7F
or 080h or 0x80
ld (A_m2),a ld (A_m2),a
inc hl inc hl
ld a,(hl) ld a,(hl)
@ -293,7 +293,7 @@ fp_unpackB:
inc de inc de
ld a,(de) ld a,(de)
ld b,a ld b,a
and 080h and 0x80
jp z,fp_unpackB_sb0 jp z,fp_unpackB_sb0
ld a,1 ld a,1
jr fp_unpackB_sb1 jr fp_unpackB_sb1
@ -303,8 +303,8 @@ fp_unpackB_sb1:
ld (B_sign),a ld (B_sign),a
ld a,b ld a,b
and 07Fh and 0x7F
or 080h or 0x80
ld (B_m2),a ld (B_m2),a
inc de inc de
ld a,(de) ld a,(de)
@ -344,7 +344,7 @@ fp_packA_packNZ:
; remove hidden 1 ; remove hidden 1
ld a,(A_m2) ld a,(A_m2)
and 07Fh and 0x7F
ld b,a ld b,a
; apply sign bit7 ; apply sign bit7
@ -352,7 +352,7 @@ fp_packA_packNZ:
or a or a
jp z,fp_packA_sign0 jp z,fp_packA_sign0
ld a,b ld a,b
or 080h or 0x80
jr fp_packA_storeB1 jr fp_packA_storeB1
fp_packA_sign0: fp_packA_sign0:
ld a,b ld a,b
@ -373,13 +373,13 @@ fp_pack_from_B_into_A:
ld (hl),a ld (hl),a
inc hl inc hl
ld a,(B_m2) ld a,(B_m2)
and 07Fh and 0x7F
ld b,a ld b,a
ld a,(B_sign) ld a,(B_sign)
or a or a
jp z,fp_pack_from_B_bs0 jp z,fp_pack_from_B_bs0
ld a,b ld a,b
or 080h or 0x80
jr fp_pack_from_B_bs1 jr fp_pack_from_B_bs1
fp_pack_from_B_bs0: fp_pack_from_B_bs0:
ld a,b ld a,b
@ -890,7 +890,7 @@ div_mantissas_loop:
jr c,div_mantissas_restore jr c,div_mantissas_restore
; success => set quotient LSB = 1 ; success => set quotient LSB = 1
ld a,(A_m0) ld a,(A_m0)
or 001h or 0x1
ld (A_m0),a ld (A_m0),a
jr div_mantissas_next jr div_mantissas_next
div_mantissas_restore: div_mantissas_restore:
@ -977,7 +977,7 @@ add24_Phigh_plus_B:
; ============================================================ ; ============================================================
; fp_print: fixed format printing ; fp_print: fixed format printing
; Prints: [-]I.FFFFFF (FRAC_DIGITS digits) ; Prints: [-]I.FFFFFF (FRAC_DIGITS digits)
; Uses printChar (A=char) ; Uses os_print_vec (A=char)
; ============================================================ ; ============================================================
fp_print: fp_print:
; zero? ; zero?
@ -985,13 +985,13 @@ fp_print:
or a or a
jr nz,fp_print_nz jr nz,fp_print_nz
ld a,'0' ld a,'0'
call printChar call os_print_vec
ld a,'.' ld a,'.'
call printChar call os_print_vec
ld b,FRAC_DIGITS ld b,FRAC_DIGITS
fp_print_zf: fp_print_zf:
ld a,'0' ld a,'0'
call printChar call os_print_vec
djnz fp_print_zf djnz fp_print_zf
ret ret
@ -1005,7 +1005,7 @@ fp_print_nz:
; sign + top fraction ; sign + top fraction
ld a,(hl) ld a,(hl)
ld b,a ld b,a
and 080h and 0x80
jp z,fp_print_ps0 jp z,fp_print_ps0
ld a,1 ld a,1
jr fp_print_ps1 jr fp_print_ps1
@ -1016,8 +1016,8 @@ fp_print_ps1:
; mantissa with hidden 1 inserted ; mantissa with hidden 1 inserted
ld a,b ld a,b
and 07Fh and 0x7F
or 080h or 0x80
ld (PR_M2),a ld (PR_M2),a
inc hl inc hl
ld a,(hl) ld a,(hl)
@ -1031,7 +1031,7 @@ fp_print_ps1:
or a or a
jp z,fp_print_mag jp z,fp_print_mag
ld a,'-' ld a,'-'
call printChar call os_print_vec
fp_print_mag: fp_print_mag:
; S = (E - 23) ; S = (E - 23)
ld a,(PR_E) ld a,(PR_E)
@ -1084,13 +1084,13 @@ fp_print_doShl:
fp_print_print_int_and_frac: fp_print_print_int_and_frac:
call print_u32_dec call print_u32_dec
ld a,'.' ld a,'.'
call printChar call os_print_vec
ld b,FRAC_DIGITS ld b,FRAC_DIGITS
fp_print_fr: fp_print_fr:
call mul_remainder_by_10 call mul_remainder_by_10
ld a,(PR_R3) ld a,(PR_R3)
add a,'0' add a,'0'
call printChar call os_print_vec
xor a xor a
ld (PR_R3),a ld (PR_R3),a
djnz fp_print_fr djnz fp_print_fr
@ -1173,7 +1173,7 @@ print_u32_dec:
or b or b
jr nz,print_u32_dec_nz jr nz,print_u32_dec_nz
ld a,'0' ld a,'0'
call printChar call os_print_vec
ret ret
print_u32_dec_nz: print_u32_dec_nz:
xor a xor a
@ -1212,7 +1212,7 @@ print_u32_dec_pr:
ld b,0 ld b,0
add hl,bc add hl,bc
ld a,(hl) ld a,(hl)
call printChar call os_print_vec
ld a,c ld a,c
or a or a
jr nz,print_u32_dec_pr jr nz,print_u32_dec_pr
@ -1353,7 +1353,7 @@ fp_parse_apply_sign:
ret z ret z
inc hl inc hl
ld a,(hl) ld a,(hl)
xor 080h xor 0x80
ld (hl),a ld (hl),a
ret ret
@ -1536,7 +1536,7 @@ fp_from_u32_scaled_to_A_found:
; store sign=0, fraction = top 23 bits of mantissa (hidden 1 removed) ; store sign=0, fraction = top 23 bits of mantissa (hidden 1 removed)
ld a,(PR_INT3) ld a,(PR_INT3)
and 07Fh and 0x7F
ld (hl),a ld (hl),a
inc hl inc hl
ld a,(PR_INT2) ld a,(PR_INT2)
@ -1615,7 +1615,7 @@ DIGLEN: .space 1
; 100000.0 = 143 43 50 00 ; 100000.0 = 143 43 50 00
; 1000000.0= 146 74 24 00 ; 1000000.0= 146 74 24 00
; ============================================================ ; ============================================================
.section float .section "float","acrx"
pow10_table: pow10_table:
.byte 127, 0x00, 0x00, 0x00 ; 10^0 = 1 .byte 127, 0x00, 0x00, 0x00 ; 10^0 = 1
.byte 130, 0x20, 0x00, 0x00 ; 10^1 = 10 .byte 130, 0x20, 0x00, 0x00 ; 10^1 = 10

View file

@ -1,9 +1,9 @@
# SPDX-License-Identifier: MPL-2.0 /* SPDX-License-Identifier: MPL-2.0 */
/* SPDX-FileCopyrightText: (c) 2025 A.M. Rowsell */
SECTIONS SECTIONS
{ {
.zone 0xA000 : { *(.zone) *(zone) } .zone 0xA000 : { *(.zone) *(zone) }
.text 0xE000 : { *(.text) } .text 0xE000 : { *(.text) *(.float) *(float) }
.float 0xE000 : { *(.float) *(float) }
.vectors 0xF000 : { *(.vectors) } .vectors 0xF000 : { *(.vectors) }
.data 0x7000 : { *(.data) } .data 0x7000 : { *(.data) }
.bss : { *(.bss) } .bss : { *(.bss) }

View file

@ -1,6 +0,0 @@
; SPDX-License-Identifier: MPL-2.0
; SPDX-FileCopyrightText: (c) 2025 A.M. Rowsell
; Stub printChar: does nothing
.global printChar
printChar:
ret

View file

@ -6,7 +6,7 @@
.equ OS_VEC_BASE,0xF000 .equ OS_VEC_BASE,0xF000
; .vectors is pinned to 0xF000 via linker.cmd ; .vectors is pinned to 0xF000 via linker.cmd
.section .vectors .section ".vectors","adr"
.global os_vectors .global os_vectors
os_vectors: os_vectors:

View file

@ -3,7 +3,7 @@
; ============================================================ ; ============================================================
; ZONE OS main section ; ZONE OS main section
; ============================================================ ; ============================================================
.section zone .section "zone","acrx"
.global zone_start .global zone_start
.global os_print_vec .global os_print_vec
.global os_getch_vec .global os_getch_vec