1
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?

More than 5 years have passed since last update.

Z80アセンブラにおけるサブルーチン呼び出しの検討

Posted at

32bitのCコンパイラの出力を参考にZ80アセンブラのサブルーチン呼び出しを検討してみる。

image.png
https://godbolt.org/z/RP5mD0

;10 bload "program.bin",r

CHPUT	equ $00a2

	org $d000
start:
	ld hl,7		; y
	push hl
	ld hl,$40	; x
	push hl
	call hoge
	pop hl		; 空読みx2
	pop hl

	call CHPUT
	ret

; byte hoge(word x, word y)
_x	equ 2
_y	equ 4

hoge:
	ld (spwk),sp
	ld ix,(spwk)

	ld a,(ix+_x)
	add a,(ix+_y)
	ret

spwk:	dw 0

	end start

1
0
2

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
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?