mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 20:08:05 +11:00
zasm: consolidate
* Build emulated zasm statically * Improve comments in zasm.asm * Fix build * Use unsetZ from core
This commit is contained in:
parent
055e0d7a31
commit
175e1328e7
@ -1,11 +1,12 @@
|
|||||||
zasm: zasm.c libz80/libz80.so kernel.h zasm.h
|
zasm: zasm.c libz80/libz80.o kernel.h zasm.h
|
||||||
cc $< -l z80 -L./libz80 -Wl,-rpath ./libz80 -o $@
|
cc $< libz80/libz80.o -o $@
|
||||||
|
|
||||||
libz80/libz80.so: libz80/Makefile
|
libz80/libz80.o: libz80/z80.c
|
||||||
make -C libz80
|
make -C libz80/codegen opcodes
|
||||||
|
gcc -Wall -ansi -g -c -o libz80/libz80.o libz80/z80.c
|
||||||
|
|
||||||
kernel.h: glue.asm
|
kernel.h: glue.asm
|
||||||
scas -o - -I ../../../parts $< | ./bin2c.sh KERNEL | tee $@ > /dev/null
|
scas -o - -I ../../../parts/z80 $< | ./bin2c.sh KERNEL | tee $@ > /dev/null
|
||||||
|
|
||||||
zasm.h: ../zasm.asm ../tok.asm
|
zasm.h: ../zasm.asm ../tok.asm
|
||||||
scas -o - -I.. $< | ./bin2c.sh ZASM | tee $@ > /dev/null
|
scas -o - -I.. $< | ./bin2c.sh ZASM | tee $@ > /dev/null
|
||||||
|
@ -8,6 +8,7 @@ jr init ; 2 bytes
|
|||||||
jp strncmp
|
jp strncmp
|
||||||
jp addDE
|
jp addDE
|
||||||
jp upcase
|
jp upcase
|
||||||
|
jp unsetZ
|
||||||
|
|
||||||
init:
|
init:
|
||||||
di
|
di
|
||||||
|
@ -6,3 +6,4 @@ USER_CODE .equ RAMSTART
|
|||||||
JUMP_STRNCMP .equ 0x02
|
JUMP_STRNCMP .equ 0x02
|
||||||
JUMP_ADDDE .equ 0x05
|
JUMP_ADDDE .equ 0x05
|
||||||
JUMP_UPCASE .equ 0x08
|
JUMP_UPCASE .equ 0x08
|
||||||
|
JUMP_UNSETZ .equ 0x0b
|
||||||
|
@ -20,15 +20,6 @@ ret
|
|||||||
|
|
||||||
#include "tok.asm"
|
#include "tok.asm"
|
||||||
|
|
||||||
; TODO: call from core
|
|
||||||
unsetZ:
|
|
||||||
push bc
|
|
||||||
ld b, a
|
|
||||||
inc b
|
|
||||||
cp b
|
|
||||||
pop bc
|
|
||||||
ret
|
|
||||||
|
|
||||||
; run RLA the number of times specified in B
|
; run RLA the number of times specified in B
|
||||||
rlaX:
|
rlaX:
|
||||||
; first, see if B == 0 to see if we need to bail out
|
; first, see if B == 0 to see if we need to bail out
|
||||||
@ -93,7 +84,7 @@ enterParens:
|
|||||||
ret ; we're good!
|
ret ; we're good!
|
||||||
.doNotEnter:
|
.doNotEnter:
|
||||||
pop hl
|
pop hl
|
||||||
call unsetZ
|
call JUMP_UNSETZ
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Checks whether A is 'N' or 'M'
|
; Checks whether A is 'N' or 'M'
|
||||||
@ -167,7 +158,7 @@ parseNumber:
|
|||||||
jr .loop
|
jr .loop
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
call unsetZ
|
call JUMP_UNSETZ
|
||||||
.end:
|
.end:
|
||||||
pop bc
|
pop bc
|
||||||
pop de
|
pop de
|
||||||
@ -312,7 +303,7 @@ isGroupId:
|
|||||||
cp a
|
cp a
|
||||||
ret
|
ret
|
||||||
.notgroup:
|
.notgroup:
|
||||||
call unsetZ
|
call JUMP_UNSETZ
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Find argspec A in group id H.
|
; Find argspec A in group id H.
|
||||||
@ -382,7 +373,7 @@ findInGroup:
|
|||||||
jr .end
|
jr .end
|
||||||
.notfound:
|
.notfound:
|
||||||
pop bc ; from the push bc in .find
|
pop bc ; from the push bc in .find
|
||||||
call unsetZ
|
call JUMP_UNSETZ
|
||||||
.end:
|
.end:
|
||||||
pop hl
|
pop hl
|
||||||
pop bc
|
pop bc
|
||||||
@ -403,7 +394,7 @@ matchArg:
|
|||||||
cp 0
|
cp 0
|
||||||
jr nz, .checkIfNumber ; not a zero, we can continue
|
jr nz, .checkIfNumber ; not a zero, we can continue
|
||||||
; zero, stop here
|
; zero, stop here
|
||||||
call unsetZ
|
call JUMP_UNSETZ
|
||||||
ret
|
ret
|
||||||
.checkIfNumber:
|
.checkIfNumber:
|
||||||
; not an exact match, let's check for numerical constants.
|
; not an exact match, let's check for numerical constants.
|
||||||
@ -502,7 +493,7 @@ handleBIT:
|
|||||||
ret
|
ret
|
||||||
.error:
|
.error:
|
||||||
xor c
|
xor c
|
||||||
call unsetZ
|
call JUMP_UNSETZ
|
||||||
ret
|
ret
|
||||||
|
|
||||||
handleBITHL:
|
handleBITHL:
|
||||||
@ -792,7 +783,7 @@ processArg:
|
|||||||
cp a ; ensure Z is set
|
cp a ; ensure Z is set
|
||||||
ret
|
ret
|
||||||
.error:
|
.error:
|
||||||
call unsetZ
|
call JUMP_UNSETZ
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Parse line at (HL) and write resulting opcode(s) in curUpcode. Returns the
|
; Parse line at (HL) and write resulting opcode(s) in curUpcode. Returns the
|
||||||
@ -910,8 +901,8 @@ argGrpCC:
|
|||||||
argGrpABCDEHL:
|
argGrpABCDEHL:
|
||||||
.db "BCDEHL_A" ; 0xb
|
.db "BCDEHL_A" ; 0xb
|
||||||
|
|
||||||
; This is a list of primary instructions (single upcode) that lead to a
|
; This is a list of all supported instructions. Each row represent a combination
|
||||||
; constant (no group code to insert). Format:
|
; of instr/argspecs (which means more than one row per instr). Format:
|
||||||
;
|
;
|
||||||
; 4 bytes for the name (fill with zero)
|
; 4 bytes for the name (fill with zero)
|
||||||
; 1 byte for arg constant
|
; 1 byte for arg constant
|
||||||
@ -919,9 +910,12 @@ argGrpABCDEHL:
|
|||||||
; 1 byte displacement for group arguments + flags
|
; 1 byte displacement for group arguments + flags
|
||||||
; 2 bytes for upcode (2nd byte is zero if instr is one byte)
|
; 2 bytes for upcode (2nd byte is zero if instr is one byte)
|
||||||
;
|
;
|
||||||
|
; An "arg constant" is a char corresponding to either a row in argspecTbl or
|
||||||
|
; a group index in argGrpTbl (values < 0x10 are considered group indexes).
|
||||||
|
;
|
||||||
; The displacement bit is split in 2 nibbles: lower nibble is the displacement
|
; The displacement bit is split in 2 nibbles: lower nibble is the displacement
|
||||||
; value, upper nibble is for flags:
|
; value, upper nibble is for flags:
|
||||||
|
;
|
||||||
; Bit 7: indicates that the numerical argument is of the 'e' type and has to be
|
; Bit 7: indicates that the numerical argument is of the 'e' type and has to be
|
||||||
; decreased by 2 (djnz, jr).
|
; decreased by 2 (djnz, jr).
|
||||||
; Bit 6: it indicates that the group argument's value is to be placed on the
|
; Bit 6: it indicates that the group argument's value is to be placed on the
|
||||||
|
Loading…
Reference in New Issue
Block a user