-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrt0_phc25.asm
More file actions
51 lines (36 loc) · 1.57 KB
/
Copy pathcrt0_phc25.asm
File metadata and controls
51 lines (36 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
; Minimal CRT0 for PHC25 Tetris using z88dk with XOR decoder
; Set origin to start of Program Work Area
org $C009
; ================================================================
; XOR Decoder Stub - THIS SECTION MUST NOT BE ENCODED!
; ================================================================
SECTION code_decoder
DI ; Disable interrupts
decoder_start:
LD D, XOR_MASK_VALUE ; Mask in D
LD HL, encoded_start ; Start of encoded region
LD BC, ENCODED_LENGTH ; Length to decode
decode_loop:
LD A, B ; Check if done
OR C
JR Z, start ; Jump to program start when done
LD A, (HL) ; Load byte
XOR D ; Decode
LD (HL), A ; Store back
INC HL ; Next byte
DEC BC
JR decode_loop
; Configuration
XOR_MASK_VALUE EQU 0x03 ; Set to actual mask after encoding
ENCODED_LENGTH EQU 7710 ; Set to actual length after encoding
; ================================================================
; Main program code - THIS GETS ENCODED
; ================================================================
SECTION code_compiler
encoded_start: ; Mark where encoding begins
start:
call _main
halt_loop:
jr halt_loop
PUBLIC start
EXTERN _main