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:
parent
43c1005d61
commit
88cee235b1
2
apps/zasm/emul/.gitignore
vendored
2
apps/zasm/emul/.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
libz80
|
libz80
|
||||||
wrapper.h
|
kernel.h
|
||||||
zasm.h
|
zasm.h
|
||||||
zasm
|
zasm
|
||||||
|
@ -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 $@
|
cc $< -l z80 -L./libz80 -Wl,-rpath ./libz80 -o $@
|
||||||
|
|
||||||
libz80/libz80.so: libz80/Makefile
|
libz80/libz80.so: libz80/Makefile
|
||||||
make -C libz80
|
make -C libz80
|
||||||
|
|
||||||
wrapper.h: wrapper.asm
|
kernel.h: glue.asm
|
||||||
scas -o - $< | ./bin2c.sh WRAPPER > $@
|
scas -o - $< | ./bin2c.sh KERNEL > $@
|
||||||
|
|
||||||
zasm.h: ../zasm.asm
|
zasm.h: ../zasm.asm
|
||||||
scas -o - $< | ./bin2c.sh ZASM > $@
|
scas -o - $< | ./bin2c.sh ZASM > $@
|
||||||
|
22
apps/zasm/emul/glue.asm
Normal file
22
apps/zasm/emul/glue.asm
Normal 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"
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "libz80/z80.h"
|
#include "libz80/z80.h"
|
||||||
#include "wrapper.h"
|
#include "kernel.h"
|
||||||
#include "zasm.h"
|
#include "zasm.h"
|
||||||
|
|
||||||
/* zasm is a "pure memory" application. It starts up being told memory location
|
/* 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.
|
* spit the contents of the dest memory to stdout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// in sync with wrapper.asm
|
// in sync with glue.asm
|
||||||
#define READFROM 0x9000
|
#define READFROM 0xa000
|
||||||
#define WRITETO 0xc000
|
#define WRITETO 0xd000
|
||||||
|
#define ZASM_CODE_OFFSET 0x8000
|
||||||
|
|
||||||
static Z80Context cpu;
|
static Z80Context cpu;
|
||||||
static uint8_t mem[0xffff];
|
static uint8_t mem[0xffff];
|
||||||
@ -48,13 +49,11 @@ static void mem_write(int unused, uint16_t addr, uint8_t val)
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// initialize memory
|
// initialize memory
|
||||||
int wrapperlen = sizeof(WRAPPER);
|
for (int i=0; i<sizeof(KERNEL); i++) {
|
||||||
for (int i=0; i<wrapperlen; i++) {
|
mem[i] = KERNEL[i];
|
||||||
mem[i] = WRAPPER[i];
|
|
||||||
}
|
}
|
||||||
int zasm = sizeof(ZASM);
|
for (int i=0; i<sizeof(ZASM); i++) {
|
||||||
for (int i=0; i<zasm; i++) {
|
mem[i+ZASM_CODE_OFFSET] = ZASM[i];
|
||||||
mem[i+wrapperlen] = ZASM[i];
|
|
||||||
}
|
}
|
||||||
int ptr = READFROM;
|
int ptr = READFROM;
|
||||||
int c = getchar();
|
int c = getchar();
|
||||||
|
Loading…
Reference in New Issue
Block a user