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 MSX .cファイルから .asmのラベルを呼ぶ方法

Posted at
.ファイル構成
main.c
sub.asm
main.c
// プロトタイプ宣言 (externは省略可能ですが、書くのが作法です)
// アセンブリ側が "_show" なら、C言語側は "show" と書きます
extern void show(void);

void main() {
    // 呼び出し
    show();
}
sub.asm
    ; MSX BIOSのアドレス定義
    defc CHPUT = $00A2
    
    ; C言語から見えるようにシンボルを公開する
    ; 接頭にアンダースコア(_)を付ける
    PUBLIC _show

_show:
    ld a, 'H'
    call CHPUT
    ld a, 'e'
    call CHPUT
    ld a, 'l'
    call CHPUT
    ld a, 'l'
    call CHPUT
    ld a, 'o'
    call CHPUT
    
    ; 【重要】必ずRETでC言語の呼び出し元に戻る
    ret
.ビルドコマンド
zcc +msx -subtype=rom -create-app main.c sub.asm -o main.rom
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?