mirror of
https://github.com/option8/sim8800.git
synced 2025-01-13 19:29:54 +00:00
Begin optimizing for 65C02, enhanced IIe
This commit is contained in:
parent
2485c65486
commit
8b6fd7f1d9
212
SIM8800.s
212
SIM8800.s
@ -7,12 +7,9 @@
|
|||||||
ORG $9000
|
ORG $9000
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
; TODO: real access display while in trace/step
|
; TODO:
|
||||||
; set displaybytes/+1 on memory access.
|
; optimize for speed, 65C02 - target is Enhanced IIe, 128K RAM
|
||||||
;
|
; port to 65816? 24bit addresses, 16 bit registers, 64k contiguous AUX, 2.8mhz
|
||||||
; port to 65816 - 24bit addresses, 16 bit registers, 64k contiguous AUX, 2.8mhz
|
|
||||||
;
|
|
||||||
;
|
|
||||||
;
|
;
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -53,7 +50,6 @@ KSWL EQU $38 ; keyboard input routine
|
|||||||
KSWH EQU $39 ; normally $FD1B
|
KSWH EQU $39 ; normally $FD1B
|
||||||
|
|
||||||
HIPCH EQU $FE ; is the PC above 32k limit?
|
HIPCH EQU $FE ; is the PC above 32k limit?
|
||||||
HIPCOFFSET EQU $FD ; 80 or 70. SPAGHETTI!
|
|
||||||
|
|
||||||
KBDBUF EQU $C000 ; KEYBOARD BUFFER
|
KBDBUF EQU $C000 ; KEYBOARD BUFFER
|
||||||
KBDSTROBE EQU $C010 ; KEYBOARD STROBE
|
KBDSTROBE EQU $C010 ; KEYBOARD STROBE
|
||||||
@ -193,10 +189,6 @@ SBC10 STA PCH ; store resulting PCH
|
|||||||
MAIN SEI ; DON'T ALLOW INTERRUPTS
|
MAIN SEI ; DON'T ALLOW INTERRUPTS
|
||||||
CLD ; CLEAR DECIMAL MODE
|
CLD ; CLEAR DECIMAL MODE
|
||||||
LDX #$00 ; LOAD INDEX
|
LDX #$00 ; LOAD INDEX
|
||||||
|
|
||||||
LDA #$80
|
|
||||||
STA HIPCOFFSET ; set offset
|
|
||||||
|
|
||||||
; **** add $10 to SIMH
|
; **** add $10 to SIMH
|
||||||
CLC
|
CLC
|
||||||
LDA SIMH
|
LDA SIMH
|
||||||
@ -206,7 +198,8 @@ MAIN SEI ; DON'T ALLOW INTERRUPTS
|
|||||||
CMP #$7F ; if it's >=32K boundary after add $10, get from AUX
|
CMP #$7F ; if it's >=32K boundary after add $10, get from AUX
|
||||||
BCC STASIMM2
|
BCC STASIMM2
|
||||||
STA RAMRDON ; set AUX READ
|
STA RAMRDON ; set AUX READ
|
||||||
SBC HIPCOFFSET ; subtract #$80
|
|
||||||
|
SBC #$80 ; subtract #$80
|
||||||
CLC ; read from AUX, still write to MAIN
|
CLC ; read from AUX, still write to MAIN
|
||||||
; add #$80
|
; add #$80
|
||||||
; set MAIN READ
|
; set MAIN READ
|
||||||
@ -230,7 +223,8 @@ DECSIMH SEC ; then subtract #$10... oof.
|
|||||||
STA RAMRDOFF ; high = turn it off, etc
|
STA RAMRDOFF ; high = turn it off, etc
|
||||||
CLC ; add #$80 to SIMH again
|
CLC ; add #$80 to SIMH again
|
||||||
LDA SIMH
|
LDA SIMH
|
||||||
ADC HIPCOFFSET
|
|
||||||
|
ADC #$80
|
||||||
STA SIMH
|
STA SIMH
|
||||||
|
|
||||||
CHECKPCH ; is PC looking above #$8FFF?
|
CHECKPCH ; is PC looking above #$8FFF?
|
||||||
@ -431,8 +425,7 @@ PUSHT TXA ; TEMP SAVE - x=0A on set return, gets PCL/H
|
|||||||
PLA ; RECOVER TEMP SAVE
|
PLA ; RECOVER TEMP SAVE
|
||||||
TAX ;
|
TAX ;
|
||||||
|
|
||||||
LDY #$80
|
|
||||||
STY HIPCOFFSET ; offset 80 for PUSH???
|
|
||||||
|
|
||||||
RPMEM LDY #$01 ; CLEAR INDEX
|
RPMEM LDY #$01 ; CLEAR INDEX
|
||||||
|
|
||||||
@ -442,8 +435,9 @@ RPMEM LDY #$01 ; CLEAR INDEX
|
|||||||
LDA DESTDA,Y ; $04 + $12 = $16 DESTDA
|
LDA DESTDA,Y ; $04 + $12 = $16 DESTDA
|
||||||
STA DISPLAYBYTES ; high byte to first bank of LEDs.
|
STA DISPLAYBYTES ; high byte to first bank of LEDs.
|
||||||
CMP #$7F ; over 9000?
|
CMP #$7F ; over 9000?
|
||||||
BCC RPMEM2 ; nope, skip math
|
BCC RPMEM2 ; nope, skip math
|
||||||
SBC HIPCOFFSET ; off by $10 ??? ***
|
|
||||||
|
SBC #$80 ; off by $10 ??? ***
|
||||||
STA RAMWRTON ; write to AUX
|
STA RAMWRTON ; write to AUX
|
||||||
STA DESTDA,Y
|
STA DESTDA,Y
|
||||||
|
|
||||||
@ -478,7 +472,8 @@ RPLP LDA SIMM,X ;GET NEXT RP DATA
|
|||||||
BCS STADESTDA2 ; Over 1000, skip
|
BCS STADESTDA2 ; Over 1000, skip
|
||||||
|
|
||||||
STADESTDA3 SEC
|
STADESTDA3 SEC
|
||||||
SBC HIPCOFFSET
|
|
||||||
|
SBC #$80
|
||||||
STA RAMWRTON
|
STA RAMWRTON
|
||||||
STA DESTDA+1
|
STA DESTDA+1
|
||||||
|
|
||||||
@ -489,7 +484,8 @@ STADESTDA2 PLA ; get RP data back
|
|||||||
BPL RPLP2
|
BPL RPLP2
|
||||||
CLC
|
CLC
|
||||||
LDA DESTDA+1
|
LDA DESTDA+1
|
||||||
ADC HIPCOFFSET
|
|
||||||
|
ADC #$80
|
||||||
STA DESTDA+1
|
STA DESTDA+1
|
||||||
STA RAMWRTOFF ; write to MAIN
|
STA RAMWRTOFF ; write to MAIN
|
||||||
|
|
||||||
@ -597,8 +593,7 @@ RETUN
|
|||||||
; **** doing a JUMP or CALL - reset HIPCH
|
; **** doing a JUMP or CALL - reset HIPCH
|
||||||
LDA #$00
|
LDA #$00
|
||||||
STA HIPCH
|
STA HIPCH
|
||||||
LDA #$80
|
|
||||||
STA HIPCOFFSET ; set offset
|
|
||||||
; **** doing a JUMP or CALL - reset HIPCH
|
; **** doing a JUMP or CALL - reset HIPCH
|
||||||
|
|
||||||
LDA SPH
|
LDA SPH
|
||||||
@ -609,7 +604,8 @@ RETUN
|
|||||||
CMP #$10
|
CMP #$10
|
||||||
BCS RETUN2
|
BCS RETUN2
|
||||||
SEC
|
SEC
|
||||||
RETUN1 SBC HIPCOFFSET ; *** SPH off by $10?
|
RETUN1
|
||||||
|
SBC #$80 ; *** SPH off by $10?
|
||||||
STA RAMRDON
|
STA RAMRDON
|
||||||
STA RAMWRTON
|
STA RAMWRTON
|
||||||
STA SPH
|
STA SPH
|
||||||
@ -628,12 +624,10 @@ RETUN2 CLC
|
|||||||
BPL RETUN3
|
BPL RETUN3
|
||||||
LDA SPH ; return SPH to high value
|
LDA SPH ; return SPH to high value
|
||||||
CLC
|
CLC
|
||||||
ADC HIPCOFFSET ; *** SPH off by $10?
|
ADC #$80 ; *** SPH off by $10?
|
||||||
STA SPH
|
STA SPH
|
||||||
STA RAMRDOFF
|
STA RAMRDOFF
|
||||||
STA RAMWRTOFF
|
STA RAMWRTOFF
|
||||||
LDA #$80
|
|
||||||
STA HIPCOFFSET ; set offset
|
|
||||||
|
|
||||||
RETUN3 LDX #$0A ; POP RETURN OFF
|
RETUN3 LDX #$0A ; POP RETURN OFF
|
||||||
BNE POPIT ; STACK INTO PC
|
BNE POPIT ; STACK INTO PC
|
||||||
@ -657,11 +651,6 @@ POP LSR A ; POP?
|
|||||||
POPIT TXA ; TEMP SAVE INDEX
|
POPIT TXA ; TEMP SAVE INDEX
|
||||||
PHA ;
|
PHA ;
|
||||||
|
|
||||||
;***
|
|
||||||
; POP and RETURN get stack offset 70.
|
|
||||||
LDA #$70
|
|
||||||
STA HIPCOFFSET ; set offset
|
|
||||||
;***
|
|
||||||
|
|
||||||
JSR SPPNT ; PULL OUT STACK DATA
|
JSR SPPNT ; PULL OUT STACK DATA
|
||||||
PLA ; BUMP SP
|
PLA ; BUMP SP
|
||||||
@ -1014,93 +1003,98 @@ STPSW STA PSW ; SAVE NEW PSW
|
|||||||
|
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
ROTATE LDY SIMA ;
|
ROTATE LDY SIMA ; GET ACCUMULATOR
|
||||||
LSR A ;
|
LSR A ; IS THIS CMC OR 8TC?
|
||||||
BNE ROCOMP ;
|
BNE ROCOMP ; NO, IT IS A ROTATE .OR CMA
|
||||||
LDA PSW ;
|
LDA PSW ; YES, CHANGE CARRY
|
||||||
EOR #$01 ;
|
EOR #$01 ; CMC
|
||||||
BCC STPS ;
|
BCC STPS ;
|
||||||
ORA #$01 ;
|
ORA #$01 ; STC
|
||||||
STPS BVS STPSW ;
|
STPS BVS STPSW ;
|
||||||
ROCOMP BCS LEFT ;
|
; ----------------------------------------------------------------------------
|
||||||
LSR A ;
|
|
||||||
BNE ROT ;
|
ROCOMP BCS LEFT ; LEFT OR RIGHT?
|
||||||
TYA ;
|
LSR A ; CMA?
|
||||||
EOR #$FF ;
|
BNE ROT ; NO, ROTATE
|
||||||
STA SIMA ;
|
TYA ; YES, COMMPLEMFNT A
|
||||||
|
EOR #$FF ;
|
||||||
|
STA SIMA ; DOESN* T SET STATUS
|
||||||
RTS ;
|
RTS ;
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
ROT TYA ;
|
ROT TYA ; GET ACCUMULATOR
|
||||||
BCS RRC ;
|
BCS RRC ;
|
||||||
LDA PSW ;
|
LDA PSW ; GET 8080 CARRY
|
||||||
RRC LSR A ;
|
RRC LSR A ;
|
||||||
TYA ;
|
TYA ; GET ACCUMULATOR
|
||||||
ROR A ;
|
ROR A ; ROTATE RIGHT
|
||||||
BVS JCRY ;
|
BVS JCRY ; GO STORE&SET CARRY
|
||||||
LEFT LSR A ;
|
; ----------------------------------------------------------------------------
|
||||||
BEQ DAA ;
|
LEFT LSR A ; DECIMAL ADJUST? IYES# GO 00 IT
|
||||||
TYA ;
|
BEQ DAA ; N 0 , GET ACCUMULATOR
|
||||||
BCS RLC ;
|
TYA ; JRLC?
|
||||||
LDA PSW ;
|
BCS RLC ; NO#GET 8080 CARRY
|
||||||
ROR A ;
|
LDA PSW ; MOVE IT INTO MSNIB
|
||||||
ROR A ;
|
ROR A ;
|
||||||
RLC ASL A ;
|
ROR A ;
|
||||||
TYA ;
|
RLC ASL A ; MOVE IT INTO CARRY
|
||||||
ROL A ;
|
TYA ; G E T ACCUMULATOR
|
||||||
JCRY STA SIMA ;
|
ROL A ; MOVE IT LEFT
|
||||||
JMP CARRY ;
|
JCRY STA SIMA ; SAVE IT
|
||||||
|
JMP CARRY ; GO SET STATUS
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
DAA CLC ;
|
DAA CLC ;
|
||||||
PHP ;
|
PHP ;PRE3ERVE STATUS |
|
||||||
TYA ;
|
TYA ;GET SOURCE DATA
|
||||||
STA ZERO ;
|
STA ZERO ; PREP FOR ADD
|
||||||
AND #$0F ;
|
AND #$0F ;LOOK AT LSNI8
|
||||||
ADC #$06 ;
|
ADC #$06 ;IF *0A WILL CAUSE AUX CRY
|
||||||
ORA PSW ;
|
ORA PSW ;OR I F AC I S ALREADY SET
|
||||||
AND #$10 ;
|
AND #$10 ; EITHER SET?
|
||||||
BEQ NOSIX ;
|
BEQ NOSIX ;NO, DON T ADJUST LSNIB
|
||||||
LDA #$06 ;
|
LDA #$06 ; YES# ADJUST IT
|
||||||
NOSIX TAY ;
|
NOSIX TAY ;
|
||||||
ADC ZERO ;
|
ADC ZERO ; G E T SOURCE
|
||||||
BCS SXTY ;
|
BCS SXTY ;
|
||||||
ADC #$60 ;
|
ADC #$60 ;113 MSNIB NOW > A0T IIF SO* CARRY IS SET
|
||||||
ROL A ;
|
ROL A ;G E T CARRY
|
||||||
ORA PSW ;
|
ORA PSW ;OR WITH 8080 CARRY
|
||||||
LSR A ;
|
LSR A ;I S EITHER SETT
|
||||||
BCC DA ;
|
BCC DA ;NO# DON'T ADJUST MSNIB l
|
||||||
SXTY TYA ;
|
SXTY TYA ;YES* ADJUST MSN!B I
|
||||||
ADC #$5F ;
|
ADC #$5F ;(5F + CARRY = 60)
|
||||||
TAY ;
|
TAY ;
|
||||||
DA LDX #$00 ;
|
DA LDX #$00 ;DESTINATION IS A
|
||||||
PLP ;
|
PLP ;RESTQRE STATUS
|
||||||
ADCRY JSR ADDR ;
|
ADCRY JSR ADDR ;
|
||||||
JSR CARRY ;
|
JSR CARRY ;
|
||||||
|
|
||||||
|
|
||||||
STATUS2
|
STATUS2
|
||||||
TAY ;
|
TAY ; SAVE RESULT
|
||||||
ROL PSW ;
|
ROL PSW ; CLEAR P3W SIGN BIT
|
||||||
ASL A ;
|
ASL A ; PUT NEW SIGN IN CARRY
|
||||||
STA FLAG ;
|
STA FLAG ; C L E A R L S B OF F L A G
|
||||||
LDA PSW ;
|
LDA PSW ; PUT NEW SIGN IN P3N
|
||||||
ROR A ;
|
ROR A ;
|
||||||
SGN ORA #$46 ;
|
SGN ORA #$46 ; PRESET Z*P 8 PRESET
|
||||||
TAX ;
|
TAX ; 3AVE IN X
|
||||||
TYA ;
|
TYA ; RECOVER WORD
|
||||||
BEQ DONE ;
|
BEQ DONE ; I F ZERO*ALL DONE
|
||||||
FLIP INC FLAG ;
|
FLIP INC FLAG ; IFLIP FLAG |
|
||||||
PAR LSR A ;
|
PAR LSR A ; TEST EACH BIT I
|
||||||
BEQ ALL2 ;
|
BEQ ALL2 ; NO MORE BITS
|
||||||
BCC PAR ;
|
BCC PAR ;
|
||||||
ALL2 BCS FLIP ;
|
ALL2 BCS FLIP ;
|
||||||
LSR FLAG ;
|
LSR FLAG ; TEST FLAG
|
||||||
TXA ;
|
TXA ; RECOVER P3w
|
||||||
AND #$BF ;
|
AND #$BF ; CLEAR Z
|
||||||
BCS REC ;
|
BCS REC ; PARITY EVENT
|
||||||
AND #$FB ;
|
AND #$FB ; N0* CLEAR P
|
||||||
REC TAX ;
|
REC TAX ; BACK TO X
|
||||||
DONE STX PSW ;
|
DONE STX PSW ; STORE AS PSW
|
||||||
RTS ;
|
RTS ;
|
||||||
|
|
||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -1172,8 +1166,6 @@ DEC LDY #$0C ; point to DEC data
|
|||||||
; ----------------------------------------------------------------------------
|
; ----------------------------------------------------------------------------
|
||||||
MEMRP TYA ; grab source pointer offset
|
MEMRP TYA ; grab source pointer offset
|
||||||
|
|
||||||
LDY #$80
|
|
||||||
STY HIPCOFFSET
|
|
||||||
|
|
||||||
LDA DESTDA+1
|
LDA DESTDA+1
|
||||||
|
|
||||||
@ -1185,7 +1177,7 @@ MEMRP TYA ; grab source pointer offset
|
|||||||
BCS MRLP1
|
BCS MRLP1
|
||||||
AUXMEMRP STA RAMRDON ; read from AUX
|
AUXMEMRP STA RAMRDON ; read from AUX
|
||||||
SEC
|
SEC
|
||||||
SBC HIPCOFFSET
|
SBC #$80
|
||||||
STA DESTDA+1
|
STA DESTDA+1
|
||||||
|
|
||||||
MRLP1 LDY #$01 ; move data in memory
|
MRLP1 LDY #$01 ; move data in memory
|
||||||
@ -1201,11 +1193,9 @@ MRLP LDA (DESTDA),Y ; get next byte
|
|||||||
STA RAMRDOFF ; read from MAIN
|
STA RAMRDOFF ; read from MAIN
|
||||||
LDA DESTDA+1
|
LDA DESTDA+1
|
||||||
CLC
|
CLC
|
||||||
ADC HIPCOFFSET
|
ADC #$80
|
||||||
STA DESTDA+1
|
STA DESTDA+1
|
||||||
|
|
||||||
LDA #$80
|
|
||||||
STA HIPCOFFSET ; set offset
|
|
||||||
|
|
||||||
|
|
||||||
MRLPRTS RTS ;
|
MRLPRTS RTS ;
|
||||||
@ -2660,11 +2650,11 @@ CHOOSER2 ASC " 1 FOR KILL-THE-BIT",00
|
|||||||
CHOOSER3 ASC " 2 FOR 4K BASIC",00
|
CHOOSER3 ASC " 2 FOR 4K BASIC",00
|
||||||
CHOOSER4 ASC " 3 FOR 8K BASIC",00
|
CHOOSER4 ASC " 3 FOR 8K BASIC",00
|
||||||
CHOOSER5 ASC " 4 FOR MICROCHESS",00
|
CHOOSER5 ASC " 4 FOR MICROCHESS",00
|
||||||
CHOOSER6 ASC " 5 FOR DISK BOOTLOADER",00
|
CHOOSER6 ASC " 5 FOR DBL ROM AT $00",00
|
||||||
CHOOSER7 ASC " 0 FOR NO PROGRAM",00
|
CHOOSER7 ASC " 0 FOR NO PROGRAM",00
|
||||||
|
|
||||||
CHOOSERTBL DB >CHOOSER1,<CHOOSER1,>CHOOSER2,<CHOOSER2,>CHOOSER3,<CHOOSER3
|
CHOOSERTBL DB >CHOOSER1,<CHOOSER1,>CHOOSER2,<CHOOSER2,>CHOOSER3,<CHOOSER3
|
||||||
DB >CHOOSER4,<CHOOSER4,>CHOOSER5,<CHOOSER5,>CHOOSER6,<CHOOSER6,>CHOOSER7,<CHOOSER7
|
DB >CHOOSER4,<CHOOSER4,>CHOOSER5,<CHOOSER5,>CHOOSER6,<CHOOSER6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2676,7 +2666,7 @@ CHOOSERLOOP LDY CHOOSERTBL,X
|
|||||||
JSR STROUT ;Y=String ptr high, A=String ptr low
|
JSR STROUT ;Y=String ptr high, A=String ptr low
|
||||||
JSR CROUT
|
JSR CROUT
|
||||||
INX
|
INX
|
||||||
CPX #$0E
|
CPX #$0C
|
||||||
BNE CHOOSERLOOP
|
BNE CHOOSERLOOP
|
||||||
|
|
||||||
CHOOSERWAITLOOP LDX #$00
|
CHOOSERWAITLOOP LDX #$00
|
||||||
@ -3015,7 +3005,7 @@ DSKREADLOC DB <BASICBUFFER,>BASICBUFFER ; write to end of sim8800
|
|||||||
DSKTRANSFERRED DB $00,$00
|
DSKTRANSFERRED DB $00,$00
|
||||||
|
|
||||||
DSKFILE DB ENDDSKNAME-DSKNAME ;Length of name
|
DSKFILE DB ENDDSKNAME-DSKNAME ;Length of name
|
||||||
DSKNAME ASC '/SIM8800/VIRTUAL.DSK' ;followed by the name
|
DSKNAME ASC '/SIM8800/ZORK.DSK' ;followed by the name
|
||||||
ENDDSKNAME EQU *
|
ENDDSKNAME EQU *
|
||||||
|
|
||||||
WRITEDSK JSR MLI
|
WRITEDSK JSR MLI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user