Skip to content

Commit d496730

Browse files
committed
Add --zxnext option to the compiler
1 parent c7a375d commit d496730

5 files changed

Lines changed: 147 additions & 1 deletion

File tree

tests/functional/no_zxnext.asm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
LDIX
2+
LDWS
3+
LDIRX
4+
LDDX
5+
LDDRX
6+
LDPIRX
7+
OUTINB
8+
MUL D,E
9+
ADD HL,A
10+
ADD DE,A
11+
ADD BC,A
12+
ADD HL,0201h
13+
ADD DE,0201h
14+
ADD BC,0201h
15+
SWAPNIB
16+
MIRROR
17+
PUSH 4321h
18+
NEXTREG 37h,38h
19+
NEXTREG 33h,A
20+
PIXELDN
21+
PIXELAD
22+
SETAE
23+
TEST 77h
24+
BSLA DE,B
25+
BSRA DE,B
26+
BSRL DE,B
27+
BSRF DE,B
28+
BRLC DE,B
29+
JP (C)
30+

tests/functional/test_cmdline.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,23 @@ usage: zxb [-h] [-d] [-O OPTIMIZE] [-o OUTPUT_FILE] [-T] [-t] [-B] [-a] [-A]
1010
[-D DEFINES] [-M MEMORY_MAP] [-i] [-I INCLUDE_PATH] [--strict]
1111
[--headerless] [--version] [--parse-only]
1212
[--append-binary APPEND_BINARY]
13-
[--append-headless-binary APPEND_HEADLESS_BINARY]
13+
[--append-headless-binary APPEND_HEADLESS_BINARY] [-N]
1414
PROGRAM
1515
zxb: error: Option --asm and --mmap cannot be used together
1616

1717
>>> process_file('arrbase1.bas', ['-q', '-S', '-O -D EMPTY_MACRO'])
18+
19+
>>> process_file('use_zxnext_asm.bas')
20+
21+
>>> process_file('no_zxnext.asm')
22+
no_zxnext.asm:8: Syntax error. Unexpected token 'D' [D]
23+
no_zxnext.asm:9: Syntax error. Unexpected token 'A' [A]
24+
no_zxnext.asm:12: Syntax error. Unexpected token '513' [INTEGER]
25+
no_zxnext.asm:17: Syntax error. Unexpected token '17185' [INTEGER]
26+
no_zxnext.asm:23: Syntax error. Unexpected token '119' [INTEGER]
27+
no_zxnext.asm:29: Syntax error. Unexpected token 'C' [C]
28+
29+
>>> process_file('no_zxnext.asm', ['-q', '-S', '-O --zxnext'])
30+
31+
>>> process_file('zxnext_all.asm')
32+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
org 32768
2+
__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (__CALL_BACK__), hl
12+
ei
13+
#line 0
14+
LDIX
15+
LDWS
16+
LDIRX
17+
LDDX
18+
LDDRX
19+
LDPIRX
20+
OUTINB
21+
MUL D,E
22+
ADD HL,A
23+
ADD DE,A
24+
ADD BC,A
25+
ADD HL,0201h
26+
ADD DE,0201h
27+
ADD BC,0201h
28+
SWAPNIB
29+
MIRROR
30+
PUSH 4321h
31+
NEXTREG 37h,38h
32+
NEXTREG 33h,A
33+
PIXELDN
34+
PIXELAD
35+
SETAE
36+
TEST 77h
37+
BSLA DE,B
38+
BSRA DE,B
39+
BSRL DE,B
40+
BSRF DE,B
41+
BRLC DE,B
42+
JP (C)
43+
#line 29
44+
ld hl, 0
45+
ld b, h
46+
ld c, l
47+
__END_PROGRAM:
48+
di
49+
ld hl, (__CALL_BACK__)
50+
ld sp, hl
51+
exx
52+
pop hl
53+
exx
54+
pop iy
55+
pop ix
56+
ei
57+
ret
58+
__CALL_BACK__:
59+
DEFW 0
60+
ZXBASIC_USER_DATA:
61+
; Defines DATA END --> HEAP size is 0
62+
ZXBASIC_USER_DATA_END:
63+
; Defines USER DATA Length in bytes
64+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
65+
END
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma zxnext = TRUE
2+
ASM
3+
LDIX
4+
LDWS
5+
LDIRX
6+
LDDX
7+
LDDRX
8+
LDPIRX
9+
OUTINB
10+
MUL D,E
11+
ADD HL,A
12+
ADD DE,A
13+
ADD BC,A
14+
ADD HL,0201h
15+
ADD DE,0201h
16+
ADD BC,0201h
17+
SWAPNIB
18+
MIRROR
19+
PUSH 4321h
20+
NEXTREG 37h,38h
21+
NEXTREG 33h,A
22+
PIXELDN
23+
PIXELAD
24+
SETAE
25+
TEST 77h
26+
BSLA DE,B
27+
BSRA DE,B
28+
BSRL DE,B
29+
BSRF DE,B
30+
BRLC DE,B
31+
JP (C)
32+
END ASM
33+

zxb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ def main(args=None):
150150
help='Appends binary to tape file (only works with -t or -T)')
151151
parser.add_argument('--append-headless-binary', default=[], action='append',
152152
help='Appends binary to tape file (only works with -t or -T)')
153+
parser.add_argument('-N', '--zxnext', action='store_true',
154+
help='Enables ZX Next asm extended opcodes')
153155

154156
options = parser.parse_args(args=args)
155157

@@ -174,6 +176,7 @@ def main(args=None):
174176
OPTIONS.memory_map.value = options.memory_map
175177
OPTIONS.strict.value = options.strict
176178
OPTIONS.headerless.value = options.headerless
179+
OPTIONS.zxnext.value = options.zxnext
177180

178181
OPTIONS.org.value = api.utils.parse_int(options.org)
179182
if OPTIONS.org.value is None:

0 commit comments

Comments
 (0)