Skip to content

Commit 5cbc10f

Browse files
authored
Merge pull request #518 from boriel/feature/move_asm_lib_to_CORE_namespace
Feature/move asm lib to core namespace
2 parents 1440723 + c5b6301 commit 5cbc10f

911 files changed

Lines changed: 144783 additions & 137048 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/arch/zx48k/backend/__init__.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from . import errors
1515
from .errors import InvalidICError as InvalidIC
1616

17+
from .runtime.namespace import NAMESPACE
18+
1719

1820
# 8 bit arithmetic functions
1921
from .__8bit import _add8, _sub8, _mul8, _divu8, _divi8, _modu8, _modi8, _neg8, _abs8
@@ -116,12 +118,12 @@
116118
RE_IX_IDX = re.compile(r'^\([ \t]*ix[ \t]*[-+][ \t]*.+\)$')
117119

118120
# Label for the program START end EXIT
119-
START_LABEL = '__START_PROGRAM'
120-
END_LABEL = '__END_PROGRAM'
121-
CALL_BACK = '__CALL_BACK__'
122-
MAIN_LABEL = '__MAIN_PROGRAM__'
123-
DATA_LABEL = 'ZXBASIC_USER_DATA'
124-
DATA_END_LABEL = 'ZXBASIC_USER_DATA_END'
121+
START_LABEL = f'{NAMESPACE}__START_PROGRAM'
122+
END_LABEL = f'{NAMESPACE}__END_PROGRAM'
123+
CALL_BACK = f'{NAMESPACE}__CALL_BACK__'
124+
MAIN_LABEL = f'{NAMESPACE}__MAIN_PROGRAM__'
125+
DATA_LABEL = f'{NAMESPACE}ZXBASIC_USER_DATA'
126+
DATA_END_LABEL = f'{NAMESPACE}ZXBASIC_USER_DATA_END'
125127

126128
# Whether to use the FunctionExit scheme
127129
FLAG_use_function_exit = False
@@ -196,9 +198,9 @@ def init():
196198
# Default HEAP SIZE (Dynamic memory) in bytes
197199
OPTIONS.add_option('heap_size', int, 4768) # A bit more than 4K
198200
# Labels for HEAP START (might not be used if not needed)
199-
OPTIONS.add_option('heap_start_label', str, f'{RuntimeLabel.NAMESPACE}ZXBASIC_MEM_HEAP')
201+
OPTIONS.add_option('heap_start_label', str, f'{NAMESPACE}ZXBASIC_MEM_HEAP')
200202
# Labels for HEAP SIZE (might not be used if not needed)
201-
OPTIONS.add_option('heap_size_label', str, f'{RuntimeLabel.NAMESPACE}ZXBASIC_HEAP_SIZE')
203+
OPTIONS.add_option('heap_size_label', str, f'{NAMESPACE}ZXBASIC_HEAP_SIZE')
202204
# Flag for headerless mode (No prologue / epilogue)
203205
OPTIONS.add_option('headerless', bool, False)
204206

@@ -2222,16 +2224,16 @@ def emit_start():
22222224
heap_init = ['%s:' % DATA_LABEL]
22232225
output.append('org %s' % OPTIONS.org)
22242226

2225-
if REQUIRES.intersection(MEMINITS) or '__MEM_INIT' in INITS:
2227+
if REQUIRES.intersection(MEMINITS) or f'{NAMESPACE}__MEM_INIT' in INITS:
22262228
heap_init.append('; Defines HEAP SIZE\n' + OPTIONS.heap_size_label + ' EQU ' +
22272229
str(OPTIONS.heap_size))
22282230
heap_init.append(OPTIONS.heap_start_label + ':')
22292231
heap_init.append('DEFS %s' % str(OPTIONS.heap_size))
22302232

22312233
heap_init.append('; Defines USER DATA Length in bytes\n' +
2232-
'ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA')
2233-
heap_init.append('.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN')
2234-
heap_init.append('.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA')
2234+
f'{NAMESPACE}ZXBASIC_USER_DATA_LEN EQU {DATA_END_LABEL} - {DATA_LABEL}')
2235+
heap_init.append(f'{NAMESPACE}.__LABEL__.ZXBASIC_USER_DATA_LEN EQU {NAMESPACE}ZXBASIC_USER_DATA_LEN')
2236+
heap_init.append(f'{NAMESPACE}.__LABEL__.ZXBASIC_USER_DATA EQU {DATA_LABEL}')
22352237

22362238
output.append('%s:' % START_LABEL)
22372239
if OPTIONS.headerless:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Define just the main Private namespace
22

