Skip to content

Commit

Permalink
fix/mainargs with "
Browse files Browse the repository at this point in the history
  • Loading branch information
jedeoric committed Jun 4, 2024
1 parent 71970fe commit 52e915c
Show file tree
Hide file tree
Showing 15 changed files with 176 additions and 54 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ jobs:
git clone https://github.com/orix-software/docker-unit-test.git
cd docker-unit-test && bash install.sh ${GITHUB_WORKSPACE} && cd ..
cp build/usr/share/kernel/kernelsd.rom ${GITHUB_WORKSPACE}/oricutron/roms/kernel.rom
cat tests/unit_test/xopen.sub > ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT
cat tests/unit_test/xrm.sub >> ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT
cat tests/unit_test/xopen.sub > ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT
cat tests/unit_test/xrm.sub >> ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT
cp mainarg ${GITHUB_WORKSPACE}/oricutron/sdcard/BIN
cat mainarg >> ${GITHUB_WORKSPACE}/oricutron/sdcard/ETC/AUTOBOOT
cd ${GITHUB_WORKSPACE}/oricutron
timeout --preserve-status 5 ./xvfb.sh || exit 0
timeout --preserve-status 10 ./xvfb.sh || exit 0
- name: Check unit-test
run: |
Expand Down
51 changes: 26 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ SOURCE=src/kernel.asm
PROGRAM_NAME=kernel

ifeq ($(CC65_HOME),)
CC = cl65
AS = ca65
LD = ld65
AR = ar65
CC = cl65
AS = ca65
LD = ld65
AR = ar65
else
CC = $(CC65_HOME)/bin/cl65
AS = $(CC65_HOME)/bin/ca65
LD = $(CC65_HOME)/bin/ld65
AR = $(CC65_HOME)/bin/ar65
CC = $(CC65_HOME)/bin/cl65
AS = $(CC65_HOME)/bin/ca65
LD = $(CC65_HOME)/bin/ld65
AR = $(CC65_HOME)/bin/ar65
endif

PATH_PACKAGE_ROM=build/usr/share/$(PROGRAM_NAME)/
Expand All @@ -37,8 +37,8 @@ init:
kernel: $(SOURCE)
@echo Rom are built in $(PATH_PACKAGE_ROM)
@echo Build kernelsd.rom for Twilighte board
@$(AS) --verbose -s -tnone --debug-info -o kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log
@$(LD) -C src/kernel.cfg kernelsd.ld65 -m kernelsd.map -DWITH_SDCARD_FOR_ROOT=1 -DWITH_TWILIGHTE_BOARD=1 -Ln kernelsd.sym > output.log
@$(AS) --verbose -s -tnone --debug-info -o kernelsd.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > output.log
@$(LD) -C src/kernel.cfg kernelsd.ld65 -m kernelsd.map -DWITH_SDCARD_FOR_ROOT=1 -DWITH_TWILIGHTE_BOARD=1 -Ln kernelsd.sym > output.log
@cp kernel.rom kernelsd.rom
@sed -re 's/al 00(.{4}) \.(.+)$$/\1 \2/' kernelsd.sym| sort > kernelsd2.sym > output.log
@cp kernelsd.rom $(PATH_PACKAGE_ROM)/
Expand All @@ -48,29 +48,30 @@ kernel: $(SOURCE)
@echo Build kernelus.rom for Twilighte board
@echo "WITH_TWILIGHTE_BOARD">$(PATH_PACKAGE_ROM)/kernelus.lst
@$(AS) --verbose -s -tnone --debug-info -o kernelus.ld65 $(SOURCE) $(ASFLAGS) > output.log
@$(LD) -C src/kernel.cfg kernelus.ld65 -m kernelus.map -DWITH_TWILIGHTE_BOARD=1 -Ln kernelus.sym > output.log
@$(LD) -C src/kernel.cfg kernelus.ld65 -m kernelus.map -DWITH_TWILIGHTE_BOARD=1 -Ln kernelus.sym > output.log
@cp kernel.rom kernelus.rom
@cp kernelus.rom $(PATH_PACKAGE_ROM)/

