Przeglądaj źródła

stdio: de-macro-ize

pull/10/head
Virgil Dupras 5 lat temu
rodzic
commit
56760b5aba
6 zmienionych plików z 70 dodań i 35 usunięć
  1. +2
    -2
      parts/z80/shell.asm
  2. +27
    -7
      parts/z80/stdio.asm
  3. +25
    -13
      recipes/rc2014/glue.asm
  4. +6
    -6
      recipes/rc2014/sdcard/glue.asm
  5. +1
    -1
      tools/emul/shell/shell.c
  6. +9
    -6
      tools/emul/shell/shell_.asm

+ 2
- 2
parts/z80/shell.asm Wyświetl plik

@@ -79,7 +79,7 @@ shellInit:
; to it rather than call it. Saves two precious bytes in the stack.
shellLoop:
; First, let's wait until something is typed.
STDIO_GETC
call stdioGetC
jr nz, shellLoop ; nothing typed? loop
; got it. Now, is it a CR or LF?
cp ASCII_CR
@@ -88,7 +88,7 @@ shellLoop:
jr z, .do ; char is LF? do!

; Echo the received character right away so that we see what we type
STDIO_PUTC
call stdioPutC

; Ok, gotta add it do the buffer
; save char for later


+ 27
- 7
parts/z80/stdio.asm Wyświetl plik

@@ -4,13 +4,33 @@
; which the user is connected in a decoupled manner.
;
; *** REQUIREMENTS ***
; STDIO_GETC: a macro that follows GetC API
; STDIO_PUTC: a macro that follows GetC API
; blkdev. select the block device you want to use as stdio just before you call
; stdioInit.

; *** VARIABLES ***
; Used to store formatted hex values just before printing it.
STDIO_HEX_FMT .equ STDIO_RAMSTART
STDIO_RAMEND .equ STDIO_HEX_FMT+2
STDIO_GETC .equ STDIO_HEX_FMT+2
STDIO_PUTC .equ STDIO_GETC+2
STDIO_RAMEND .equ STDIO_PUTC+2

; Select the blockdev to use as stdio before calling this.
stdioInit:
push hl
ld hl, (BLOCKDEV_GETC)
ld (STDIO_GETC), hl
ld hl, (BLOCKDEV_PUTC)
ld (STDIO_PUTC), hl
pop hl
ret

stdioGetC:
ld ix, (STDIO_GETC)
jp (ix)

stdioPutC:
ld ix, (STDIO_PUTC)
jp (ix)

; print null-terminated string pointed to by HL
printstr:
@@ -21,7 +41,7 @@ printstr:
ld a, (hl) ; load character to send
or a ; is it zero?
jr z, .end ; if yes, we're finished
STDIO_PUTC
call stdioPutC
inc hl
jr .loop

@@ -38,7 +58,7 @@ printnstr:
ld b, a
.loop:
ld a, (hl) ; load character to send
STDIO_PUTC
call stdioPutC
inc hl
djnz .loop

@@ -49,9 +69,9 @@ printnstr:

printcrlf:
ld a, ASCII_CR
STDIO_PUTC
call stdioPutC
ld a, ASCII_LF
STDIO_PUTC
call stdioPutC
ret

; Print the hex char in A


+ 25
- 13
recipes/rc2014/glue.asm Wyświetl plik

@@ -5,32 +5,44 @@ RAMEND .equ 0xffff
ACIA_CTL .equ 0x80 ; Control and status. RS off.
ACIA_IO .equ 0x81 ; Transmit. RS on.

jr init
jp init

; interrupt hook
.fill 0x38-$
jp aciaInt

#include "core.asm"
ACIA_RAMSTART .equ RAMSTART
#include "acia.asm"

BLOCKDEV_RAMSTART .equ ACIA_RAMEND
BLOCKDEV_COUNT .equ 1
#include "blockdev.asm"
; List of devices
.dw aciaGetC, aciaPutC, 0, 0

STDIO_RAMSTART .equ BLOCKDEV_RAMEND
#include "stdio.asm"

