Skip to content

Commit

Permalink
another code cleanup for upcoming release
Browse files Browse the repository at this point in the history
- removed some commented out code
- System Monitor: unification of address storage between commands
- moved gensine to tools bank
- minimal size optimation in kernel/monitor code

Signed-off-by: Sven Oliver Moll <svolli@svolli.de>
  • Loading branch information
Sven Oliver Moll committed Nov 27, 2024
1 parent 11f2fab commit 32f3859
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 158 deletions.
2 changes: 1 addition & 1 deletion src/65c02/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ add_executable(native_kernel
native_rom/woz.s
native_rom/vt100.s
native_rom/lineinput.s
native_rom/functions.s
native_rom/bios.s

mon/main.s
Expand Down Expand Up @@ -146,6 +145,7 @@ target_type(native_basic native_kernel)

add_executable(native_tools
native_rom/browser.s
native_rom/gensine.s
native_rom/bios.s
native_rom/bios_stub.s
)
Expand Down
11 changes: 1 addition & 10 deletions src/65c02/mon/assembler.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
.import newedit

.import prtxsp
.import prthex8s
.import prthex8
.import decodeopcode
.import prterr
.import skipspace
Expand Down Expand Up @@ -71,13 +69,7 @@ getaddr1:
lda INBUF,x
beq @fail
jsr getaddr
; this whole checking will be obsoleted by checking #nibbles
; bcc @ok
; cmp #')' ; could be (zp),y
; beq @check
; cmp #','+1 ; could be zp,x
; bne @fail
;@check:
; do some very different error checking here
lda TMP8
cmp #$04 ; check if any digit was processed
bcs @fail
Expand All @@ -100,7 +92,6 @@ skipspace1:
assemble:
jsr getaddr ; get addr to assemble to
bcc :+
;sta $DF01
rts ; on error just leave for now
:
sta ADDR1+0 ; getaddr will be used again, save to other
Expand Down
32 changes: 14 additions & 18 deletions src/65c02/mon/disassembler.s
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

.include "../native_bios.inc"
.include "../native.inc"
.include "../native_kernel.inc"

.export disassemble
.export decodeopcode
.export prtinst

.import getaddr
.import prthex8s
.import prthex8
.import prt3sp
.import prtxsp

Expand All @@ -30,19 +29,16 @@
;******************************************************************************
;* *
;* Apple //c *
;* Video Firmware and *
;* Monitor ROM Source *
;* *
;* COPYRIGHT 1977-1983 BY *
;* APPLE COMPUTER, INC. *
;* Copyright 1977-1983 by Apple Computer, Inc. *
;* All Rights Reserved *
;* *
;* ALL RIGHTS RESERVED *
;* *
;* S. WOZNIAK 1977 *
;* A. BAUM 1977 *
;* JOHN A NOV 1978 *
;* R. AURICCHIO SEP 1982 *
;* E. BEERNINK 1983 *
;* S. Wozniak 1977 *
;* A. Baum 1977 *
;* John A NOV 1978 *
;* R. Auricchio SEP 1982 *
;* E. Beernink 1983 *
;* *
;******************************************************************************
;* however those routines were heavily modified to fit the Sorbus Computer *
Expand Down Expand Up @@ -173,9 +169,9 @@ prtinst:
.byte 10," > ",0
; print address
lda ADDR1+1
jsr prthex8
jsr prhex8
lda ADDR1+0
jsr prthex8
jsr prhex8

jsr prt3sp ;followed by 3 spaces (will set X=$00)

Expand All @@ -185,7 +181,7 @@ prtinst:
pha ;SAVE MNEMONIC TABLE INDEX
@top:
lda (ADDR1),y
jsr prthex8
jsr prhex8
ldx #$01 ;print a single space
@skipoutput:
jsr prtxsp
Expand Down Expand Up @@ -241,7 +237,7 @@ prtinst:
@pradr4:
dey
bmi @pradr2
jsr prthex8 ; was prthex8s
jsr prhex8
@pradr5:
lda FORMAT
cmp #$E8 ;HANDLE REL ADR MODE
Expand All @@ -254,9 +250,9 @@ prtinst:
iny
:
tya
jsr prthex8
jsr prhex8
txa ; OF BRANCH AND RETURN
jmp prthex8
jmp prhex8

@pcadj3:
ldy ADDR1+1
Expand Down
54 changes: 13 additions & 41 deletions src/65c02/mon/hexdump.s
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

.include "../native_bios.inc"
.include "../native.inc"
.include "../native_kernel.inc"

.export hexenter
.export hexupdown
.export memorydump
.export prthex4
.export prthex8
.export prthex8s
.export inbufhex4
.export inbufhex8
.export inbufaddr1
Expand All @@ -32,7 +30,7 @@

memorydump:
jsr getaddr
bcs @next
bcs memorydumpline
lda ADDR0+0
sta ADDR1+0
lda ADDR0+1
Expand Down Expand Up @@ -70,26 +68,16 @@ memorydump:
@done:
rts

@next:
lda ADDR1+0
clc
adc #$10
sta ADDR1+0
bcc :+
inc ADDR1+1
:
;slip through

memorydumpline:
jsr PRINT
.byte 10," :",0

lda ADDR1+1
sta ADDR2+1
jsr prthex8
jsr prhex8
lda ADDR1+0
sta ADDR2+0
jsr prthex8
jsr prhex8
jsr prtsp

ldy #$00
Expand All @@ -101,7 +89,7 @@ memorydumpline:
jsr prtsp

lda (ADDR1),y
jsr prthex8
jsr prhex8

iny
cpy #$10
Expand All @@ -124,33 +112,17 @@ memorydumpline:
iny
cpy #$10
bcc @asciiloop
lda #':'
sta MODE
rts

prthex8s:
pha
jsr prthex8
pla
rts

prthex8:
pha
lsr
lsr
lsr
lsr
jsr prthex4
pla
prthex4:
and #$0f
ora #'0'
cmp #':'
lda ADDR1+0
clc
adc #$10
sta ADDR1+0
bcc :+
adc #$06
inc ADDR1+1
:
jmp CHROUT

lda #':'
sta MODE
rts

updownaddr:
lda INBUF
Expand Down
15 changes: 4 additions & 11 deletions src/65c02/mon/interndrive.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
.include "../native.inc"

.export blockrw
.export iofailed

.import getaddr
.import skipspace
.import prterr
.import prthex8
.import newenter
.import uppercase
.ifp02
.else
.import iofailed
.endif

.importzp FORMAT

Expand Down Expand Up @@ -57,17 +53,14 @@ blockrw:
bne :+
jsr PRINT
.byte "read",0
beq :++
beq iofailed
:
jsr PRINT
.byte "write",0
:
.ifp02

iofailed:
pla
pla
jsr PRINT
.byte " failed",0
jmp newenter ; return to newenter instead of loop
.else
jmp iofailed
.endif
2 changes: 1 addition & 1 deletion src/65c02/mon/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
; [X] BRK handler
; [X] native ROM integration
; [X] NMOS 6502 toolkit integration
; [ ] consistent current address pointer for 'm', 'd', set upon init to PC
; [ ] merge code?
; --- release build
; [ ] memory read/write respects bank register
Expand Down Expand Up @@ -127,7 +128,6 @@ INBUF_SIZE := $4e ; 78 characters to fit 80 char screen width
.import hexenter
.import hexupdown
.import memorydump
.import prthex8

; from interndrive.s
.import blockrw
Expand Down
15 changes: 10 additions & 5 deletions src/65c02/mon/registers.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
.export regupdown

.import prterr
.import prthex8
.import prtsp
.import inbufhex8
.import inbufsp
Expand All @@ -22,6 +21,7 @@
.import skipspace

.importzp MODE
.importzp ADDR1
.import INBUF

; don't change order in memory
Expand Down Expand Up @@ -130,6 +130,9 @@ mon_init:
sta R_PC,x
dex
bpl :-
sta ADDR1+0
lda R_PC+1
sta ADDR1+1

mon_hello:
sei ; sanitize
Expand All @@ -155,7 +158,7 @@ mon_hello:
pla
ply
bne :+
jsr prthex8
jsr prhex8
:
.endif
jsr regdump
Expand Down Expand Up @@ -185,15 +188,15 @@ regdump:
.endif
.byte 10," ~",0
lda R_PC+1
jsr prthex8
jsr prhex8
lda R_PC+0
jsr prthex8
jsr prhex8

ldx #REGSTART
:
jsr prtsp
lda R_BK,x
jsr prthex8
jsr prhex8
inx
cpx #NUMREGS
bcc :-
Expand Down Expand Up @@ -270,6 +273,8 @@ regedit:

ldy #REGSTART
@regloop:
lda INBUF,x
beq @done
jsr getbyte ; get A,X,Y,SP
bcs @error
sta R_BK,y
Expand Down
Loading

0 comments on commit 32f3859

Please sign in to comment.