c128lib Common
Various common functionalities.
Loading...
Searching...
No Matches
invoke.asm File Reference

Invoke module. More...

Functions

macro invokeStackBegin (value)
 
macro invokeStackEnd (value)
 
macro pushParamB (value)
 
macro pushParamW (value)
 
macro pushParamBInd (value)
 
macro pushParamWInd (value)
 
macro pullParamB (value)
 
macro pullParamW (value)
 
macro pullParamWList (list)
 

Detailed Description

Invoke module.

Set of KickAssembler macros for subroutine implementation.

With these macros one can realize communication with subroutines using stack. This approach is following:

1) subroutine caller prepares input parameters and pushes them to the stack using push*() macros

2) subroutine is then called using JSR

3) subroutine first preserves return address in local variable using invokeStackBegin(variablePtr) macro

4) subroutine then pulls all pushed parameters in opposite order using pull*() macros

5) when subroutine is about to end, just before RTS is called, it must restore return address with invokeStackEnd(varPtr) macro

Date
2022

Function Documentation

◆ invokeStackBegin()

macro invokeStackBegin ( value )

Preserves return address that is used with JSR. Should be called at beginning of subroutine.

Parameters
[out]valuePointer to the memory location (that is local variable of the subroutine) where return address will be preserved.
Note
Use c128lib_invokeStackBegin in invoke-global
Since
0.6.0

◆ invokeStackEnd()

macro invokeStackEnd ( value )

Restores return address that will be then used with RTS. Should be called at the very end of subroutine just before RTS.

Parameters
[in]valuePointer to the memory location (that is local variable of the subroutine) from where return address will be restored.
Note
Use c128lib_invokeStackEnd in invoke-global
Since
0.6.0

◆ pullParamB()

macro pullParamB ( value )

Pulls byte value from the stack and stores it under given address.

Parameters
[out]valuePointer to the memory location where given byte will be pulled to
Note
Use c128lib_pullParamB in invoke-global
Since
0.6.0

◆ pullParamW()

macro pullParamW ( value )

Pulls two bytes value from the stack and stores it under given address.

Parameters
[out]valuePointer to the beginning of memory location where given two bytes will be pulled to
Note
Use c128lib_pullParamW in invoke-global
Since
0.6.0

◆ pullParamWList()

macro pullParamWList ( list )

Pulls two bytes value from the stack and stores it under provided addresses.

Parameters
[out]listList of memory locations, where given two byte value will be stored
Note
Use c128lib_pullParamWList in invoke-global
Since
0.6.0

◆ pushParamB()

macro pushParamB ( value )

Pushes byte value as a parameter to the subroutine. Such value should be then pulled in subroutine in opposite order.

Parameters
[in]valueByte value of the parameter for subroutine
Note
Use c128lib_pushParamB in invoke-global
Since
0.6.0

◆ pushParamBInd()

macro pushParamBInd ( value )

Pushes byte pointed by an address as a parameter to the subroutine. Such value should be then pulled in subroutine in opposite order.

Parameters
[in]valuePointer to the byte value of the parameter for subroutine
Note
Use c128lib_pushParamBInd in invoke-global
Since
0.6.0

◆ pushParamW()

macro pushParamW ( value )

Pushes two bytes value as a parameter to the subroutine. Such value should be then pulled in subroutine in opposite order.

Parameters
[in]valueWord value of the parameter for subroutine
Note
Use c128lib_pushParamW in invoke-global
Since
0.6.0

◆ pushParamWInd()

macro pushParamWInd ( value )

Pushes two bytes value pointed by an address as a parameter to the subroutine. Such value should be then pulled in subroutine in opposite order.

Parameters
[in]valuePointer to the two bytes value of the parameter for subroutine
Note
Use c128lib_pushParamWInd in invoke-global
Since
0.6.0