SHELL_RAMSTART .equ STDIO_RAMEND
.define SHELL_IO_GETC call aciaGetC
.define SHELL_IO_PUTC call aciaPutC
SHELL_EXTRA_CMD_COUNT .equ 0
#include "shell.asm"

init:
di
; setup stack
ld hl, RAMEND
ld sp, hl
im 1

call aciaInit
xor a
ld de, BLOCKDEV_GETC
call blkSel
call stdioInit
call shellInit
ei
jp shellLoop

#include "core.asm"
ACIA_RAMSTART .equ RAMSTART
#include "acia.asm"
.define STDIO_GETC call aciaGetC
.define STDIO_PUTC call aciaPutC
STDIO_RAMSTART .equ ACIA_RAMEND
#include "stdio.asm"
SHELL_RAMSTART .equ STDIO_RAMEND
.define SHELL_IO_GETC call aciaGetC
.define SHELL_IO_PUTC call aciaPutC
SHELL_EXTRA_CMD_COUNT .equ 0
#include "shell.asm"

+ 6
- 6
recipes/rc2014/sdcard/glue.asm Wyświetl plik

@@ -27,11 +27,7 @@ jp aciaInt
#include "core.asm"
ACIA_RAMSTART .equ RAMSTART
#include "acia.asm"
.define STDIO_GETC call aciaGetC
.define STDIO_PUTC call aciaPutC
STDIO_RAMSTART .equ ACIA_RAMEND
#include "stdio.asm"
BLOCKDEV_RAMSTART .equ STDIO_RAMEND
BLOCKDEV_RAMSTART .equ ACIA_RAMEND
BLOCKDEV_COUNT .equ 2
#include "blockdev.asm"
; List of devices
@@ -40,7 +36,10 @@ BLOCKDEV_COUNT .equ 2

#include "blockdev_cmds.asm"

SHELL_RAMSTART .equ BLOCKDEV_RAMEND
STDIO_RAMSTART .equ BLOCKDEV_RAMEND
#include "stdio.asm"

SHELL_RAMSTART .equ STDIO_RAMEND
.define SHELL_IO_GETC call blkGetCW
.define SHELL_IO_PUTC call blkPutC
SHELL_EXTRA_CMD_COUNT .equ 3
@@ -63,6 +62,7 @@ init:
xor a
ld de, BLOCKDEV_GETC
call blkSel
call stdioInit
call shellInit

ei


+ 1
- 1
tools/emul/shell/shell.c Wyświetl plik

@@ -141,7 +141,7 @@ int main()
cpu.memRead = mem_read;
cpu.memWrite = mem_write;

while (running) {
while (running && !cpu.halted) {
Z80Execute(&cpu);
}



+ 9
- 6
tools/emul/shell/shell_.asm Wyświetl plik

@@ -9,12 +9,8 @@ FS_SEEKH_PORT .equ 0x03
jp init

#include "core.asm"
.define STDIO_GETC call emulGetC
.define STDIO_PUTC call emulPutC
STDIO_RAMSTART .equ RAMSTART
#include "stdio.asm"

BLOCKDEV_RAMSTART .equ STDIO_RAMEND
BLOCKDEV_RAMSTART .equ RAMSTART
BLOCKDEV_COUNT .equ 4
#include "blockdev.asm"
; List of devices
@@ -25,7 +21,10 @@ BLOCKDEV_COUNT .equ 4

#include "blockdev_cmds.asm"

.equ FS_RAMSTART BLOCKDEV_RAMEND
STDIO_RAMSTART .equ BLOCKDEV_RAMEND
#include "stdio.asm"

.equ FS_RAMSTART STDIO_RAMEND
.equ FS_HANDLE_COUNT 2
#include "fs.asm"
#include "fs_cmds.asm"
@@ -42,6 +41,10 @@ init:
; setup stack
ld hl, RAMEND
ld sp, hl
xor a
ld de, BLOCKDEV_GETC
call blkSel
call stdioInit
call fsInit
ld a, 1 ; select fsdev
ld de, BLOCKDEV_GETC


Ładowanie…
Anuluj
Zapisz