Skip to content

Commit

Permalink
refact: move bitwise implementations to bitwise/
Browse files Browse the repository at this point in the history
  • Loading branch information
boriel committed Nov 13, 2024
1 parent 8bf2536 commit ea87feb
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/arch/z80/backend/runtime/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ class CoreLabels:
CoreLabels.ARRAY: "array.asm",
CoreLabels.ARRAY_PTR: "array.asm",
CoreLabels.ARRAYSTR_FREE_MEM: "arraystrfree.asm",
CoreLabels.BAND16: "band16.asm",
CoreLabels.BAND32: "band32.asm",
CoreLabels.BNOT16: "bnot16.asm",
CoreLabels.BNOT32: "bnot32.asm",
CoreLabels.BOR16: "bor16.asm",
CoreLabels.BOR32: "bor32.asm",
CoreLabels.BXOR16: "bxor16.asm",
CoreLabels.BXOR32: "bxor32.asm",
CoreLabels.BAND16: "bitwise/band16.asm",
CoreLabels.BAND32: "bitwise/band32.asm",
CoreLabels.BNOT16: "bitwise/bnot16.asm",
CoreLabels.BNOT32: "bitwise/bnot32.asm",
CoreLabels.BOR16: "bitwise/bor16.asm",
CoreLabels.BOR32: "bitwise/bor32.asm",
CoreLabels.BXOR16: "bitwise/bxor16.asm",
CoreLabels.BXOR32: "bitwise/bxor32.asm",
CoreLabels.CHECK_BREAK: "break.asm",
CoreLabels.DIVF: "divf.asm",
CoreLabels.DIVF16: "divf16.asm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ __BAND16:
ret

pop namespace

Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ __BAND32:
ret

pop namespace

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ __BNOT16:
ret

pop namespace

Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ __BNOT32:
ret

pop namespace

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ __BOR16:
ret

pop namespace

Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ __BOR32:
ret

pop namespace

Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ __BXOR16:
ret

pop namespace

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ __BXOR32:
xor l
ld c, a ; BC <- BC & HL

pop hl ; Return dddress
pop hl ; Return address
ex (sp), hl ; HL <- High part of 2nd Operand

ld a, d
Expand All @@ -37,4 +37,3 @@ __BXOR32:
ret

pop namespace

52 changes: 52 additions & 0 deletions tests/functional/arch/zx48k/bnot8.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
org 32768
.core.__START_PROGRAM:
di
push ix
push iy
exx
push hl
exx
ld hl, 0
add hl, sp
ld (.core.__CALL_BACK__), hl
ei
jp .core.__MAIN_PROGRAM__
.core.__CALL_BACK__:
DEFW 0
.core.ZXBASIC_USER_DATA:
; Defines USER DATA Length in bytes
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
_a:
DEFB 00
_b:
DEFB 00
.core.ZXBASIC_USER_DATA_END:
.core.__MAIN_PROGRAM__:
ld a, 255
ld (_b), a
ld a, 255
ld (_a), a
ld a, 254
ld (_b), a
ld a, 254
ld (_a), a
cpl
ld (_b), a
ld hl, 0
ld b, h
ld c, l
.core.__END_PROGRAM:
di
ld hl, (.core.__CALL_BACK__)
ld sp, hl
exx
pop hl
exx
pop iy
pop ix
ei
ret
;; --- end of user code ---
END
10 changes: 10 additions & 0 deletions tests/functional/arch/zx48k/bnot8.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
' TEST for Bitwise NOT 16 bits

DIM a as UByte
DIM b as UByte

b = bNOT 0
a = bNOT 0
b = bNOT 1
a = bNOT 1
b = bNOT a
6 changes: 3 additions & 3 deletions tests/functional/arch/zx48k/bxor32.asm
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ _b:
ei
ret
;; --- end of user code ---
#line 1 "/zxbasic/src/arch/zx48k/library-asm/bxor32.asm"
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/bitwise/bxor32.asm"
; FASTCALL bitwise xor 32 version.
; Performs 32bit xor 32bit and returns the bitwise
; result DE,HL
Expand All @@ -119,7 +119,7 @@ __BXOR32:
ld a, c
xor l
ld c, a ; BC <- BC & HL
pop hl ; Return dddress
pop hl ; Return address
ex (sp), hl ; HL <- High part of 2nd Operand
ld a, d
xor h
Expand All @@ -131,5 +131,5 @@ __BXOR32:
ld l, c ; HL <- BC ; Always return DE,HL pair regs
ret
pop namespace
#line 80 "bxor32.bas"
#line 80 "arch/zx48k/bxor32.bas"
END

0 comments on commit ea87feb

Please sign in to comment.