main.c
#include <stdint.h>
/*
引数の値は、スタックに2バイト単位で渡される
引数の型が1バイトの場合でも、スタックを2バイト使用して渡される
この場合上位バイトは、0x00になる
*/
void test(uint16_t src, uint16_t dest, uint8_t len) {
#asm
ld ix,0
add ix,sp
; (ix+0) test関数実行後の戻りアドレス 下位 (0x??) 任意の値
; (ix+1) test関数実行後の戻りアドレス 上位 (0x??) 任意の値
; (ix+2) 第3引数(len) 下位 (0xff)
; (ix+3) 第3引数(len) 上位 (0x00)
; (ix+4) 第2引数(dest) 下位 (0xcd)
; (ix+5) 第2引数(dest) 上位 (0xab)
; (ix+6) 第1引数(src) 下位 (0x34)
; (ix+7) 第1引数(src) 上位 (0x12)
ld bc,(ix+2) ; b=0x00, c=0xff
ld de,(ix+4) ; d=0xab, e=0xcd
ld hl,(ix+6) ; h=0x12, l=0x34
#endasm
}
void main() {
test(0x1234, 0xabcd, 0xff);
}