Skip to content

Commit

Permalink
Merge pull request #482 from kiwisincebirth/map/cbios-size
Browse files Browse the repository at this point in the history
CBIOS Size reduce by reducing resident utils
  • Loading branch information
wwarthen authored Dec 21, 2024
2 parents 6647b09 + 4df6f00 commit f8f46c6
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 127 deletions.
72 changes: 62 additions & 10 deletions Source/CBIOS/cbios.asm
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ REBOOT:
;
#IFDEF PLTWBW
; WARM START
LD B,BF_SYSRESET ; SYSTEM RESTART
LD C,BF_SYSRES_WARM ; WARM START
LD BC,BC_SYSRES_WARM ; SYSTEM WARM RESTART
CALL $FFF0 ; CALL HBIOS
#ENDIF
;
Expand Down Expand Up @@ -2199,8 +2198,7 @@ INIT:

#ELSE
; GET CRITICAL BANK ID'S
LD B,BF_SYSGET ; HBIOS FUNC=GET SYS INFO
LD C,BF_SYSGET_BNKINFO ; HBIOS SUBFUNC=GET BANK ASSIGNMENTS
LD BC,BC_SYSGET_BNKINFO ; HBIOS FUNC=GET SYS INFO;GET BANK ASSIGNMENTS
RST 08 ; CALL HBIOS
LD A,D ; GET HBIOS BANK RETURNED IN D
LD (BNKBIOS),A ; ... AND SAVE IT
Expand All @@ -2213,8 +2211,7 @@ INIT:
#ENDIF
;
; SOFT RESET HBIOS
LD B,BF_SYSRESET ; HB FUNC: RESET
LD C,BF_SYSRES_INT ; WARM START
LD BC,BC_SYSRES_INT ; HB FUNC: RESET; WARM START
RST 08 ; DO IT
;
#IF DEBUG
Expand Down Expand Up @@ -2494,8 +2491,7 @@ DEV_INIT000:
DEV_INIT00:
; LOOP THRU DEVICES ADDING DEVICES TO DEVMAP
; CONSOLE DEVICE WAS ALREADY DONE, SO IT IS SKIPPED HERE
LD B,BF_SYSGET ; HBIOS FUNC: GET SYS INFO
LD C,BF_SYSGET_CIOCNT ; SUBFUNC: GET CIO UNIT COUNT
LD BC,BC_SYSGET_CIOCNT ; HBIOS FUNC: GET SYS INFO; GET CIO UNIT COUNT
RST 08 ; E := SERIAL UNIT COUNT
LD B,E ; COUNT TO B
LD C,0 ; UNIT INDEX
Expand Down Expand Up @@ -2926,8 +2922,7 @@ DRV_INIT:
; DEVICES. NON-HARD DISK UNITS ARE ALWAYS CONSIDERED
; ACTIVE, BUT HARD DISK UNITS ARE ONLY CONSIDERED ACTIVE
; IF THERE IS MEDIA IN THE DRIVE.
LD B,BF_SYSGET
LD C,BF_SYSGET_DIOCNT
LD BC,BC_SYSGET_DIOCNT ; GET DISK UNIT COUNT
RST 08 ; E := DISK UNIT COUNT
LD B,E ; COUNT TO B
LD A,B ; COUNT TO A
Expand Down Expand Up @@ -3433,6 +3428,63 @@ DEV15 .EQU DEVUNK
;
#ENDIF
;
;
;__________________________________________________________________________________________________
;
; INITIALIZATION Utilities
;
; PRINT VALUE OF A IN DECIMAL WITH LEADING ZERO SUPPRESSION
;
PRTDECB:
PUSH HL
PUSH AF
LD L,A
LD H,0
CALL PRTDEC
POP AF
POP HL
RET
;
; PRINT VALUE OF HL IN DECIMAL WITH LEADING ZERO SUPPRESSION
;
PRTDEC:
PUSH BC
PUSH DE
PUSH HL
LD E,'0'
LD BC,-10000
CALL PRTDEC1
LD BC,-1000
CALL PRTDEC1
LD BC,-100
CALL PRTDEC1
LD C,-10
CALL PRTDEC1
LD E,0
LD C,-1
CALL PRTDEC1
POP HL
POP DE
POP BC
RET
PRTDEC1:
LD A,'0' - 1
PRTDEC2:
INC A
ADD HL,BC
JR C,PRTDEC2
SBC HL,BC
CP E
JR Z,PRTDEC3
LD E,0
CALL COUT
PRTDEC3:
RET
;
;__________________________________________________________________________________________________
;
; INITIALIZATION Working Storage
;
DPHTOP .DW 0 ; CURRENT TOP OF DPH POOL
DIRBUF .DW 0 ; DIR BUF POINTER
HEAPTOP .DW BUFPOOL ; CURRENT TOP OF HEAP
Expand Down
186 changes: 69 additions & 117 deletions Source/CBIOS/util.asm
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ PC_COLON:
LD A,':'
JR PC_PRTCHR