unittest:
$(CC) $(CFLAGS) tests/mkdir.c -o tmkdir
$(CC) $(CFLAGS) tests/fwrite.c -o tfwrite
@$(CC) $(CFLAGS) tests/mkdir.c -o tmkdir
@$(CC) $(CFLAGS) tests/fwrite.c -o tfwrite
@$(CC) $(CFLAGS) tests/unit_test/mainarg.s -o mainarg

memmap:
@$(AS) --verbose -s -tnone --debug-info -o kernel-telestrat.ld65 -DWITH_SDCARD_FOR_ROOT=1 $(SOURCE) $(ASFLAGS) > memmap.md
@$(LD) -C src/kernel.cfg kernel-telestrat.ld65 -m kernel.map -o kernel-telestrat.ld65.rom -DWITH_ACIA=2 -DWITH_SDCARD_FOR_ROOT=1 -Ln kernel-telestrat.ca.sym
sh generate_memmap.sh
@sh generate_memmap.sh

test:
cp Makefile build/usr/src/kernel/
cp README.md build/usr/src/kernel/
cp src/* build/usr/src/kernel/ -adpR
cp README.md build/usr/share/doc/$(PROGRAM_NAME)/
ls -l $(HOMEDIR)
export ORIX_PATH=`pwd`
sh tools/builddocs.sh
cd build && tar -c * > ../$(PROGRAM_NAME).tar && cd ..
filepack $(PROGRAM_NAME).tar $(PROGRAM_NAME).pkg
gzip $(PROGRAM_NAME).tar
mv $(PROGRAM_NAME).tar.gz $(PROGRAM_NAME).tgz
@cp Makefile build/usr/src/kernel/
@cp README.md build/usr/src/kernel/
@cp src/* build/usr/src/kernel/ -adpR
@cp README.md build/usr/share/doc/$(PROGRAM_NAME)/
@ls -l $(HOMEDIR)
@export ORIX_PATH=`pwd`
@sh tools/builddocs.sh
@cd build && tar -c * > ../$(PROGRAM_NAME).tar && cd ..
@filepack $(PROGRAM_NAME).tar $(PROGRAM_NAME).pkg
@gzip $(PROGRAM_NAME).tar
@mv $(PROGRAM_NAME).tar.gz $(PROGRAM_NAME).tgz

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.1
2024.3
2 changes: 1 addition & 1 deletion docs/memmap_ram.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
## Page 4
|Type | Name | Range | Size |
| :------- |:----------------------------- |:----------- |:-----|
|RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 |
|RAM|page4 overlay_access | $0419-$0436 | 54 |
|RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0411 | 3 |
## Page 5&6
|Type | Name | Range | Size |
| :------- |:----------------------------- |:----------- |:-----|
Expand Down
8 changes: 4 additions & 4 deletions memmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ CALL:XOPEN:XRM_ROUTINE
|##MEMMAP: Page 4
|MEMMAP:Type | Name | Range | Size |
|MEMMAP: :------- |:----------------------------- |:----------- |:-----|
|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0414 | 3 |
|MEMMAP:RAM|page4 overlay_access | $0419-$0436 | 54 |
|MEMMAP:RAM|page4 ORIX_VECTOR_READ_VALUE_INTO_RAM_OVERLAY | $0411-$0411 | 3 |
|##MEMMAP: Page 5&6
|MEMMAP:Type | Name | Range | Size |
|MEMMAP: :------- |:----------------------------- |:----------- |:-----|
Expand All @@ -371,12 +371,12 @@ CALL:XOPEN:XRM_ROUTINE
|##MEMMAP: Kernel bank 7
|MEMMAP: Type | Name | Range | Size |
|MEMMAP: :-------- |:---------------------------- |:------- |:-----|
|MEMMAP:ROM|FREE |$feee-$fff0| 258 |
|MEMMAP:ROM|FREE |$ff0e-$fff0| 226 |
|##MEMMAP: Bank 0
|MEMMAP: Type | Name | Range | Size |
|MEMMAP: -------- | ---------------------------- | ------- |-----|
|MEMMAP:BANK0|BUFBUF | $c080-$c0b6 | 54 |
|MEMMAP:BANK0|BUFROU | $c500-$c54e | |
|MEMMAP:BANK0|TELEMON_KEYBOARD_BUFFER_BEGIN | $c5c4-$c680 | |
|MEMMAP:BANK0|XMALLOC (copy from kernel) | $fba0-$fc4c | |
|MEMMAP:BANK0|XFREE (copy from kernel) | $fc4c-$fed1 | |
|MEMMAP:BANK0|XMALLOC (copy from kernel) | $fbc0-$fc6c | |
|MEMMAP:BANK0|XFREE (copy from kernel) | $fc6c-$fef1 | |
15 changes: 12 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ ld65 -C src/kernel.cfg -DWITH_SDCARD_FOR_ROOT=1 tmp/kernelsd.ld65 -Ln tmp/kerne
#cl65 -ttelestrat -C tests/orix-sdk/cfg/telestrat_900.cfg tests/multiples_files_opened.c tests/multiples_files_fopen.s tests/exec.s -o multi
#cl65 -ttelestrat -C tests/orix-sdk/cfg/telestrat_900.cfg tests/readdir.c tests/kernel_calls/readdir_extern.s -o b

ca65 --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 --verbose -s -ttelestrat src/kdebug.asm -o kdebugsd.ld65 --debug-info
ld65 -tnone -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 kdebugsd.ld65 -o kdebug.rom -Ln kdebugsd.sym -m memmap.txt -vm
#ca65 --cpu 6502 -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 --verbose -s -ttelestrat src/kdebug.asm -o kdebugsd.ld65 --debug-info
#ld65 -tnone -DWITH_SDCARD_FOR_ROOT=1 -DWITH_DEBUG=1 kdebugsd.ld65 -o kdebug.rom -Ln kdebugsd.sym -m memmap.txt -vm

cp kernel.rom $ORICUTRON_PATH/roms
# cp kdebug.rom $ORICUTRON_PATH/roms
Expand All @@ -25,7 +25,16 @@ cp tests/test_kernel $ORICUTRON_PATH/sdcard/bin/test
#cp tests/kopened $ORICUTRON_PATH/sdcard/bin/

#cat tests/unit_test/xopen.sub > $ORICUTRON_PATH/sdcard/etc/AUTOBOOT
#cat tests/unit_test/xrm.sub >> $ORICUTRON_PATH/sdcard/etc/AUTOBOOT
cat tests/unit_test/start.sub >> $ORICUTRON_PATH/sdcard/etc/AUTOBOOT

cp tests/unit_test/mainarg.sub $ORICUTRON_PATH/sdcard/bin/mainarg.sub

cl65 -ttelestrat tests/unit_test/mainarg.s -o 1000 --start-addr 2048
cl65 -ttelestrat tests/unit_test/mainarg.s -o 1256 --start-addr 2304
dependencies/orix-sdk/bin/relocbin.py3 -o mainarg -2 1000 1256


cp mainarg $ORICUTRON_PATH/sdcard/bin/mainarg

cd $ORICUTRON_PATH
./oricutron
Expand Down
1 change: 1 addition & 0 deletions src/functions/init_screen.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
bpl @loop

ldy #$05 ; loop with $12 to fill text definitions and Hires

@L1:
lda data_text_window,y ; data_to_define_2
sta SCRTXT,y ; thise fill also SCRHIR
Expand Down
64 changes: 53 additions & 11 deletions src/functions/mainargs.asm
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,34 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte

.proc XMAINARGS_ROUTINE

;;@brief Build a mainargs array and returns in A and Y the ptr (malloc)
;;@inputA Mode (0 or 1)
;;@inputX High ptr curl struct
;;@modifyMEM_RES
;;@modifyMEM_RESB
;;@modifyMEM_TR0
;;@modifyMEM_TR1
;;@modifyMEM_TR2
;;@modifyMEM_TR3
;;@modifyMEM_TR4
;;@modifyMEM_KERNEL_ERRNO

sta XMAINARGS_MODE

; Get current process
ldx kernel_process+kernel_process_struct::kernel_current_process
; Get the struct og the process
jsr kernel_get_struct_process_ptr
sta RES
sty RES+1

lda RES
; Compute cmdline offset
lda RES ; FIXME A is already populated
clc
adc #kernel_one_process_struct::cmdline ; 1 : number of args
bcc @S7
inc RES+1

@S7:
sta RES

Expand Down Expand Up @@ -73,6 +89,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte
; Mode 1 : Copy only

ldy #$00

@loop2:
lda (RES),y
beq @out2
Expand Down Expand Up @@ -104,6 +121,7 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte
adc RESB
bcc @S3
inc XMAINARGSV+1

@S3:
sta XMAINARGSV ; TR2 contains the first offset

Expand All @@ -124,16 +142,28 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte
beq @out
cmp #' '
beq @new_arg
cmp #$22 ; Is it '"' ?
cmp #'"' ; Is it '"' ?
bne @not_double_quote

lda XMAINARGS_DOUBLE_QUOTE
lda XMAINARGS_DOUBLE_QUOTE ; If equal two 0, it " is found here, let's
beq @begin_double_quote

inc XMAINARGS_DOUBLE_QUOTE
; End of double quote found, close param
bne @out

@begin_double_quote:
inc XMAINARGS_DOUBLE_QUOTE

lda RES
clc
adc #$01
bcc @no_inc
inc RES+1

@no_inc:
sta RES
jsr @init_param
jmp @loop

@not_double_quote:
; store the string
Expand All @@ -151,17 +181,34 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte

ldx XMAINARGSC
; return ptr
lda RESB ; $7C9
lda RESB
ldy RESB+1
rts

@new_arg:
ldx XMAINARGS_DOUBLE_QUOTE
beq @double_quote_not_opened

; At this step we found a space in a " sentence
; A contains " "
sta (XMAINARGSV),y
jmp @no_new_arg

@double_quote_not_opened:
lda XMAINARGS_SPACEFOUND
bne @no_new_arg

lda #$01
sta XMAINARGS_SPACEFOUND

jsr @init_param
inc XMAINARGSC

@no_new_arg:
iny
jmp @loop

@init_param:
lda #$00
sta (XMAINARGSV),y

Expand All @@ -176,10 +223,5 @@ XMAINARGS_DOUBLE_QUOTE := TR5 ; 1 byte
txa
tay

inc XMAINARGSC

@no_new_arg:
iny
jmp @loop

rts
.endproc
3 changes: 1 addition & 2 deletions src/include/libs/ch376_verify.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
cmp #CH376_DETECTED
beq @detected



; let's start reset
jsr _ch376_reset_all
lda #$01 ; error
rts

@detected:
jsr _ch376_set_usb_mode_kernel

Expand Down
2 changes: 1 addition & 1 deletion src/kernel.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
adc #$01
.endmacro

.define VERSION "2024.1"
.define VERSION "2024.3"

XMALLOC_ROUTINE_TO_RAM_OVERLAY = 39

Expand Down
59 changes: 59 additions & 0 deletions tests/unit_test/mainarg.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
; Code to test XMAINARGS

.include "telestrat.inc"
.include "../../dependencies/orix-sdk/macros/SDK_mainargs.mac"
.include "../../dependencies/orix-sdk/macros/SDK_print.mac"
.include "../../dependencies/orix-sdk/macros/SDK_conio.mac"

.segment "STARTUP"
.segment "INIT"
.segment "ONCE"

.segment "CODE"
_main:

userzp := $80

start_adress:
argv := userzp ; 2 bytes
argc := userzp + 2 ; 1 byte

initmainargs argv, argc, 0


nop
lda argc
cmp #$03
bne @no_arg
nop
nop

nop

nop
getmainarg #1, (argv)
BRK_TELEMON XWSTR0
crlf
nop
nop

nop

nop
getmainarg #2, (argv)
BRK_TELEMON XWSTR0
crlf

rts
nop
@no_arg:
print str_there_not_two_arg
lda #$01
ldy #$00
rts

str_there_not_two_arg:
.asciiz "There is not 2 arg"


lda #$41
4 changes: 4 additions & 0 deletions tests/unit_test/mainarg.sub
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/submit
echo Mainarg test
mainarg ici "part1 part2"
#on error echo error
Loading

0 comments on commit 52e915c

Please sign in to comment.