From 52386107b3b9bb7c6fa550428db544210af4ae24 Mon Sep 17 00:00:00 2001 From: Robin Krens Date: Sat, 4 Jun 2022 22:49:50 +0200 Subject: [PATCH] main: setting register from C with inline asm --- Makefile | 2 +- src/init.s | 7 +++++-- src/main.c | 24 +++++++++++++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 33bfcaa..9403cf9 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ all: # use -x to for -ffreestanding c-files: - $(CC) -O -c src/*.c + $(CC) -O -c src/*.c -I$(INC) init: $(AS) -fas86 src/*.s -i $(INC) diff --git a/src/init.s b/src/init.s index 065942e..3a36e09 100644 --- a/src/init.s +++ b/src/init.s @@ -2,6 +2,7 @@ %include "WonderSwan.inc" extern _main +extern __end MYSEGMENT equ 0xF000 @@ -38,10 +39,12 @@ sprtable equ bgmap-SPR_TABLE_SIZE mov sp,WS_STACK in al,IO_HARDWARE_TYPE ; Check Wonderswan Mono/Color - test al,WS_COLOR + test al,WS_COLOR .mono: jz .mono ; We loop forever if Mono mov sp,WSC_STACK ; New stack + + call _main xor ax,ax ; Clear Ram mov di,0x100 @@ -182,7 +185,7 @@ TileGfxE: ;****************************************** - ROM_HEADER ..start, MYSEGMENT, 0x42, RH_WS_COLOR, RH_ROM_8MBITS, RH_NO_SRAM, RH_HORIZONTAL + ;ROM_HEADER __end, MYSEGMENT, 0x42, RH_WS_COLOR, RH_ROM_8MBITS, RH_NO_SRAM, RH_HORIZONTAL ;****************************************** diff --git a/src/main.c b/src/main.c index f37cfc4..1ce8228 100644 --- a/src/main.c +++ b/src/main.c @@ -1,4 +1,26 @@ +/* #include */ +#include + +void outport(c) + unsigned c; +{ +#asm + xor dx, dx + mov dx, ax + shr dx, 8 + out dx, al + ;out 0x15, al +#endasm +} + int main() { - return 1; + while(1) { + /* outport(0x15EE); */ + unsigned reg = 0x15; + unsigned val = 0xEE; + outport((reg << 8) | val); + + } + return 0; } -- 2.7.4