Introduce I/O module for C (out).

This commit is contained in:
giomba 2023-10-13 09:44:39 +02:00
parent 06f240dd6d
commit 05ae364cfc
4 changed files with 33 additions and 0 deletions

View File

@ -4,6 +4,7 @@ SRC = \
src/ceda_print_a.asm \
src/ceda_print_c.c \
src/main.c \
src/io_a.c \
\
OBJ = $(patsubst %, %.o, $(basename $(SRC)))

10
src/io.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef CEDA_IO_H
#define CEDA_IO_H
#include <stdint.h>
void io_out(uint8_t address, uint8_t value);
uint8_t io_in(uint8_t address);
#endif // CEDA_IO_H

18
src/io_a.asm Normal file
View File

@ -0,0 +1,18 @@
SECTION code
PUBLIC _io_out
_io_out:
push ix
ld ix,$0000
add ix,sp
push bc
ld c,(ix+$04)
ld b,(ix+$05)
out (c),b
pop bc
pop ix
ret

View File

@ -1,4 +1,5 @@
#include "ceda_print.h"
#include "io.h"
int globalvar = 0x7777;
@ -6,5 +7,8 @@ int main(void) {
ceda_print("Hello world!");
ceda_cls();
io_out(0x81, 0x80);
ceda_print("ABCD");
return 0;
}