From: Robin Krens <robin@robinkrens.nl>
Date: Sat, 4 Jun 2022 20:49:50 +0000 (+0200)
Subject: main: setting register from C with inline asm
X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=52386107b3b9bb7c6fa550428db544210af4ae24;p=swan-dev

main: setting register from C with inline asm
---

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 <code16bit.h> */
+#include <wonderswan_mem.h>
+
+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;
 }