PC_COMMA:
PUSH AF
LD A,','
JR PC_PRTCHR
;PC_COMMA:
; PUSH AF
; LD A,','
; JR PC_PRTCHR

PC_LBKT:
PUSH AF
Expand All @@ -43,30 +43,30 @@ PC_RBKT:
LD A,']'
JR PC_PRTCHR

PC_LT:
PUSH AF
LD A,'<'
JR PC_PRTCHR
;PC_LT:
; PUSH AF
; LD A,'<'
; JR PC_PRTCHR

PC_GT:
PUSH AF
LD A,'>'
JR PC_PRTCHR
;PC_GT:
; PUSH AF
; LD A,'>'
; JR PC_PRTCHR

PC_LPAREN:
PUSH AF
LD A,'('
JR PC_PRTCHR
;PC_LPAREN:
; PUSH AF
; LD A,'('
; JR PC_PRTCHR

PC_RPAREN:
PUSH AF
LD A,')'
JR PC_PRTCHR
;PC_RPAREN:
; PUSH AF
; LD A,')'
; JR PC_PRTCHR

PC_ASTERISK:
PUSH AF
LD A,'*'
JR PC_PRTCHR
;PC_ASTERISK:
; PUSH AF
; LD A,'*'
; JR PC_PRTCHR

PC_CR:
PUSH AF
Expand Down Expand Up @@ -201,7 +201,7 @@ _REGDMP:
LD A,'@'
CALL COUT
POP AF

PUSH BC
LD BC,(REGDMP_PC)
CALL PRTHEXWORD ; PC
Expand Down Expand Up @@ -235,7 +235,7 @@ _REGDMP:
POP AF

;LD SP,(RD_STKSAV) ; BACK TO ORIGINAL STACK FRAME

