mirror of
https://github.com/irmen/prog8.git
synced 2024-11-29 01:49:22 +00:00
progstart() added to complement progend()
This commit is contained in:
parent
9438e996d7
commit
1d38c3582a
@ -91,6 +91,7 @@ internal class ProgramAndVarsGen(
|
|||||||
OutputType.RAW -> {
|
OutputType.RAW -> {
|
||||||
asmgen.out("; ---- raw assembler program ----")
|
asmgen.out("; ---- raw assembler program ----")
|
||||||
asmgen.out("* = ${options.loadAddress.toHex()}")
|
asmgen.out("* = ${options.loadAddress.toHex()}")
|
||||||
|
asmgen.out("prog8_program_start\t; start of program label")
|
||||||
asmgen.out(" cld")
|
asmgen.out(" cld")
|
||||||
asmgen.out(" tsx ; save stackpointer for sys.exit()")
|
asmgen.out(" tsx ; save stackpointer for sys.exit()")
|
||||||
asmgen.out(" stx prog8_lib.orig_stackpointer")
|
asmgen.out(" stx prog8_lib.orig_stackpointer")
|
||||||
@ -106,6 +107,7 @@ internal class ProgramAndVarsGen(
|
|||||||
}
|
}
|
||||||
asmgen.out("; ---- basic program with sys call ----")
|
asmgen.out("; ---- basic program with sys call ----")
|
||||||
asmgen.out("* = ${options.loadAddress.toHex()}")
|
asmgen.out("* = ${options.loadAddress.toHex()}")
|
||||||
|
asmgen.out("prog8_program_start\t; start of program label")
|
||||||
val year = LocalDate.now().year
|
val year = LocalDate.now().year
|
||||||
asmgen.out(" .word (+), $year")
|
asmgen.out(" .word (+), $year")
|
||||||
asmgen.out(" .null $9e, format(' %d ', prog8_entrypoint), $3a, $8f, ' prog8'")
|
asmgen.out(" .null $9e, format(' %d ', prog8_entrypoint), $3a, $8f, ' prog8'")
|
||||||
@ -122,6 +124,7 @@ internal class ProgramAndVarsGen(
|
|||||||
// this is the same as RAW
|
// this is the same as RAW
|
||||||
asmgen.out("; ---- program without basic sys call ----")
|
asmgen.out("; ---- program without basic sys call ----")
|
||||||
asmgen.out("* = ${options.loadAddress.toHex()}")
|
asmgen.out("* = ${options.loadAddress.toHex()}")
|
||||||
|
asmgen.out("prog8_program_start\t; start of program label")
|
||||||
asmgen.out(" cld")
|
asmgen.out(" cld")
|
||||||
asmgen.out(" tsx ; save stackpointer for sys.exit()")
|
asmgen.out(" tsx ; save stackpointer for sys.exit()")
|
||||||
asmgen.out(" stx prog8_lib.orig_stackpointer")
|
asmgen.out(" stx prog8_lib.orig_stackpointer")
|
||||||
@ -134,6 +137,7 @@ internal class ProgramAndVarsGen(
|
|||||||
OutputType.XEX -> {
|
OutputType.XEX -> {
|
||||||
asmgen.out("; ---- atari xex program ----")
|
asmgen.out("; ---- atari xex program ----")
|
||||||
asmgen.out("* = ${options.loadAddress.toHex()}")
|
asmgen.out("* = ${options.loadAddress.toHex()}")
|
||||||
|
asmgen.out("prog8_program_start\t; start of program label")
|
||||||
asmgen.out(" cld")
|
asmgen.out(" cld")
|
||||||
asmgen.out(" tsx ; save stackpointer for sys.exit()")
|
asmgen.out(" tsx ; save stackpointer for sys.exit()")
|
||||||
asmgen.out(" stx prog8_lib.orig_stackpointer")
|
asmgen.out(" stx prog8_lib.orig_stackpointer")
|
||||||
|
@ -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) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
|
@ -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) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
|
@ -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) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
|
@ -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) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
|
@ -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) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
|
@ -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) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
|
@ -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,
|
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.
|
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.
|
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 (uword jiffies)``
|
||||||
wait approximately the given number of jiffies (1/60th seconds)
|
wait approximately the given number of jiffies (1/60th seconds)
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
%import math
|
|
||||||
%import textio
|
%import textio
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
uword v0 = 4000
|
txt.print_uwhex(sys.progstart(), true)
|
||||||
uword v1 = 60000
|
|
||||||
|
|
||||||
for cx16.r1 in 65400 to 65535 {
|
|
||||||
txt.print_uw(cx16.r1)
|
|
||||||
txt.spc()
|
txt.spc()
|
||||||
txt.spc()
|
txt.print_uwhex(sys.progend(), true)
|
||||||
txt.print_uw(math.lerpw(v0, v1, cx16.r1))
|
|
||||||
txt.nl()
|
txt.nl()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user