VOOZH about

URL: https://qiita.com/Stosstruppe/items/ce4c0723712a5b7796de

⇱ zcc インラインアセンブラ #Z80 - Qiita


👁 Image
1

Go to list of users who liked

1

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@Stosstruppe

zcc インラインアセンブラ

1
Last updated at Posted at 2018-07-11

z88dkのzccでインラインアセンブラを使う。

参考
z88dk - The Stack Frame

inline.c
/*
zcc +msx -lndos -create-app inline.c
bload"cas:",r
*/

# include <stdio.h>

int myfunc(char len, unsigned char *p)
{
 #asm

 ld hl, 2
 add hl, sp
 ld e, (hl)
 inc hl
 ld d, (hl) ; de=p
 inc hl
 ld b, (hl) ; b=len
loop:
 ld a, (de)
 call $00a2 ; CHPUT
 inc de
 djnz loop

 ld hl, $cafe ; return value

 #endasm
}

void main()
{
 int ret = myfunc(5, "0123456789");
 printf("\nret = %x\n", ret);
}

WebMSXを起動しa.casファイルをCassetteにドロップする。
👁 WMSX Screen (1).png

  • FASTCALL版
fast.c
/*
zcc +msx -lndos -create-app fast.c
bload"cas:",r
*/

# include <stdio.h>

int __FASTCALL__ myfunc(unsigned char *p)
{
 #asm

loop:
 ld a, (hl)
 or a
 jr z, exit
 call $00a2 ; CHPUT
 inc hl
 jr loop
exit:
 ld hl, $babe ; return value

 #endasm
}

void main()
{
 int ret = myfunc("hello, world");
 printf("\nret = %x\n", ret);
}

👁 WMSX Screen (3).png

1

Go to list of users who liked

1
0

Go to list of comments

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

Go to list of users who liked

1