This commit is contained in:
Irmen de Jong 2024-09-02 22:19:30 +02:00
parent a50400b7d1
commit 7d4dc3c063
2 changed files with 67 additions and 28 deletions

View File

@ -12,6 +12,7 @@ class Neo6502MachineDefinition: IMachineDefinition {
override val FLOAT_MAX_NEGATIVE = -9.999999999e97 override val FLOAT_MAX_NEGATIVE = -9.999999999e97
override val FLOAT_MEM_SIZE = 6 override val FLOAT_MEM_SIZE = 6
override val PROGRAM_LOAD_ADDRESS = 0x0800u override val PROGRAM_LOAD_ADDRESS = 0x0800u
override val PROGRAM_TOP_ADDRESS = 0xfbffu
override val BSSHIGHRAM_START = 0u // TODO override val BSSHIGHRAM_START = 0u // TODO
override val BSSHIGHRAM_END = 0u // TODO override val BSSHIGHRAM_END = 0u // TODO
@ -25,10 +26,6 @@ class Neo6502MachineDefinition: IMachineDefinition {
override fun convertFloatToBytes(num: Double): List<UByte> = TODO("atari float to bytes") override fun convertFloatToBytes(num: Double): List<UByte> = TODO("atari float to bytes")
override fun convertBytesToFloat(bytes: List<UByte>): Double = TODO("atari bytes to float") override fun convertBytesToFloat(bytes: List<UByte>): Double = TODO("atari bytes to float")
override fun importLibs(compilerOptions: CompilationOptions, compilationTargetName: String): List<String> {
return listOf("syslib")
}
override fun launchEmulator(selectedEmulator: Int, programNameWithPath: Path) { override fun launchEmulator(selectedEmulator: Int, programNameWithPath: Path) {
if(selectedEmulator!=1) { if(selectedEmulator!=1) {
System.err.println("The neo target only supports the main emulator (neo).") System.err.println("The neo target only supports the main emulator (neo).")

View File

@ -15,25 +15,13 @@ sys {
const ubyte target = 7 ; compilation target specifier. 255=virtual, 128=C128, 64=C64, 32=PET, 16=CommanderX16, 8=atari800XL, 7=Neo6502 const ubyte target = 7 ; compilation target specifier. 255=virtual, 128=C128, 64=C64, 32=PET, 16=CommanderX16, 8=atari800XL, 7=Neo6502
asmsub init_system() { const ubyte sizeof_bool = 1
; Initializes the machine to a sane starting state. const ubyte sizeof_byte = 1
; Called automatically by the loader program logic. const ubyte sizeof_ubyte = 1
%asm {{ const ubyte sizeof_word = 2
sei const ubyte sizeof_uword = 2
cld const ubyte sizeof_float = 0 ; undefined, no floats supported
clc
; TODO reset screen mode etc etc?
clv
; TODO what about IRQ handler? cli
rts
}}
}
asmsub init_system_phase2() {
%asm {{
rts ; no phase 2 steps on the Neo6502
}}
}
asmsub reset_system() { asmsub reset_system() {
; Soft-reset the system back to initial power-on status ; Soft-reset the system back to initial power-on status
@ -216,6 +204,7 @@ save_SCRATCH_ZPB1 .byte 0
save_SCRATCH_ZPREG .byte 0 save_SCRATCH_ZPREG .byte 0
save_SCRATCH_ZPWORD1 .word 0 save_SCRATCH_ZPWORD1 .word 0
save_SCRATCH_ZPWORD2 .word 0 save_SCRATCH_ZPWORD2 .word 0
; !notreached!
}} }}
} }
@ -239,27 +228,38 @@ save_SCRATCH_ZPWORD2 .word 0
asmsub exit(ubyte returnvalue @A) { asmsub exit(ubyte returnvalue @A) {
; -- immediately exit the program with a return code in the A register ; -- immediately exit the program with a return code in the A register
; TODO where to store A as exit code?
%asm {{ %asm {{
sta cleanup_at_exit._exitcode
ldx prog8_lib.orig_stackpointer ldx prog8_lib.orig_stackpointer
txs txs
rts ; return to original caller jmp cleanup_at_exit
}} }}
} }
asmsub exit2(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y) { asmsub exit2(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y) {
; -- immediately exit the program with result values in the A, X and Y registers. ; -- immediately exit the program with result values in the A, X and Y registers.
; TODO where to store A,X,Y as exit code?
%asm {{ %asm {{
jmp exit sta cleanup_at_exit._exitcode
stx cleanup_at_exit._exitcodeX
sty cleanup_at_exit._exitcodeY
ldx prog8_lib.orig_stackpointer
txs
jmp cleanup_at_exit
}} }}
} }
asmsub exit3(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y, bool carry @Pc) { asmsub exit3(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y, bool carry @Pc) {
; -- immediately exit the program with result values in the A, X and Y registers, and the Carry flag in the status register. ; -- immediately exit the program with result values in the A, X and Y registers, and the Carry flag in the status register.
; TODO where to store A,X,Y,Carry as exit code?
%asm {{ %asm {{
jmp exit sta cleanup_at_exit._exitcode
lda #0
rol a
sta cleanup_at_exit._exitcodeCarry
stx cleanup_at_exit._exitcodeX
sty cleanup_at_exit._exitcodeY
ldx prog8_lib.orig_stackpointer
txs
jmp cleanup_at_exit
}} }}
} }
@ -417,6 +417,7 @@ cx16 {
_cx16_vreg_storage _cx16_vreg_storage
.word 0,0,0,0,0,0,0,0 .word 0,0,0,0,0,0,0,0
.word 0,0,0,0,0,0,0,0 .word 0,0,0,0,0,0,0,0
; !notreached!
}} }}
} }
@ -437,3 +438,44 @@ cx16 {
} }
} }
p8_sys_startup {
; program startup and shutdown machinery. Needs to reside in normal system ram.
asmsub init_system() {
; Initializes the machine to a sane starting state.
; Called automatically by the loader program logic.
%asm {{
sei
cld
clc
; TODO reset screen mode etc etc?
clv
; TODO what about IRQ handler? cli
rts
}}
}
asmsub init_system_phase2() {
%asm {{
rts ; no phase 2 steps on the Neo6502
}}
}
asmsub cleanup_at_exit() {
; executed when the main subroutine does rts
%asm {{
_exitcodeCarry = *+1
lda #0
lsr a
_exitcode = *+1
lda #0 ; exit code possibly modified in exit()
_exitcodeX = *+1
ldx #0
_exitcodeY = *+1
ldy #0
rts
}}
}
}