3-
NAMESPACE = ''
3+
NAMESPACE = 'core.'
Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,59 @@
1-
;
2-
; CharLeft
3-
; Alvin Albrecht 2002
4-
;
5-
6-
;INCLUDE "SPconfig.def"
7-
;XLIB SPCharLeft
8-
9-
; Char Left
10-
;
11-
; Adjusts screen address HL to move one character to the left
12-
; on the display. Start of line wraps to the previous row.
13-
;
14-
; enter: HL = valid screen address
15-
; Carry reset
16-
; exit : Carry = moved off screen
17-
; HL = moves one character left, with line wrap
18-
; used : AF, HL
19-
20-
;IF !DISP_HIRES
21-
22-
SP.CharLeft:
23-
ld a,l
24-
dec l
25-
or a
26-
ret nz
27-
ld a,h
28-
sub $08
29-
ld h,a
30-
cp $40
31-
ret
32-
33-
;ELSE
34-
35-
;.SPCharLeft
36-
; ld a,h
37-
; xor $20
38-
; ld h,a
39-
; cp $58
40-
; ccf
41-
; ret nc
42-
; ld a,l
43-
; dec l
44-
; or a
45-
; ret nz
46-
; ld a,h
47-
; sub $08
48-
; ld h,a
49-
; and $18
50-
; cp $18
51-
; ccf
52-
; ret
53-
54-
; ENDIF
1+
;
2+
; CharLeft
3+
; Alvin Albrecht 2002
4+
;
5+
6+
;INCLUDE "SPconfig.def"
7+
;XLIB SPCharLeft
8+
9+
; Char Left
10+
;
11+
; Adjusts screen address HL to move one character to the left
12+
; on the display. Start of line wraps to the previous row.
13+
;
14+
; enter: HL = valid screen address
15+
; Carry reset
16+
; exit : Carry = moved off screen
17+
; HL = moves one character left, with line wrap
18+
; used : AF, HL
19+
20+
;IF !DISP_HIRES
21+
22+
push namespace core
23+
24+
SP.CharLeft:
25+
ld a,l
26+
dec l
27+
or a
28+
ret nz
29+
ld a,h
30+
sub $08
31+
ld h,a
32+
cp $40
33+
ret
34+
35+
pop namespace
36+
37+
38+
;ELSE
39+
40+
;.SPCharLeft
41+
; ld a,h
42+
; xor $20
43+
; ld h,a
44+
; cp $58
45+
; ccf
46+
; ret nc
47+
; ld a,l
48+
; dec l
49+
; or a
50+
; ret nz
51+
; ld a,h
52+
; sub $08
53+
; ld h,a
54+
; and $18
55+
; cp $18
56+
; ccf
57+
; ret
58+
59+
; ENDIF
Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,54 @@
1-
;
2-
; CharRight
3-
; Alvin Albrecht 2002
4-
;
5-
6-
;INCLUDE "SPconfig.def"
7-
;XLIB SPCharRight
8-
9-
; Char Right
10-
;
11-
; Adjusts screen address HL to move one character to the right
12-
; on the display. End of line wraps to the next row.
13-
;
14-
; enter: HL = valid screen address
15-
; Carry reset
16-
; exit : Carry = moved off screen
17-
; HL = moves one character right, with line wrap
18-
; used : AF, HL
19-
20-
;IF !DISP_HIRES
21-
22-
SP.CharRight:
23-
inc l
24-
ret nz
25-
ld a,8
26-
add a,h
27-
ld h,a
28-
cp $58
29-
ccf
30-
ret
31-
32-
;ELSE
33-
34-
;.SPCharRight
35-
; ld a,h
36-
; xor $20
37-
; ld h,a
38-
; cp $58
39-
; ret nc
40-
; inc l
41-
; ret nz
42-
; ld a,8
43-
; add a,h
44-
; ld h,a
45-
; cp $58
46-
; ccf
47-
; ret
48-
49-
; ENDIF
1+
;
2+
; CharRight
3+
; Alvin Albrecht 2002
4+
;
5+
6+
;INCLUDE "SPconfig.def"
7+
;XLIB SPCharRight
8+
9+
; Char Right
10+
;
11+
; Adjusts screen address HL to move one character to the right
12+
; on the display. End of line wraps to the next row.
13+
;
14+
; enter: HL = valid screen address
15+
; Carry reset
16+
; exit : Carry = moved off screen
17+
; HL = moves one character right, with line wrap
18+
; used : AF, HL
19+
20+
;IF !DISP_HIRES
21+
22+
push namespace core
23+
24+
SP.CharRight:
25+
inc l
26+
ret nz
27+
ld a,8
28+
add a,h
29+
ld h,a
30+
cp $58
31+
ccf
32+
ret
33+
34+
pop namespace
35+
36+
37+
;ELSE
38+
39+
;.SPCharRight
40+
; ld a,h
41+
; xor $20
42+
; ld h,a
43+
; cp $58
44+
; ret nc
45+
; inc l
46+
; ret nz
47+
; ld a,8
48+
; add a,h
49+
; ld h,a
50+
; cp $58
51+
; ccf
52+
; ret
53+
54+
; ENDIF

0 commit comments

Comments
 (0)