Working bios added to rom
This commit is contained in:
+20
-5
@@ -1,10 +1,11 @@
|
|||||||
.SILENT:
|
.SILENT:
|
||||||
|
include memory.mk
|
||||||
|
|
||||||
ASM := zasm
|
ASM := zasm
|
||||||
ASMFLAGS := -w -b
|
ASMFLAGS := -w -b
|
||||||
BUILDDIR := build
|
BUILDDIR := build
|
||||||
|
|
||||||
FILES := bios
|
FILES := bios
|
||||||
SUBDIRS := apps/basic
|
|
||||||
|
|
||||||
SOURCES := $(addprefix ./, $(addsuffix .asm, $(FILES)))
|
SOURCES := $(addprefix ./, $(addsuffix .asm, $(FILES)))
|
||||||
TARGETS := $(addprefix $(BUILDDIR)/, $(addsuffix .bin, $(FILES)))
|
TARGETS := $(addprefix $(BUILDDIR)/, $(addsuffix .bin, $(FILES)))
|
||||||
@@ -12,7 +13,7 @@ TARGETS := $(addprefix $(BUILDDIR)/, $(addsuffix .bin, $(FILES))
|
|||||||
TOPTARGETS := all clean size
|
TOPTARGETS := all clean size
|
||||||
$(TOPTARGETS): $(SUBDIRS)
|
$(TOPTARGETS): $(SUBDIRS)
|
||||||
|
|
||||||
all: $(BUILDDIR) $(TARGETS) size
|
all: $(BUILDDIR) $(BUILDDIR)/rom.bin size
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILDDIR)
|
rm -rf $(BUILDDIR)
|
||||||
@@ -20,7 +21,7 @@ clean:
|
|||||||
$(BUILDDIR):
|
$(BUILDDIR):
|
||||||
mkdir -p $(BUILDDIR)
|
mkdir -p $(BUILDDIR)
|
||||||
|
|
||||||
$(BUILDDIR)/%.bin: ./%.asm
|
$(BUILDDIR)/%.bin: ./%.asm $(BUILDDIR)/memory.inc
|
||||||
echo '>$<'
|
echo '>$<'
|
||||||
$(ASM) $(ASMFLAGS) $< $@
|
$(ASM) $(ASMFLAGS) $< $@
|
||||||
|
|
||||||
@@ -32,9 +33,23 @@ size:
|
|||||||
echo "$$file: Not built yet (run 'make')"; \
|
echo "$$file: Not built yet (run 'make')"; \
|
||||||
fi \
|
fi \
|
||||||
done
|
done
|
||||||
|
$(MAKE) -C apps/basic size --no-print-directory
|
||||||
|
|
||||||
|
$(BUILDDIR)/basic.bin:
|
||||||
|
$(MAKE) -C apps/basic $(or $(MAKECMDGOALS),all) --no-print-directory
|
||||||
|
|
||||||
|
$(BUILDDIR)/memory.inc: memory.mk
|
||||||
|
@mkdir -p $(@D)
|
||||||
|
@awk 'BEGIN { print "; Generated from rom_layout.mk; do not edit." } \
|
||||||
|
/^[A-Z][A-Z0-9_]*[[:space:]]*:=[[:space:]]*/ { print $$1 " .equ " $$3 }' $< > $@
|
||||||
|
|
||||||
|
$(BUILDDIR)/rom.bin: $(BUILDDIR)/bios.bin $(BUILDDIR)/basic.bin
|
||||||
|
objcopy --pad-to=$$(($(BIOS_ROM_START)+$(BIOS_ROM_SIZE))) \
|
||||||
|
-I binary $(BUILDDIR)/bios.bin -O binary $(BUILDDIR)/bios_padded.bin
|
||||||
|
objcopy --pad-to=$(BASIC_ROM_SIZE) \
|
||||||
|
-I binary $(BUILDDIR)/basic.bin -O binary $(BUILDDIR)/basic_padded.bin
|
||||||
|
cat $(BUILDDIR)/bios_padded.bin $(BUILDDIR)/basic_padded.bin > $(BUILDDIR)/rom.bin
|
||||||
|
|
||||||
$(SUBDIRS):
|
|
||||||
$(MAKE) -C $@ $(or $(MAKECMDGOALS),all) --no-print-directory
|
|
||||||
|
|
||||||
.PHONY: $(TOPTARGETS) $(SUBDIRS)
|
.PHONY: $(TOPTARGETS) $(SUBDIRS)
|
||||||
|
|
||||||
|
|||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
Rom map:
|
||||||
|
+----------+ 0000
|
||||||
|
| BIOS |
|
||||||
|
+----------+ 0400
|
||||||
|
| BASIC |
|
||||||
|
+----------+ 2400
|
||||||
|
|
||||||
|
Bios copies itself and basic to the top 16k which then look like:
|
||||||
|
+----------+ c000
|
||||||
|
| INT VEC |
|
||||||
|
+----------+ c050
|
||||||
|
| BIOS API |
|
||||||
|
+----------+
|
||||||
|
| BIOS |
|
||||||
|
+----------+ c400
|
||||||
|
| BIOS VAR |
|
||||||
|
+----------+ c800
|
||||||
|
| BASIC |
|
||||||
|
+----------+ e800
|
||||||
|
| BASIC WS |
|
||||||
|
| .... |
|
||||||
|
| BASIC ST |
|
||||||
|
+----------+ ffff
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
.SILENT:
|
.SILENT:
|
||||||
ASM := zasm
|
ASM := zasm
|
||||||
ASMFLAGS := -w -b
|
ASMFLAGS := -w -b
|
||||||
BUILDDIR := ../../build/basic
|
BUILDDIR := ../../build
|
||||||
|
|
||||||
FILES := basic
|
FILES := basic
|
||||||
SUBDIRS :=
|
SUBDIRS :=
|
||||||
|
|||||||
+14
-11
@@ -35,15 +35,18 @@
|
|||||||
; Adapted for the freeware Zilog Macro Assembler 2.10 to produce
|
; Adapted for the freeware Zilog Macro Assembler 2.10 to produce
|
||||||
; the original ROM code (checksum A934H). PA
|
; the original ROM code (checksum A934H). PA
|
||||||
|
|
||||||
|
#include "../../build/memory.inc"
|
||||||
|
#include "../../bios.inc"
|
||||||
|
|
||||||
; MACHINE CONFIG
|
; MACHINE CONFIG
|
||||||
MC_BIOS_PUTC .EQU 0C050H
|
MC_BIOS_PUTC .EQU BIOS_PUTC
|
||||||
MC_BIOS_TRY_GETC .EQU 0C053H
|
MC_BIOS_TRY_GETC .EQU BIOS_TRY_GETC
|
||||||
MC_BIOS_GETC .EQU 0C056H
|
MC_BIOS_GETC .EQU BIOS_GETC
|
||||||
MC_BIOS_FLUSH .EQU 0C062H
|
MC_BIOS_FLUSH .EQU 00000H
|
||||||
MC_BIOS_MONITOR .EQU 0C06EH
|
MC_BIOS_MONITOR .EQU 00000H
|
||||||
MC_CODE_START .EQU 04000H
|
MC_CODE_START .EQU BASIC_RAM_START
|
||||||
MC_RAM_START .EQU 08000H
|
MC_RAM_START .EQU BASIC_RAM_START + BASIC_ROM_SIZE
|
||||||
MC_RAM_END .EQU 0BFFFH
|
MC_RAM_END .EQU 0FFFFH
|
||||||
|
|
||||||
; GENERAL EQUATES
|
; GENERAL EQUATES
|
||||||
|
|
||||||
@@ -182,7 +185,7 @@ COPY: LD A,(DE) ; Get source
|
|||||||
CALL PRNTCRLF ; Output CRLF
|
CALL PRNTCRLF ; Output CRLF
|
||||||
LD (BUFFER+72+1),A ; Mark end of buffer
|
LD (BUFFER+72+1),A ; Mark end of buffer
|
||||||
LD (PROGST),A ; Initialise program area
|
LD (PROGST),A ; Initialise program area
|
||||||
MSIZE: LD HL,MC_RAM_END+1 ; Directly set top of ram instead of probing
|
MSIZE: LD HL,MC_RAM_END ; Directly set top of ram instead of probing
|
||||||
JP SETTOP
|
JP SETTOP
|
||||||
;LD HL,MEMMSG ; Point to message
|
;LD HL,MEMMSG ; Point to message
|
||||||
;CALL PRS ; Output "Memory size"
|
;CALL PRS ; Output "Memory size"
|
||||||
@@ -216,7 +219,7 @@ MSIZE: LD HL,MC_RAM_END+1 ; Directly set top of ram instead of probing
|
|||||||
;LD (HL),B ; Restore old contents
|
;LD (HL),B ; Restore old contents
|
||||||
;JP NZ,MSIZE ; Ask again if no RAM
|
;JP NZ,MSIZE ; Ask again if no RAM
|
||||||
|
|
||||||
SETTOP: DEC HL ; Back one byte
|
SETTOP: ;DEC HL ; Back one byte
|
||||||
LD DE,STLOOK-1 ; See if enough RAM
|
LD DE,STLOOK-1 ; See if enough RAM
|
||||||
CALL CPDEHL ; Compare DE with HL
|
CALL CPDEHL ; Compare DE with HL
|
||||||
JP C,MSIZE ; Ask again if not enough RAM
|
JP C,MSIZE ; Ask again if not enough RAM
|
||||||
@@ -4344,7 +4347,7 @@ JJUMP1: LD IX,-1 ; Flag cold start
|
|||||||
MONOUT: JP MC_BIOS_PUTC ; output a char
|
MONOUT: JP MC_BIOS_PUTC ; output a char
|
||||||
|
|
||||||
|
|
||||||
MONITR: CALL MC_BIOS_FLUSH
|
MONITR: ;CALL MC_BIOS_FLUSH
|
||||||
JP MC_BIOS_MONITOR ; Restart (Normally Monitor Start)
|
JP MC_BIOS_MONITOR ; Restart (Normally Monitor Start)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+17
-3
@@ -1,5 +1,5 @@
|
|||||||
#target bin
|
#target bin
|
||||||
#include "memory.inc"
|
#include "build/memory.inc"
|
||||||
#include "hardware.inc"
|
#include "hardware.inc"
|
||||||
#include "bios.inc"
|
#include "bios.inc"
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ UART_DATA .equ UART_BASE+001h
|
|||||||
BUF_SIZE .equ 16
|
BUF_SIZE .equ 16
|
||||||
BUF_SIZE_MASK .equ 00fh
|
BUF_SIZE_MASK .equ 00fh
|
||||||
|
|
||||||
WORKSPACE .equ SHARED_MEM_START+01000h
|
WORKSPACE .equ SHARED_MEM_START+00400h
|
||||||
TX_HEAD .equ WORKSPACE+000h
|
TX_HEAD .equ WORKSPACE+000h
|
||||||
TX_TAIL .equ WORKSPACE+001h
|
TX_TAIL .equ WORKSPACE+001h
|
||||||
TX_COUNT .equ WORKSPACE+002h
|
TX_COUNT .equ WORKSPACE+002h
|
||||||
@@ -34,15 +34,24 @@ RX_BUF .equ TX_BUF+BUF_SIZE
|
|||||||
jp boot_copy
|
jp boot_copy
|
||||||
.org 00008h
|
.org 00008h
|
||||||
boot_copy:
|
boot_copy:
|
||||||
; copy bios to top 16k
|
|
||||||
di
|
di
|
||||||
|
; Make sure system reg is in its default state
|
||||||
|
; banking enabled
|
||||||
|
; bank 1 selected
|
||||||
ld a,BOOT_BANK_MAPPING
|
ld a,BOOT_BANK_MAPPING
|
||||||
ld (SYSTEM_REGISTER),a
|
ld (SYSTEM_REGISTER),a
|
||||||
ld sp,BIOS_STACK_TOP
|
ld sp,BIOS_STACK_TOP
|
||||||
|
; copy bios to top 16k
|
||||||
ld hl,BIOS_ROM_START
|
ld hl,BIOS_ROM_START
|
||||||
ld de,SHARED_MEM_START
|
ld de,SHARED_MEM_START
|
||||||
ld bc,BIOS_size
|
ld bc,BIOS_size
|
||||||
ldir
|
ldir
|
||||||
|
; copy basic to top 16k
|
||||||
|
ld hl,BASIC_ROM_START
|
||||||
|
ld de,BASIC_RAM_START
|
||||||
|
ld bc,BASIC_ROM_SIZE
|
||||||
|
ldir
|
||||||
|
|
||||||
jp init
|
jp init
|
||||||
|
|
||||||
#code BIOS, SHARED_MEM_START
|
#code BIOS, SHARED_MEM_START
|
||||||
@@ -115,6 +124,9 @@ init:
|
|||||||
ld hl,msg_header
|
ld hl,msg_header
|
||||||
call puts
|
call puts
|
||||||
|
|
||||||
|
; Enter bios
|
||||||
|
jp BASIC_RAM_START
|
||||||
|
|
||||||
; Shouldnt come here
|
; Shouldnt come here
|
||||||
; just to be safe an endless loop
|
; just to be safe an endless loop
|
||||||
0$:
|
0$:
|
||||||
@@ -324,6 +336,7 @@ uart_kick:
|
|||||||
; needs a (byte to tx)
|
; needs a (byte to tx)
|
||||||
; -------------------------------------------------------
|
; -------------------------------------------------------
|
||||||
putc:
|
putc:
|
||||||
|
push af
|
||||||
push de
|
push de
|
||||||
push bc
|
push bc
|
||||||
push hl
|
push hl
|
||||||
@@ -363,6 +376,7 @@ putc:
|
|||||||
pop hl
|
pop hl
|
||||||
pop bc
|
pop bc
|
||||||
pop de
|
pop de
|
||||||
|
pop af
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; -------------------------------------------------------
|
; -------------------------------------------------------
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
ROM_START .equ 00000h
|
|
||||||
ROM_SIZE .equ 08000h
|
|
||||||
ROM_END .equ 07fffh
|
|
||||||
RAM_START .equ 08000h
|
|
||||||
RAM_SIZE .equ 08000h
|
|
||||||
RAM_END .equ 0ffffh
|
|
||||||
|
|
||||||
SHARED_MEM_START .equ 0c000h
|
|
||||||
SHARED_MEM_SIZE .equ 04000h
|
|
||||||
SHARED_MEM_END .equ 0ffffh
|
|
||||||
|
|
||||||
BIOS_STACK_TOP .equ SHARED_MEM_END
|
|
||||||
BIOS_ROM_START .equ ROM_START+0080h
|
|
||||||
BIOS_ROM_SIZE .equ 00f80h
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
ROM_START := 0x0000
|
||||||
|
ROM_SIZE := 0x8000
|
||||||
|
ROM_END := 0x7fff
|
||||||
|
RAM_START := 0x8000
|
||||||
|
RAM_SIZE := 0x8000
|
||||||
|
RAM_END := 0xffff
|
||||||
|
|
||||||
|
SHARED_MEM_START := 0xc000
|
||||||
|
SHARED_MEM_SIZE := 0x4000
|
||||||
|
SHARED_MEM_END := 0xffff
|
||||||
|
|
||||||
|
BIOS_STACK_TOP := 0xffff
|
||||||
|
BIOS_ROM_START := 0x0080
|
||||||
|
BIOS_ROM_SIZE := 0x0380
|
||||||
|
|
||||||
|
BASIC_ROM_START := 0x0400
|
||||||
|
BASIC_ROM_SIZE := 0x2000
|
||||||
|
|
||||||
|
BIOS_RAM_START := 0xc000
|
||||||
|
BASIC_RAM_START := 0xd000
|
||||||
Reference in New Issue
Block a user