progstart() added to complement progend()

This commit is contained in:
Irmen de Jong 2024-11-13 19:29:50 +01:00
parent 9438e996d7
commit 1d38c3582a
9 changed files with 55 additions and 11 deletions

View File

@ -91,6 +91,7 @@ internal class ProgramAndVarsGen(
OutputType.RAW -> {
asmgen.out("; ---- raw assembler program ----")
asmgen.out("* = ${options.loadAddress.toHex()}")
asmgen.out("prog8_program_start\t; start of program label")
asmgen.out(" cld")
asmgen.out(" tsx ; save stackpointer for sys.exit()")
asmgen.out(" stx prog8_lib.orig_stackpointer")
@ -106,6 +107,7 @@ internal class ProgramAndVarsGen(
}
asmgen.out("; ---- basic program with sys call ----")
asmgen.out("* = ${options.loadAddress.toHex()}")
asmgen.out("prog8_program_start\t; start of program label")
val year = LocalDate.now().year
asmgen.out(" .word (+), $year")
asmgen.out(" .null $9e, format(' %d ', prog8_entrypoint), $3a, $8f, ' prog8'")
@ -122,6 +124,7 @@ internal class ProgramAndVarsGen(
// this is the same as RAW
asmgen.out("; ---- program without basic sys call ----")
asmgen.out("* = ${options.loadAddress.toHex()}")
asmgen.out("prog8_program_start\t; start of program label")
asmgen.out(" cld")
asmgen.out(" tsx ; save stackpointer for sys.exit()")
asmgen.out(" stx prog8_lib.orig_stackpointer")
@ -134,6 +137,7 @@ internal class ProgramAndVarsGen(
OutputType.XEX -> {
asmgen.out("; ---- atari xex program ----")
asmgen.out("* = ${options.loadAddress.toHex()}")
asmgen.out("prog8_program_start\t; start of program label")
asmgen.out(" cld")
asmgen.out(" tsx ; save stackpointer for sys.exit()")
asmgen.out(" stx prog8_lib.orig_stackpointer")

View File

@ -336,6 +336,13 @@ save_SCRATCH_ZPWORD2 .word 0
}}
}
inline asmsub progstart() -> uword @AY {
%asm {{
lda #<prog8_program_start
ldy #>prog8_program_start
}}
}
inline asmsub push(ubyte value @A) {
%asm {{
pha

View File

@ -887,6 +887,13 @@ _no_msb_size
}}
}
inline asmsub progstart() -> uword @AY {
%asm {{
lda #<prog8_program_start
ldy #>prog8_program_start
}}
}
inline asmsub push(ubyte value @A) {
%asm {{
pha

View File

@ -903,6 +903,13 @@ _no_msb_size
}}
}
inline asmsub progstart() -> uword @AY {
%asm {{
lda #<prog8_program_start
ldy #>prog8_program_start
}}
}
inline asmsub push(ubyte value @A) {
%asm {{
pha

View File

@ -1822,6 +1822,13 @@ save_SCRATCH_ZPWORD2 .word 0
}}
}
inline asmsub progstart() -> uword @AY {
%asm {{
lda #<prog8_program_start
ldy #>prog8_program_start
}}
}
inline asmsub push(ubyte value @A) {
%asm {{
pha

View File

@ -270,6 +270,13 @@ save_SCRATCH_ZPWORD2 .word 0
}}
}
inline asmsub progstart() -> uword @AY {
%asm {{
lda #<prog8_program_start
ldy #>prog8_program_start
}}
}
inline asmsub push(ubyte value @A) {
%asm {{
pha

View File

@ -435,6 +435,13 @@ save_SCRATCH_ZPWORD2 .word 0
}}
}
inline asmsub progstart() -> uword @AY {
%asm {{
lda #<prog8_program_start
ldy #>prog8_program_start
}}
}
inline asmsub push(ubyte value @A) {
%asm {{
pha

View File

@ -330,6 +330,11 @@ sys (part of syslib)
Returns the last address of the program in memory + 1. This means: the memory address directly after all the program code and variables,
including the uninitialized ones ("BSS" variables) and the uninitialized memory blocks reserved by the `memory()` function.
Can be used to load dynamic data after the program, instead of hardcoding something.
On the assembly level: it returns the address of the symbol "``prog8_program_end``".
``progstart ()``
Returns the first address of the program in memory. This usually is $0801 on the C64 and the X16, for example.
On the assembly level: it returns the address of the symbol "``prog8_program_start``".
``wait (uword jiffies)``
wait approximately the given number of jiffies (1/60th seconds)

View File

@ -1,19 +1,12 @@
%import math
%import textio
%option no_sysinit
%zeropage basicsafe
main {
sub start() {
uword v0 = 4000
uword v1 = 60000
for cx16.r1 in 65400 to 65535 {
txt.print_uw(cx16.r1)
txt.spc()
txt.spc()
txt.print_uw(math.lerpw(v0, v1, cx16.r1))
txt.nl()
}
txt.print_uwhex(sys.progstart(), true)
txt.spc()
txt.print_uwhex(sys.progend(), true)
txt.nl()
}
}