From: Robin Krens Date: Wed, 8 Jun 2022 22:03:11 +0000 (+0200) Subject: out call to ports with inline asm + c variables X-Git-Url: https://robinkrens.nl/gitweb/?a=commitdiff_plain;h=64ce7b85586b85f39e009bb294c6c4c4782d1753;p=swan-dev out call to ports with inline asm + c variables squash of: commit 0b368932d654cdbd81d682d36897c74fa1106485 commit a58ede133445902c0a13da0392cac600e72538bf --- diff --git a/Makefile b/Makefile index f949274..5ee33f7 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,9 @@ ADIR = objs SDIR = src INC = -Iinc -CFLAGS = -march=v30 -ffreestanding # use NEC v30 chip +CFLAGS = -march=v30# use NEC v30 chip +CFLAGS += -ffreestanding# no stdlib +CFLAGS += -fno-pic# for use of inline asm _OBJS = entry.o main.o # todo: make sure entry is forced as entry point for linker diff --git a/src/entry.S b/src/entry.S index e1393e5..e5fae8b 100644 --- a/src/entry.S +++ b/src/entry.S @@ -22,7 +22,7 @@ _start: mov %ax,%bx mov %ax,%bp mov %ax,%ss - + # set stack pointer for wonderswan # color mov $0xFE00 - 2,%ax diff --git a/src/main.c b/src/main.c index 502d63c..dc651f1 100644 --- a/src/main.c +++ b/src/main.c @@ -18,13 +18,27 @@ unsigned char bgtile_pal[] = { unsigned char lol[5] = { 0xAA, 0x2, 0x3, 0x4, 0x5}; unsigned char lol2[5] = { 0x1, 0x2, 0x3, 0x4, 0x5}; unsigned char lol3[5] = { 0x1, 0x2, 0x3, 0x4, 0x5}; -#define PALETTE (*(volatile unsigned *)0xFE00) #define PALETTE_T (volatile unsigned *)0xFE00 #define SPRITE_T (volatile unsigned *)0x4000 /* bss */ static unsigned char blaat[100]; +void outport(unsigned char portnr, unsigned char val) +{ + __asm__( + "mov %1, %%dl\n\t" + "out %0, (%%dx)" + : + :"r"(val), "r"(portnr) + :); +} + +void init_video(void) +{ + +} + int main(void) { lol[0] = 0xDD; @@ -33,6 +47,10 @@ int main(void) blaat[0] = 0xEE; blaat[1] = 0xEE; blaat[32] = 0xEE; + + init_video(); + outport(0x15, 0xEE); + while(1); unsigned char * ptr = PALETTE_T; for (int i = 0; i < sizeof(bgtile_pal); ++i) {