Skip to content

Commit

Permalink
Fix for #65, adding additional live sources as PRG tests
Browse files Browse the repository at this point in the history
  • Loading branch information
envenomator committed Feb 27, 2024
1 parent aec4ce3 commit 9050b41
Show file tree
Hide file tree
Showing 94 changed files with 5,487 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,12 @@ uint8_t getDefineValueToken(streamtoken_t *token, char *src) {
if(*src) token->next = src+1;
else token->next = NULL;

*src-- = 0; // terminate early and revert one character
while(isspace(*src)) { // remove trailing space(s)
*src-- = 0; // terminate on trailing spaces
if(length-- == 0) break;
if(length) {
*src-- = 0; // terminate early and revert one character
while(isspace(*src)) { // remove trailing space(s)
*src-- = 0; // terminate on trailing spaces
if(length-- == 0) break;
}
}
return length;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Z_PRG_Agon-Rokky/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Program author
The source files in this test, are kindly provided by Alexander Sharikhin, downloaded from his [github](https://github.com/nihirash/Agon-rokky/tree/main) page and have been slightly altered to assemble using my test structure.

### LICENSE
Please see Alexander's [LICENSE](tests/LICENSE) for these files.
49 changes: 49 additions & 0 deletions tests/Z_PRG_Agon-Rokky/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
# Positive test - assembler needs to pass all tests in all subfolders
# return 0 on succesfull tests (all passed)
# return 1 on issue during test (one or more tests didn't pass correctly)
# return 2 on error in test SETUP
#

test_number=0
tests_successfull=0

cd tests
rm -f *.bin
for FILE in *; do
if [ -f "$FILE" ]; then
if [ "$FILE" == "${FILE%.*}.s" ]; then
test_number=$((test_number+1))
../$ASMBIN $FILE -b FF > ../asm.output
if [ $? -eq 1 ]; then
echo "$FILE ASM ERROR"
else
echo -n "$FILE ASM OK"
if [ -f ${FILE%.*}.expect ]; then
echo -n " - binary"
diff ${FILE%.*}.bin ${FILE%.*}.expect >/dev/null
if [ $? -eq 1 ]; then
echo " error"
else
echo " match"
tests_successfull=$((tests_successfull+1))
fi
else
echo ""
tests_successfull=$((tests_successfull+1))
fi
fi
fi
fi
done
rm -f *.bin
cd ..

rm -f asm.output
if [ $test_number -eq $tests_successfull ]; then
echo "All ($test_number) files assembled succesfully"
exit 0
else
exit 1
fi
exit 0
9 changes: 9 additions & 0 deletions tests/Z_PRG_Agon-Rokky/tests/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
If you are using Rokky, I'd love to hear about it.
Let me(Alexander Sharikhin) know by sending email to [email protected].

I'm crazy about coffee. If you treat me to delicious coffee - it will be awesome.

You may use all data from this project as you want.

But if you will use parts of this project - please keep this info about my love to
coffee(or buy me a cup of coffee at least).
127 changes: 127 additions & 0 deletions tests/Z_PRG_Agon-Rokky/tests/crt.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
ASSUME ADL=1
;; USE org $40000 for usual application
;; or $B0000 for MOS command
org $40000
jp _start
align 64
db "MOS" ; Header
db 00 ; Version
db 01 ; ADL
_start:
push ix
push iy

ld ix,argv
call _parse_args
ld a,c
ld (argc),a

call _main
pop iy
pop ix

ld hl,0
ret

_parse_args:
call _skip_spaces
ld bc,0
ld b,MAX_ARGS
_parse1:
push bc
push hl
call _get_token
ld a,c
pop de
pop bc
and a
ret z

ld (ix+0),de
push hl
pop de
call _skip_spaces
xor a
ld (de),a
inc ix
inc ix
inc ix
inc c
ld a, c
cp b
jr c,_parse1
ret

_get_token:
ld c,0
@loop:
ld a,(hl)
or a
ret z

cp 13
ret z

cp 32
ret z

inc hl
inc c
jr @loop

_skip_spaces:
ld a,(hl)
cp 32
ret nz
inc hl
jr _skip_spaces

argc: db 0
argv: ds 3*MAX_ARGS

;; Constants
mos_getkey: equ $00
mos_load: equ $01
mos_sysvars: equ $08
mos_editline: equ $09
mos_fopen: equ $0a
mos_fclose: equ $0b
mos_fgetc: equ $0c
mos_fputc: equ $0d
mos_feof: equ $0e
mos_uopen: equ $15
mos_setint: equ $14
mos_uclose: equ $16
mos_ugetc: equ $17
mos_uputc: equ $18
mos_fread: equ $1a
mos_fwrite: equ $1b


;; File modes
fa_read: equ $01
fa_write: equ $02
fa_exist: equ $00
fa_create: equ $04
fa_cr_always: equ $08
fa_op_always: equ $10
fa_append: equ $30

;; A - character to print
putc:
rst.lil $10
ret

;; HLU - pointer to string
printZ:
ld bc,0
xor a
rst.lil $18
ret

macro MOSCALL func
ld a, func
rst.lil $08
endmacro


Loading

0 comments on commit 9050b41

Please sign in to comment.