diff options
author | H. Peter Anvin <hpa@zytor.com> | 2018-10-13 00:40:14 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2018-10-13 00:40:14 -0700 |
commit | d538d0709dae408326cc833ef5a59ae45083a362 (patch) | |
tree | c4d96f81ed274af6d6c1df1122a6da492b3813ee | |
parent | cdd64dbe4befc8f32799fafbf6f5ae7db0900682 (diff) | |
download | abcdisk-d538d0709dae408326cc833ef5a59ae45083a362.tar.gz abcdisk-d538d0709dae408326cc833ef5a59ae45083a362.tar.xz abcdisk-d538d0709dae408326cc833ef5a59ae45083a362.zip |
bac80.c: use 0xFE38 = 65080 = ERRCODE as a junk byte
ERRCODE will immediately be reset to -1 on END anyway, so it is a
perfectly safe place to dump an unwanted value.
-rw-r--r-- | bac80.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -132,24 +132,28 @@ static uint8_t run_prefix[] = { #define RUN_CALL_OFFSET 15 /* - * This is the BASIC statement 1 POKE xxxx%,CALL(yyyy%) - * followed by an end of program marker (1 byte) and a scratch byte. + * This is the BASIC statement 1 POKE 65080%,CALL(yyyy%) + * followed by an end of program marker (1 byte). 65080% is + * the location of ERRCODE, which will be reset to -1 when + * END is executed anyway, which will happen immediately. * * This includes the BASIC statement encapsulation, since this is * part of the payload. */ static uint8_t restart_prefix[] = { - 0x11, 0x01, 0x00, 0x86, 0x81, 0xc7, - 0xff, 0xff, /* Point to scratch byte */ + 0x10, 0x01, 0x00, 0x86, 0x81, 0xc7, + 0x38, 0xfe, /* Point to scratch byte */ 0xba, 0x2c, 0xc7, 0, 0, /* CALL address goes here */ 0xce, 0x3a, 0xba, 0x0d, - 0x01, /* End of BASIC program */ - 0x00 /* Scratch byte */ + 0x01 /* End of BASIC program */ }; -#define RESTART_REL1_OFFSET 6 #define RESTART_CALL_OFFSET 11 +/* + * STOP statement, used as end-of-data marker. Technically, + * any BASIC statement of 3 bytes or less would work here. + */ static const uint8_t stop_stmt[] = { 0x86, 0x89 /* BASIC bytecode for STOP */ }; @@ -182,7 +186,6 @@ int writebac80(FILE * out, const uint8_t * data, int len, int origin, /* Application, add a restart prefix to payload */ pfxlen = sizeof restart_prefix; set16(restart_prefix + RESTART_CALL_OFFSET, entrypoint); - push_reloc(RESTART_REL1_OFFSET - pfxlen); push_reloc(RESTART_CALL_OFFSET - pfxlen); } loader[bac80r_SYM_DELTA] = pfxlen; |