Code: Select all
push ix
ld ix,0
add ix,sp
ld l,(ix+2)
ld h,(ix+3)
;etc..
;do stuff
ld sp,ix
pop ix
ret
But now comes the strange part:
Then the arguments that the function which is called by your function are pushed on the stack..
What? those things you just laboriously read from it??
..exactly..
That you need a copy of the variables I can understand, but not like this.
Like so:
Code: Select all
long Div(long l1, long l2)
{
return l1/l2;
}
Code: Select all
;test.c:1: long Div(long l1, long l2)
; genLabel
; genFunction
; ---------------------------------
; Function Div
; ---------------------------------
_Div_start::
_Div:
push ix
ld ix,#0
add ix,sp
;test.c:3: return l1/l2;
; genIpush
; _saveRegsForCall: sendSetSize: 0 deInUse: 0 bcInUse: 0 deSending: 0
; AOP_STK for
ld l,10(ix)
ld h,11(ix)
push hl
ld l,8(ix)
ld h,9(ix)
push hl
; genIpush
; AOP_STK for
ld l,6(ix)
ld h,7(ix)
push hl
ld l,4(ix)
ld h,5(ix)
push hl
; genCall
call __divslong_rrx_s
ld b,h
ld c,l
pop af
pop af
pop af
pop af
; genRet
; Dump of IC_LEFT: type AOP_REG size 4
; reg = debc
ld l,c
ld h,b
; genLabel
; genEndFunction
pop ix
ret
_Div_end::