Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 14 additions & 12 deletions src/arch/zx48k/backend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from . import errors
from .errors import InvalidICError as InvalidIC

from .runtime.namespace import NAMESPACE


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

# Label for the program START end EXIT
START_LABEL = '__START_PROGRAM'
END_LABEL = '__END_PROGRAM'
CALL_BACK = '__CALL_BACK__'
MAIN_LABEL = '__MAIN_PROGRAM__'
DATA_LABEL = 'ZXBASIC_USER_DATA'
DATA_END_LABEL = 'ZXBASIC_USER_DATA_END'
START_LABEL = f'{NAMESPACE}__START_PROGRAM'
END_LABEL = f'{NAMESPACE}__END_PROGRAM'
CALL_BACK = f'{NAMESPACE}__CALL_BACK__'
MAIN_LABEL = f'{NAMESPACE}__MAIN_PROGRAM__'
DATA_LABEL = f'{NAMESPACE}ZXBASIC_USER_DATA'
DATA_END_LABEL = f'{NAMESPACE}ZXBASIC_USER_DATA_END'

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

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

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

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

output.append('%s:' % START_LABEL)
if OPTIONS.headerless:
Expand Down
2 changes: 1 addition & 1 deletion src/arch/zx48k/backend/runtime/namespace.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Define just the main Private namespace

NAMESPACE = ''
NAMESPACE = 'core.'
113 changes: 59 additions & 54 deletions src/arch/zx48k/library-asm/SP/CharLeft.asm
Original file line number Diff line number Diff line change
@@ -1,54 +1,59 @@
;
; CharLeft
; Alvin Albrecht 2002
;

;INCLUDE "SPconfig.def"
;XLIB SPCharLeft

; Char Left
;
; Adjusts screen address HL to move one character to the left
; on the display. Start of line wraps to the previous row.
;
; enter: HL = valid screen address
; Carry reset
; exit : Carry = moved off screen
; HL = moves one character left, with line wrap
; used : AF, HL

;IF !DISP_HIRES

SP.CharLeft:
ld a,l
dec l
or a
ret nz
ld a,h
sub $08
ld h,a
cp $40
ret

;ELSE

;.SPCharLeft
; ld a,h
; xor $20
; ld h,a
; cp $58
; ccf
; ret nc
; ld a,l
; dec l
; or a
; ret nz
; ld a,h
; sub $08
; ld h,a
; and $18
; cp $18
; ccf
; ret

; ENDIF
;
; CharLeft
; Alvin Albrecht 2002
;

;INCLUDE "SPconfig.def"
;XLIB SPCharLeft

; Char Left
;
; Adjusts screen address HL to move one character to the left
; on the display. Start of line wraps to the previous row.
;
; enter: HL = valid screen address
; Carry reset
; exit : Carry = moved off screen
; HL = moves one character left, with line wrap
; used : AF, HL

;IF !DISP_HIRES

push namespace core

SP.CharLeft:
ld a,l
dec l
or a
ret nz
ld a,h
sub $08
ld h,a
cp $40
ret

pop namespace


;ELSE

;.SPCharLeft
; ld a,h
; xor $20
; ld h,a
; cp $58
; ccf
; ret nc
; ld a,l
; dec l
; or a
; ret nz
; ld a,h
; sub $08
; ld h,a
; and $18
; cp $18
; ccf
; ret

; ENDIF
103 changes: 54 additions & 49 deletions src/arch/zx48k/library-asm/SP/CharRight.asm
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
;
; CharRight
; Alvin Albrecht 2002
;

;INCLUDE "SPconfig.def"
;XLIB SPCharRight

; Char Right
;
; Adjusts screen address HL to move one character to the right
; on the display. End of line wraps to the next row.
;
; enter: HL = valid screen address
; Carry reset
; exit : Carry = moved off screen
; HL = moves one character right, with line wrap
; used : AF, HL

;IF !DISP_HIRES

SP.CharRight:
inc l
ret nz
ld a,8
add a,h
ld h,a
cp $58
ccf
ret

;ELSE

;.SPCharRight
; ld a,h
; xor $20
; ld h,a
; cp $58
; ret nc
; inc l
; ret nz
; ld a,8
; add a,h
; ld h,a
; cp $58
; ccf
; ret

; ENDIF
;
; CharRight
; Alvin Albrecht 2002
;

;INCLUDE "SPconfig.def"
;XLIB SPCharRight

; Char Right
;
; Adjusts screen address HL to move one character to the right
; on the display. End of line wraps to the next row.
;
; enter: HL = valid screen address
; Carry reset
; exit : Carry = moved off screen
; HL = moves one character right, with line wrap
; used : AF, HL

;IF !DISP_HIRES

push namespace core

SP.CharRight:
inc l
ret nz
ld a,8
add a,h
ld h,a
cp $58
ccf
ret

pop namespace


;ELSE

;.SPCharRight
; ld a,h
; xor $20
; ld h,a
; cp $58
; ret nc
; inc l
; ret nz
; ld a,8
; add a,h
; ld h,a
; cp $58
; ccf
; ret

; ENDIF
Loading