From cb332b7b0549dd5235cca30bdb5e928927c6e901 Mon Sep 17 00:00:00 2001 From: "A.M. Rowsell" Date: Sat, 20 Dec 2025 18:36:58 -0500 Subject: [PATCH] dev: removing old printChar and instead using OS print vector --- Makefile | 12 ++++----- float.asm | 66 ++++++++++++++++++++++++------------------------- linker.cmd | 6 ++--- printChar.asm | 6 ----- vectorTable.asm | 2 +- zone.asm | 2 +- 6 files changed, 43 insertions(+), 51 deletions(-) delete mode 100644 printChar.asm diff --git a/Makefile b/Makefile index eae7846..fa84310 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,26 @@ # SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: (c) 2025 A.M. Rowsell ASM=vasm_z80_std LINK=vlink ASMFLAGS=-Fvobj LINKFLAGS=-b ihex -T linker.cmd -all: float.hex +all: zone.hex float.o: float.asm $(ASM) $(ASMFLAGS) -o $@ $< -printChar.o: printChar.asm - $(ASM) $(ASMFLAGS) -o $@ $< - vectorTable.o: vectorTable.asm $(ASM) $(ASMFLAGS) -o $@ $< zone.o: zone.asm $(ASM) $(ASMFLAGS) -o $@ $< -float.hex: float.o printChar.o vectorTable.o zone.o linker.cmd - $(LINK) $(LINKFLAGS) -o $@ float.o printChar.o vectorTable.o zone.o +zone.hex: float.o vectorTable.o zone.o linker.cmd + $(LINK) $(LINKFLAGS) -o $@ float.o vectorTable.o zone.o 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 diff --git a/float.asm b/float.asm index 9294782..2ef9b37 100644 --- a/float.asm +++ b/float.asm @@ -22,7 +22,7 @@ ; fp_div: A = A / B ; ; 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) ; ; Limitations: @@ -36,16 +36,16 @@ .equ FRAC_DIGITS,6 .equ MAX_FRAC,6 -.extern printChar +.extern os_print_vec ; ============================================================ ; CODE ; ============================================================ -.section float +.section "float","acrx" ; ------------------------------------------------------------ ; 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 @@ -94,7 +94,7 @@ fp_sub: push de inc de ld a,(de) - xor 080h + xor 0x80 ld (de),a pop de pop hl @@ -106,7 +106,7 @@ fp_sub: push de inc de ld a,(de) - xor 080h + xor 0x80 ld (de),a pop de pop hl @@ -254,7 +254,7 @@ fp_unpackA: ld a,(hl) ld b,a ; sign bit -> A_sign (0/1) - and 080h + and 0x80 jp z,fp_unpackA_sa0 ld a,1 jr fp_unpackA_sa1 @@ -265,8 +265,8 @@ fp_unpackA_sa1: ; mantissa bytes with hidden 1 inserted ld a,b - and 07Fh - or 080h + and 0x7F + or 0x80 ld (A_m2),a inc hl ld a,(hl) @@ -293,7 +293,7 @@ fp_unpackB: inc de ld a,(de) ld b,a - and 080h + and 0x80 jp z,fp_unpackB_sb0 ld a,1 jr fp_unpackB_sb1 @@ -303,8 +303,8 @@ fp_unpackB_sb1: ld (B_sign),a ld a,b - and 07Fh - or 080h + and 0x7F + or 0x80 ld (B_m2),a inc de ld a,(de) @@ -344,7 +344,7 @@ fp_packA_packNZ: ; remove hidden 1 ld a,(A_m2) - and 07Fh + and 0x7F ld b,a ; apply sign bit7 @@ -352,7 +352,7 @@ fp_packA_packNZ: or a jp z,fp_packA_sign0 ld a,b - or 080h + or 0x80 jr fp_packA_storeB1 fp_packA_sign0: ld a,b @@ -373,13 +373,13 @@ fp_pack_from_B_into_A: ld (hl),a inc hl ld a,(B_m2) - and 07Fh + and 0x7F ld b,a ld a,(B_sign) or a jp z,fp_pack_from_B_bs0 ld a,b - or 080h + or 0x80 jr fp_pack_from_B_bs1 fp_pack_from_B_bs0: ld a,b @@ -890,7 +890,7 @@ div_mantissas_loop: jr c,div_mantissas_restore ; success => set quotient LSB = 1 ld a,(A_m0) - or 001h + or 0x1 ld (A_m0),a jr div_mantissas_next div_mantissas_restore: @@ -977,7 +977,7 @@ add24_Phigh_plus_B: ; ============================================================ ; fp_print: fixed format printing ; Prints: [-]I.FFFFFF (FRAC_DIGITS digits) -; Uses printChar (A=char) +; Uses os_print_vec (A=char) ; ============================================================ fp_print: ; zero? @@ -985,13 +985,13 @@ fp_print: or a jr nz,fp_print_nz ld a,'0' - call printChar + call os_print_vec ld a,'.' - call printChar + call os_print_vec ld b,FRAC_DIGITS fp_print_zf: ld a,'0' - call printChar + call os_print_vec djnz fp_print_zf ret @@ -1005,7 +1005,7 @@ fp_print_nz: ; sign + top fraction ld a,(hl) ld b,a - and 080h + and 0x80 jp z,fp_print_ps0 ld a,1 jr fp_print_ps1 @@ -1016,8 +1016,8 @@ fp_print_ps1: ; mantissa with hidden 1 inserted ld a,b - and 07Fh - or 080h + and 0x7F + or 0x80 ld (PR_M2),a inc hl ld a,(hl) @@ -1031,7 +1031,7 @@ fp_print_ps1: or a jp z,fp_print_mag ld a,'-' - call printChar + call os_print_vec fp_print_mag: ; S = (E - 23) ld a,(PR_E) @@ -1084,13 +1084,13 @@ fp_print_doShl: fp_print_print_int_and_frac: call print_u32_dec ld a,'.' - call printChar + call os_print_vec ld b,FRAC_DIGITS fp_print_fr: call mul_remainder_by_10 ld a,(PR_R3) add a,'0' - call printChar + call os_print_vec xor a ld (PR_R3),a djnz fp_print_fr @@ -1173,7 +1173,7 @@ print_u32_dec: or b jr nz,print_u32_dec_nz ld a,'0' - call printChar + call os_print_vec ret print_u32_dec_nz: xor a @@ -1212,7 +1212,7 @@ print_u32_dec_pr: ld b,0 add hl,bc ld a,(hl) - call printChar + call os_print_vec ld a,c or a jr nz,print_u32_dec_pr @@ -1353,7 +1353,7 @@ fp_parse_apply_sign: ret z inc hl ld a,(hl) - xor 080h + xor 0x80 ld (hl),a ret @@ -1536,7 +1536,7 @@ fp_from_u32_scaled_to_A_found: ; store sign=0, fraction = top 23 bits of mantissa (hidden 1 removed) ld a,(PR_INT3) - and 07Fh + and 0x7F ld (hl),a inc hl ld a,(PR_INT2) @@ -1615,7 +1615,7 @@ DIGLEN: .space 1 ; 100000.0 = 143 43 50 00 ; 1000000.0= 146 74 24 00 ; ============================================================ -.section float +.section "float","acrx" pow10_table: .byte 127, 0x00, 0x00, 0x00 ; 10^0 = 1 .byte 130, 0x20, 0x00, 0x00 ; 10^1 = 10 diff --git a/linker.cmd b/linker.cmd index 056d45f..5fa51f2 100644 --- a/linker.cmd +++ b/linker.cmd @@ -1,9 +1,9 @@ -# SPDX-License-Identifier: MPL-2.0 +/* SPDX-License-Identifier: MPL-2.0 */ +/* SPDX-FileCopyrightText: (c) 2025 A.M. Rowsell */ SECTIONS { .zone 0xA000 : { *(.zone) *(zone) } - .text 0xE000 : { *(.text) } - .float 0xE000 : { *(.float) *(float) } + .text 0xE000 : { *(.text) *(.float) *(float) } .vectors 0xF000 : { *(.vectors) } .data 0x7000 : { *(.data) } .bss : { *(.bss) } diff --git a/printChar.asm b/printChar.asm deleted file mode 100644 index 982eb7f..0000000 --- a/printChar.asm +++ /dev/null @@ -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 diff --git a/vectorTable.asm b/vectorTable.asm index b75446c..b4362ce 100644 --- a/vectorTable.asm +++ b/vectorTable.asm @@ -6,7 +6,7 @@ .equ OS_VEC_BASE,0xF000 ; .vectors is pinned to 0xF000 via linker.cmd -.section .vectors +.section ".vectors","adr" .global os_vectors os_vectors: diff --git a/zone.asm b/zone.asm index 0d504d4..6c1f782 100644 --- a/zone.asm +++ b/zone.asm @@ -3,7 +3,7 @@ ; ============================================================ ; ZONE OS main section ; ============================================================ -.section zone +.section "zone","acrx" .global zone_start .global os_print_vec .global os_getch_vec