0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

z88dk 関数 引数

0
Last updated at Posted at 2026-01-30
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);
}
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?