mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 14:58:06 +11:00
zasm emul: get rid of the kernel/user distinction
Made things complicated for nothing.
This commit is contained in:
parent
98695f9912
commit
d9fff16157
@ -36,7 +36,7 @@
|
|||||||
; fsGetC
|
; fsGetC
|
||||||
; fsSeek
|
; fsSeek
|
||||||
; fsTell
|
; fsTell
|
||||||
; RAMSTART (where we put our variables in RAM)
|
; ZASM_RAMSTART (where we put our variables in RAM)
|
||||||
; FS_HANDLE_SIZE
|
; FS_HANDLE_SIZE
|
||||||
|
|
||||||
; *** Variables ***
|
; *** Variables ***
|
||||||
@ -45,7 +45,7 @@
|
|||||||
; about actual output, but only about the length of each upcode. This means
|
; about actual output, but only about the length of each upcode. This means
|
||||||
; that when we parse instructions and directive that error out because of a
|
; that when we parse instructions and directive that error out because of a
|
||||||
; missing symbol, we don't error out and just write down a dummy value.
|
; missing symbol, we don't error out and just write down a dummy value.
|
||||||
.equ ZASM_FIRST_PASS RAMSTART
|
.equ ZASM_FIRST_PASS ZASM_RAMSTART
|
||||||
; whether we're in "local pass", that is, in local label scanning mode. During
|
; whether we're in "local pass", that is, in local label scanning mode. During
|
||||||
; this special pass, ZASM_FIRST_PASS will also be set so that the rest of the
|
; this special pass, ZASM_FIRST_PASS will also be set so that the rest of the
|
||||||
; code behaves as is we were in the first pass.
|
; code behaves as is we were in the first pass.
|
||||||
@ -54,9 +54,6 @@
|
|||||||
.equ ZASM_CTX_PC ZASM_LOCAL_PASS+1
|
.equ ZASM_CTX_PC ZASM_LOCAL_PASS+1
|
||||||
.equ ZASM_RAMEND ZASM_CTX_PC+2
|
.equ ZASM_RAMEND ZASM_CTX_PC+2
|
||||||
|
|
||||||
; *** Code ***
|
|
||||||
jp zasmMain
|
|
||||||
|
|
||||||
#include "zasm/util.asm"
|
#include "zasm/util.asm"
|
||||||
.equ IO_RAMSTART ZASM_RAMEND
|
.equ IO_RAMSTART ZASM_RAMEND
|
||||||
#include "zasm/io.asm"
|
#include "zasm/io.asm"
|
||||||
|
@ -2,6 +2,8 @@ TARGETS = shell/shell zasm/zasm runbin/runbin
|
|||||||
KERNEL_HEADERS = shell/kernel.h zasm/kernel.h
|
KERNEL_HEADERS = shell/kernel.h zasm/kernel.h
|
||||||
USER_HEADERS = zasm/user.h
|
USER_HEADERS = zasm/user.h
|
||||||
CFSPACK = ../cfspack/cfspack
|
CFSPACK = ../cfspack/cfspack
|
||||||
|
PARTS = ../../parts/z80
|
||||||
|
APPS = ../../apps
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(TARGETS)
|
all: $(TARGETS)
|
||||||
@ -9,10 +11,7 @@ all: $(TARGETS)
|
|||||||
shell/kernel.h: shell/shell_.asm
|
shell/kernel.h: shell/shell_.asm
|
||||||
zasm/kernel.h: zasm/glue.asm
|
zasm/kernel.h: zasm/glue.asm
|
||||||
$(KERNEL_HEADERS):
|
$(KERNEL_HEADERS):
|
||||||
scas -o - -I ../../parts/z80 $< | ./bin2c.sh KERNEL | tee $@ > /dev/null
|
scas -o - -I $(PARTS) -I $(APPS) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null
|
||||||
|
|
||||||
zasm/user.h: zasm/user.asm
|
|
||||||
scas -o - -I ../../apps $< | ./bin2c.sh USERSPACE | tee $@ > /dev/null
|
|
||||||
|
|
||||||
zasm/includes.cfs: $(CFSPACK)
|
zasm/includes.cfs: $(CFSPACK)
|
||||||
rm -rf zasm/includes
|
rm -rf zasm/includes
|
||||||
@ -27,7 +26,7 @@ zasm/includes.h: zasm/includes.cfs
|
|||||||
./bin2c.sh FSDEV < $< | tee $@ > /dev/null
|
./bin2c.sh FSDEV < $< | tee $@ > /dev/null
|
||||||
|
|
||||||
shell/shell: shell/shell.c libz80/libz80.o shell/kernel.h $(CFSPACK)
|
shell/shell: shell/shell.c libz80/libz80.o shell/kernel.h $(CFSPACK)
|
||||||
zasm/zasm: zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/user.h zasm/includes.h
|
zasm/zasm: zasm/zasm.c libz80/libz80.o zasm/kernel.h zasm/includes.h
|
||||||
runbin/runbin: runbin/runbin.c libz80/libz80.o
|
runbin/runbin: runbin/runbin.c libz80/libz80.o
|
||||||
$(TARGETS):
|
$(TARGETS):
|
||||||
cc $< libz80/libz80.o -o $@
|
cc $< libz80/libz80.o -o $@
|
||||||
|
@ -1,31 +1,12 @@
|
|||||||
; Glue code for the emulated environment
|
; Glue code for the emulated environment
|
||||||
.equ RAMSTART 0x4000
|
.equ RAMSTART 0x4000
|
||||||
.equ USER_CODE 0x4800
|
|
||||||
.equ STDIO_PORT 0x00
|
.equ STDIO_PORT 0x00
|
||||||
.equ STDIN_SEEK 0x01
|
.equ STDIN_SEEK 0x01
|
||||||
.equ FS_DATA_PORT 0x02
|
.equ FS_DATA_PORT 0x02
|
||||||
.equ FS_SEEK_PORT 0x03
|
.equ FS_SEEK_PORT 0x03
|
||||||
.equ STDERR_PORT 0x04
|
.equ STDERR_PORT 0x04
|
||||||
|
|
||||||
jp init ; 3 bytes
|
jp init
|
||||||
; *** JUMP TABLE ***
|
|
||||||
jp strncmp
|
|
||||||
jp addDE
|
|
||||||
jp addHL
|
|
||||||
jp upcase
|
|
||||||
jp unsetZ
|
|
||||||
jp intoDE
|
|
||||||
jp intoHL
|
|
||||||
jp writeHLinDE
|
|
||||||
jp findchar
|
|
||||||
jp parseHex
|
|
||||||
jp parseHexPair
|
|
||||||
jp blkSel
|
|
||||||
jp fsFindFN
|
|
||||||
jp fsOpen
|
|
||||||
jp fsGetC
|
|
||||||
jp fsSeek
|
|
||||||
jp fsTell
|
|
||||||
|
|
||||||
#include "core.asm"
|
#include "core.asm"
|
||||||
#include "parse.asm"
|
#include "parse.asm"
|
||||||
@ -40,11 +21,12 @@ jp fsTell
|
|||||||
.equ FS_RAMSTART BLOCKDEV_RAMEND
|
.equ FS_RAMSTART BLOCKDEV_RAMEND
|
||||||
.equ FS_HANDLE_COUNT 0
|
.equ FS_HANDLE_COUNT 0
|
||||||
#include "fs.asm"
|
#include "fs.asm"
|
||||||
|
.equ ZASM_RAMSTART FS_RAMEND
|
||||||
|
#include "zasm/main.asm"
|
||||||
|
|
||||||
init:
|
init:
|
||||||
di
|
di
|
||||||
; We put the stack at the end of the kernel memory
|
ld hl, 0xffff
|
||||||
ld hl, USER_CODE-1
|
|
||||||
ld sp, hl
|
ld sp, hl
|
||||||
ld a, 2 ; select fsdev
|
ld a, 2 ; select fsdev
|
||||||
ld de, BLOCKDEV_GETC
|
ld de, BLOCKDEV_GETC
|
||||||
@ -52,7 +34,7 @@ init:
|
|||||||
call fsOn
|
call fsOn
|
||||||
ld h, 0 ; input blkdev
|
ld h, 0 ; input blkdev
|
||||||
ld l, 1 ; output blkdev
|
ld l, 1 ; output blkdev
|
||||||
call USER_CODE
|
call zasmMain
|
||||||
; signal the emulator we're done
|
; signal the emulator we're done
|
||||||
halt
|
halt
|
||||||
|
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
; *** JUMP TABLE ***
|
|
||||||
strncmp .equ 0x03
|
|
||||||
addDE .equ 0x06
|
|
||||||
addHL .equ 0x09
|
|
||||||
upcase .equ 0x0c
|
|
||||||
unsetZ .equ 0x0f
|
|
||||||
intoDE .equ 0x12
|
|
||||||
intoHL .equ 0x15
|
|
||||||
writeHLinDE .equ 0x18
|
|
||||||
findchar .equ 0x1b
|
|
||||||
parseHex .equ 0x1e
|
|
||||||
parseHexPair .equ 0x21
|
|
||||||
blkSel .equ 0x24
|
|
||||||
fsFindFN .equ 0x27
|
|
||||||
fsOpen .equ 0x2a
|
|
||||||
fsGetC .equ 0x2d
|
|
||||||
fsSeek .equ 0x30
|
|
||||||
fsTell .equ 0x33
|
|
||||||
|
|
||||||
.equ FS_HANDLE_SIZE 8
|
|
||||||
.equ STDERR_PORT 0x04
|
|
||||||
.equ USER_CODE 0x4800
|
|
||||||
.equ RAMSTART 0x5800
|
|
||||||
.org USER_CODE
|
|
||||||
|
|
||||||
call zasmMain
|
|
||||||
;call dumpSymTable
|
|
||||||
ret
|
|
||||||
|
|
||||||
#include "zasm/main.asm"
|
|
||||||
|
|
||||||
; *** Debug ***
|
|
||||||
debugPrint:
|
|
||||||
push af
|
|
||||||
push hl
|
|
||||||
.loop:
|
|
||||||
ld a, (hl)
|
|
||||||
or a
|
|
||||||
jr z, .end
|
|
||||||
out (STDERR_PORT), a
|
|
||||||
inc hl
|
|
||||||
jr .loop
|
|
||||||
.end:
|
|
||||||
ld a, 0x0a
|
|
||||||
out (STDERR_PORT), a
|
|
||||||
pop hl
|
|
||||||
pop af
|
|
||||||
ret
|
|
||||||
|
|
||||||
dumpSymTable:
|
|
||||||
ld hl, SYM_NAMES
|
|
||||||
ld de, SYM_VALUES
|
|
||||||
.loop:
|
|
||||||
call debugPrint
|
|
||||||
ld a, (de)
|
|
||||||
out (12), a
|
|
||||||
inc de
|
|
||||||
ld a, (de)
|
|
||||||
out (12), a
|
|
||||||
inc de
|
|
||||||
xor a
|
|
||||||
call findchar
|
|
||||||
inc hl
|
|
||||||
ld a, (hl)
|
|
||||||
or a
|
|
||||||
ret z
|
|
||||||
jr .loop
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "../libz80/z80.h"
|
#include "../libz80/z80.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "user.h"
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
/* zasm reads from a specified blkdev, assemble the file and writes the result
|
/* zasm reads from a specified blkdev, assemble the file and writes the result
|
||||||
@ -26,7 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// in sync with zasm_glue.asm
|
// in sync with zasm_glue.asm
|
||||||
#define USER_CODE 0x4800
|
|
||||||
#define STDIO_PORT 0x00
|
#define STDIO_PORT 0x00
|
||||||
#define STDIN_SEEK_PORT 0x01
|
#define STDIN_SEEK_PORT 0x01
|
||||||
#define FS_DATA_PORT 0x02
|
#define FS_DATA_PORT 0x02
|
||||||
@ -152,9 +150,6 @@ int main()
|
|||||||
for (int i=0; i<sizeof(KERNEL); i++) {
|
for (int i=0; i<sizeof(KERNEL); i++) {
|
||||||
mem[i] = KERNEL[i];
|
mem[i] = KERNEL[i];
|
||||||
}
|
}
|
||||||
for (int i=0; i<sizeof(USERSPACE); i++) {
|
|
||||||
mem[i+USER_CODE] = USERSPACE[i];
|
|
||||||
}
|
|
||||||
for (int i=0; i<sizeof(FSDEV); i++) {
|
for (int i=0; i<sizeof(FSDEV); i++) {
|
||||||
fsdev[i] = FSDEV[i];
|
fsdev[i] = FSDEV[i];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user