Sfoglia il codice sorgente

zasm emul: get rid of the kernel/user distinction

Made things complicated for nothing.
pull/10/head
Virgil Dupras 5 anni fa
parent
commit
d9fff16157
5 ha cambiato i file con 11 aggiunte e 106 eliminazioni
  1. +2
    -5
      apps/zasm/main.asm
  2. +4
    -5
      tools/emul/Makefile
  3. +5
    -23
      tools/emul/zasm/glue.asm
  4. +0
    -68
      tools/emul/zasm/user.asm
  5. +0
    -5
      tools/emul/zasm/zasm.c

+ 2
- 5
apps/zasm/main.asm Vedi File

@@ -36,7 +36,7 @@
; fsGetC
; fsSeek
; fsTell
; RAMSTART (where we put our variables in RAM)
; ZASM_RAMSTART (where we put our variables in RAM)
; FS_HANDLE_SIZE

; *** Variables ***
@@ -45,7 +45,7 @@
; 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
; 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
; 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.
@@ -54,9 +54,6 @@
.equ ZASM_CTX_PC ZASM_LOCAL_PASS+1
.equ ZASM_RAMEND ZASM_CTX_PC+2

; *** Code ***
jp zasmMain

#include "zasm/util.asm"
.equ IO_RAMSTART ZASM_RAMEND
#include "zasm/io.asm"


+ 4
- 5
tools/emul/Makefile Vedi File

@@ -2,6 +2,8 @@ TARGETS = shell/shell zasm/zasm runbin/runbin
KERNEL_HEADERS = shell/kernel.h zasm/kernel.h
USER_HEADERS = zasm/user.h
CFSPACK = ../cfspack/cfspack
PARTS = ../../parts/z80
APPS = ../../apps

.PHONY: all
all: $(TARGETS)
@@ -9,10 +11,7 @@ all: $(TARGETS)
shell/kernel.h: shell/shell_.asm
zasm/kernel.h: zasm/glue.asm
$(KERNEL_HEADERS):
scas -o - -I ../../parts/z80 $< | ./bin2c.sh KERNEL | tee $@ > /dev/null

zasm/user.h: zasm/user.asm
scas -o - -I ../../apps $< | ./bin2c.sh USERSPACE | tee $@ > /dev/null
scas -o - -I $(PARTS) -I $(APPS) $< | ./bin2c.sh KERNEL | tee $@ > /dev/null

zasm/includes.cfs: $(CFSPACK)
rm -rf zasm/includes
@@ -27,7 +26,7 @@ zasm/includes.h: zasm/includes.cfs
./bin2c.sh FSDEV < $< | tee $@ > /dev/null
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
$(TARGETS):
cc $< libz80/libz80.o -o $@


+ 5
- 23
tools/emul/zasm/glue.asm Vedi File

@@ -1,31 +1,12 @@
; Glue code for the emulated environment
.equ RAMSTART 0x4000
.equ USER_CODE 0x4800
.equ STDIO_PORT 0x00
.equ STDIN_SEEK 0x01
.equ FS_DATA_PORT 0x02
.equ FS_SEEK_PORT 0x03
.equ STDERR_PORT 0x04

jp init ; 3 bytes
; *** 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
jp init

#include "core.asm"
#include "parse.asm"
@@ -40,11 +21,12 @@ jp fsTell
.equ FS_RAMSTART BLOCKDEV_RAMEND
.equ FS_HANDLE_COUNT 0
#include "fs.asm"
.equ ZASM_RAMSTART FS_RAMEND
#include "zasm/main.asm"

init:
di
; We put the stack at the end of the kernel memory
ld hl, USER_CODE-1
ld hl, 0xffff
ld sp, hl
ld a, 2 ; select fsdev
ld de, BLOCKDEV_GETC
@@ -52,7 +34,7 @@ init:
call fsOn
ld h, 0 ; input blkdev
ld l, 1 ; output blkdev
call USER_CODE
call zasmMain
; signal the emulator we're done
halt



+ 0
- 68
tools/emul/zasm/user.asm Vedi File

@@ -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


+ 0
- 5
tools/emul/zasm/zasm.c Vedi File

@@ -2,7 +2,6 @@
#include <stdio.h>
#include "../libz80/z80.h"
#include "kernel.h"
#include "user.h"
#include "includes.h"

/* zasm reads from a specified blkdev, assemble the file and writes the result
@@ -26,7 +25,6 @@
*/

// in sync with zasm_glue.asm
#define USER_CODE 0x4800
#define STDIO_PORT 0x00
#define STDIN_SEEK_PORT 0x01
#define FS_DATA_PORT 0x02
@@ -152,9 +150,6 @@ int main()
for (int i=0; i<sizeof(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++) {
fsdev[i] = FSDEV[i];
}


Loading…
Annulla
Salva