1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

sdccでmsx

Last updated at Posted at 2016-03-19

#概要
sdccでcをコンパイルして、Z80のインテルhexにします。
hex2romでROM化します。
エミュレータで実行します。
#開発環境
SDCC : ver2.8.1
ruMSX : ver0.41
#写真
zun.jpg

#ツール
https://github.com/ohisama/hex2rom
#MakeFile

All : zun.hex zun.rom 
zun.hex : zun.o
	sdcc -V -mz80 --no-std-crt0 --code-loc 0x4010 --data-loc 0x7000 -o zun.hex  zun.o
zun.rom : zun.hex
	hex2rom zun.hex zun.rom
zun.o : zun.c
	sdcc -V -mz80 zun.c

#サンプルコード

#define	CHPUT		#0x00A2
#define	CHGET		#0x009F
void print(char * pc);
void putchar(char c);
int getchar();
int rnd(char c);
void main(void)
{
	int n = 0;
	int c = 0;
	char d = 12;
	putchar(d);
	do
	{
		c = rnd(10) & 0x0E;
		if (c < 7)
		{
			print("zun ");
			n++;
			if (n == 4)
			{
				print("doko ");
				d = 0;
			}
		}
		else
		{
			print("doko ");
			n = 0;
		}
	} while (d == 12);
	print("ki yo shi!");
	putchar(getchar());
}
void print(char * pc)
{
	while (* pc != '\0')
	{
		putchar(* pc);
		pc++;
	}
}
void putchar(char c)
{
_asm
	ld		a, 4(ix)
	call	CHPUT
_endasm;
}
int getchar()
{
_asm
	call	CHGET
	ld		l, a
	ld		h, #0
_endasm;
}
int rnd(char c)
{
_asm
	ld		a, r
	ld		b, a
	ld		a, r
	add 	a, b
	ld		l, a
	ld		h, #0
_endasm;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?