JP $FFFF ; RETURN, $FFFF IS DYNAMICALLY UPDATED
REGDMP_RET .EQU $-2 ; RETURN ADDRESS GOES HERE
;
Expand Down Expand Up @@ -340,17 +340,17 @@ ADDHLA1:
; IN: MULTIPLY H BY E
; OUT: HL = RESULT, E = 0, B = 0
;
MULT8:
LD D,0
LD L,D
LD B,8
MULT8_LOOP:
ADD HL,HL
JR NC,MULT8_NOADD
ADD HL,DE
MULT8_NOADD:
DJNZ MULT8_LOOP
RET
;MULT8:
; LD D,0
; LD L,D
; LD B,8
;MULT8_LOOP:
; ADD HL,HL
; JR NC,MULT8_NOADD
; ADD HL,DE
;MULT8_NOADD:
; DJNZ MULT8_LOOP
; RET
;
; FILL MEMORY AT HL WITH VALUE A, LENGTH IN BC, ALL REGS USED
; LENGTH *MUST* BE GREATER THAN 1 FOR PROPER OPERATION!!!
Expand All @@ -364,54 +364,6 @@ FILL:
LDIR ; DO THE REST
RET ; RETURN
;
; PRINT VALUE OF A IN DECIMAL WITH LEADING ZERO SUPPRESSION
;
PRTDECB:
PUSH HL
PUSH AF
LD L,A
LD H,0
CALL PRTDEC
POP AF
POP HL
RET
;
; PRINT VALUE OF HL IN DECIMAL WITH LEADING ZERO SUPPRESSION
;
PRTDEC:
PUSH BC
PUSH DE
PUSH HL
LD E,'0'
LD BC,-10000
CALL PRTDEC1
LD BC,-1000
CALL PRTDEC1
LD BC,-100
CALL PRTDEC1
LD C,-10
CALL PRTDEC1
LD E,0
LD C,-1
CALL PRTDEC1
POP HL
POP DE
POP BC
RET
PRTDEC1:
LD A,'0' - 1
PRTDEC2:
INC A
ADD HL,BC
JR C,PRTDEC2
SBC HL,BC
CP E
JR Z,PRTDEC3
LD E,0
CALL COUT
PRTDEC3:
RET
;
; PRINT THE HEX BYTE VALUE IN A
;
PRTHEXBYTE:
Expand Down Expand Up @@ -457,9 +409,9 @@ HEXASCII:
HEXCONV:
AND 0FH ;LOW NIBBLE ONLY
ADD A,90H
DAA
DAA
ADC A,40H
DAA
DAA
RET
;
;****************************
Expand Down Expand Up @@ -488,40 +440,40 @@ BCD2BYTE:
; [0..99] => [00H..99H]
;*****************************
;
BYTE2BCD:
PUSH BC
LD B,10
LD C,-1
BYTE2BCD1:
INC C
SUB B
JR NC,BYTE2BCD1
ADD A,B
LD B,A
LD A,C
ADD A,A
ADD A,A
ADD A,A
ADD A,A
OR B
POP BC
RET
;BYTE2BCD:
; PUSH BC
; LD B,10
; LD C,-1
;BYTE2BCD1:
; INC C
; SUB B
; JR NC,BYTE2BCD1
; ADD A,B
; LD B,A
; LD A,C
; ADD A,A
; ADD A,A
; ADD A,A
; ADD A,A
; OR B
; POP BC
; RET
;
; PRINT A BYTE BUFFER IN HEX POINTED TO BY DE
; REGISTER A HAS SIZE OF BUFFER
;
PRTHEXBUF:
OR A
RET Z ; EMPTY BUFFER
;
LD B,A
PRTHEXBUF1:
CALL PC_SPACE
LD A,(DE)
CALL PRTHEXBYTE
INC DE
DJNZ PRTHEXBUF1
RET
;PRTHEXBUF:
; OR A
; RET Z ; EMPTY BUFFER
;
; LD B,A
;PRTHEXBUF1:
; CALL PC_SPACE
; LD A,(DE)
; CALL PRTHEXBYTE
; INC DE
; DJNZ PRTHEXBUF1
; RET
;
; LEFT SHIFT DE:HL BY B BITS (B > 0)
;
Expand Down
5 changes: 5 additions & 0 deletions Source/HBIOS/hbios.inc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ BF_SYSINT_SET .EQU $20 ; SET INT VECTOR ADDRESS
; 2 BYTE FUNCTION/SUBFUNCTION : BC_ => BIOS CALL
; e.g. LOAD BC, BC_SYSxxxx (avoid load B and C seperately)
;
BC_SYSRES_INT .EQU BF_SYSRESET * $100 + BF_SYSRES_INT
BC_SYSRES_WARM .EQU BF_SYSRESET * $100 + BF_SYSRES_WARM
BC_SYSRES_COLD .EQU BF_SYSRESET * $100 + BF_SYSRES_COLD
BC_SYSRES_USER .EQU BF_SYSRESET * $100 + BF_SYSRES_USER
;
BC_SYSGET_CIOCNT .EQU BF_SYSGET * $100 + BF_SYSGET_CIOCNT
BC_SYSGET_CIOFN .EQU BF_SYSGET * $100 + BF_SYSGET_CIOFN
BC_SYSGET_DIOCNT .EQU BF_SYSGET * $100 + BF_SYSGET_DIOCNT
Expand Down

0 comments on commit f8f46c6

Please sign in to comment.