1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 12:58:06 +11:00

zasm: have a whole kernel in emulation instead of a simple wrapper

zasm is going to need to call to kernel code...
This commit is contained in:
Virgil Dupras 2019-04-16 14:26:45 -04:00
parent 43c1005d61
commit 88cee235b1
5 changed files with 35 additions and 29 deletions

View File

@ -1,4 +1,4 @@
libz80
wrapper.h
kernel.h
zasm.h
zasm

View File

@ -1,11 +1,11 @@
zasm: zasm.c libz80/libz80.so wrapper.h zasm.h
zasm: zasm.c libz80/libz80.so kernel.h zasm.h
cc $< -l z80 -L./libz80 -Wl,-rpath ./libz80 -o $@
libz80/libz80.so: libz80/Makefile
make -C libz80
wrapper.h: wrapper.asm
scas -o - $< | ./bin2c.sh WRAPPER > $@
kernel.h: glue.asm
scas -o - $< | ./bin2c.sh KERNEL > $@
zasm.h: ../zasm.asm
scas -o - $< | ./bin2c.sh ZASM > $@

22
apps/zasm/emul/glue.asm Normal file
View File

@ -0,0 +1,22 @@
; Glue code for the emulated environment
RAMSTART .equ 0x8000
RAMEND .equ 0xffff
ZASM_CODE .equ RAMSTART
ZASM_INPUT .equ 0xa000
ZASM_OUTPUT .equ 0xd000
jr init
init:
di
ld hl, RAMEND
ld sp, hl
ld hl, ZASM_INPUT
ld de, ZASM_OUTPUT
call ZASM_CODE
; signal the emulator we're done
; BC contains the number of written bytes
ld a, b
out (c), a
halt
#include "core.asm"

View File

@ -1,15 +0,0 @@
; setup the stack
ld hl, 0xffff
ld sp, hl
; zasm input
ld hl, 0x9000
; zasm output
ld de, 0xc000
call zasm
; signal the emulator we're done
; BC contains the number of written bytes
ld a, b
out (c), a
halt
zasm:
; beginning of the code

View File

@ -1,7 +1,7 @@
#include <stdint.h>
#include <stdio.h>
#include "libz80/z80.h"
#include "wrapper.h"
#include "kernel.h"
#include "zasm.h"
/* zasm is a "pure memory" application. It starts up being told memory location
@ -12,9 +12,10 @@
* spit the contents of the dest memory to stdout.
*/
// in sync with wrapper.asm
#define READFROM 0x9000
#define WRITETO 0xc000
// in sync with glue.asm
#define READFROM 0xa000
#define WRITETO 0xd000
#define ZASM_CODE_OFFSET 0x8000
static Z80Context cpu;
static uint8_t mem[0xffff];
@ -48,13 +49,11 @@ static void mem_write(int unused, uint16_t addr, uint8_t val)
int main()
{
// initialize memory
int wrapperlen = sizeof(WRAPPER);
for (int i=0; i<wrapperlen; i++) {
mem[i] = WRAPPER[i];
for (int i=0; i<sizeof(KERNEL); i++) {
mem[i] = KERNEL[i];
}
int zasm = sizeof(ZASM);
for (int i=0; i<zasm; i++) {
mem[i+wrapperlen] = ZASM[i];
for (int i=0; i<sizeof(ZASM); i++) {
mem[i+ZASM_CODE_OFFSET] = ZASM[i];
}
int ptr = READFROM;
int c = getchar();