a
a
asm80
Search…
Generic Emulators
Barebone emulator, or “generic emulator”, is a customizable emulator of CPU + memory + serial terminal. You can configure it by simple config file. Let’s long story short…
First of all, prepare a config file, e.g. “mycomputer.emu”. Extension “.emu” is mandatory. File should contain this:
1
cpu Z80
2
3
memory.ram.from 0x1000
4
memory.ram.to 0x13ff
5
memory.rom.from 0x0000
6
memory.rom.to 0x0fff
7
8
;serial simple
9
;serial.in 1
10
;serial.out 1
11
;serial.status 0
12
;serial.status.available 0x20
13
;serial.status.ready 0x02
14
15
serial 6850
16
serial.data 0x81
17
serial.control 0x80
18
19
terminal.caps 1
Copied!
Format is really simple: Each line contains one directive. Lines with “;” at the same beginning are comments. Here are parameters:
parameter
value (case sensitive)
cpu
can be “I8080”, “Z80” or “C6502”
memory.ram.from
starting address for RAM (please follow the 0x… convention for hexadecimal numbers)
memory.ram.to
last address of RAM
memory.rom.from, memory.rom.to
Same as above, but for ROM (your source code should lays here)
serial
Type of serial port. You can select “6850” or “simple”. See below
serial.data, serial.control
For 6850 serial – two ports.
serial.in, serial.out
in and out ports for “simple serial port”
serial.status
“Simple port” status. Read only port. It returns “serial.status.available” when there is any data for read, and “serial.status.ready” if port is ready to send a data.
terminal.caps
1 sets terminal to caps lock (default value 0 means “no caps”)
serial.interrupt
value 1 means that terminal invoke CPU interrupt on keypress (=serial data is ready for read). Default 0 means “no interrupt”.
Two serial ports are available – 6850 is the standard ACIA circuit, “simple” is a generic serial port with no complicated functions, just read and send bytes.
How to use it? It’s simple, just tell which emulator should use by the “.engine” directive (without “.emu”), like this:
1
org 0
2
.engine mycomputer
3
4
di
5
ld sp, 0x1400
6
ld a, 15h
7
out (80h),a
8
ld hl, hello
9
call printhl
10
11
endless:
12
call geta
13
jr z,endless
14
inc a
15
call printa
16
17
jr endless
18
19
printhl:
20
ld a,(hl)
21
or a
22
ret z
23
call printa
24
inc hl
25
jr printhl
26
27
printa:
28
push af
29
serdy:
30
in a,80h
31
and 02
32
jr z,serdy
33
pop af
34
out 81h,a
35
ret
36
37
geta:
38
in a,80h
39
and 01h
40
ret z
41
in a,81h
42
or a
43
ret
44
45
hello:
46
db "Hello World!",0x0d,0x0a,0
Copied!
It’s a simple “hello” program, using the above configuration. Just save it as “test.z80” and click to “Emulate (F10)”. It should compile and run emulator with given configuration.
For 6502-based computer you can use this config file (e.g.”my6502.emu”):
1
cpu C6502
2
3
memory.ram.from 0x0000
4
memory.ram.to 0x0fff
5
memory.rom.from 0xf000
6
memory.rom.to 0xffff
7
8
serial 6850
9
serial.data 0xa001
10
serial.control 0xa000
11
serial.map 1
Copied!
Please notice the “serial.map” directive. It means that serial port is not mapped into “I/O” space (like Z80/8080 does), but into memory space. Serial.data and serial.control are addresses now.
6502 requires RAM in a bottom part of address space, ROM at the top.
Try this code:
1
.engine my6502
2
3
ACIA = $A000
4
ACIACONTROL = ACIA+0
5
ACIASTATUS = ACIA+0
6
ACIADATA = ACIA+1
7
8
.ORG $FFFC
9
DW reset
10
DW reset
11
12
.org $f000
13
14
RESET:
15
LDX #$FF
16
TXS
17
LDA #$15
18
STA ACIAControl
19
20
LDY #0
21
LOOP:
22
LDA Message,Y
23
BEQ KEY
24
JSR SEROUT
25
INY
26
BNE LOOP
27
KEY: LDA ACIAStatus
28
AND #1
29
BEQ KEY
30
LDA ACIAData
31
; simple data mangling
32
SEC
33
ADC #0
34
JSR serout
35
36
JMP KEY
37
38
Message:
39
DB $0C,"My hovercraft is full of eels!",$0D,$0A,$00
40
41
SEROUT: PHA
42
SO_WAIT: LDA ACIAStatus
43
AND #2
44
BEQ SO_WAIT
45
PLA
46
STA ACIAData
47
RTS
Copied!
Other processors and peripherals are on its way…
Last modified 1yr ago
Copy link