On this page:
10.1 Minimal ABI
10.1.1 Subroutine entry (minimal)
10.1.2 Saved registers
10.1.3 Subroutine exit
10.2 Full ABI
10.2.1 Subroutine entry (full)
10.2.2 Frame structure
10.2.3 Closure structure

10 ABI🔗

TMA

A simple ABI for BB68 is described in this section. It has two levels: minimal and full.

10.1 Minimal ABI🔗

The minimal ABI specifies the convention a program MUST use to remain minimally compatible with full ABI programs.

10.1.1 Subroutine entry (minimal)🔗

On subroutine entry the subroutine can assume that the return address is stored in register ref.

First argument is passed in the r0 register or r01 register pair based on its size.

Subsequent arguments are passed in r23, r45 and r67 register pairs or in r2, r4 and r6 registers respectively.

The subroutine can assume that the rab register pair points to writable memory capable of holding two memory cells and can store the register pair rab there.

The subroutine can assume that no ABI conforming subroutine will pass any data in registers r8 and r9 to the called subroutine.

10.1.2 Saved registers🔗

During the subroutine call, the register pairs rab and rcd can be used for any purpose, but their value shall be preserved on subroutine exit.

10.1.3 Subroutine exit🔗

During the subroutine exit sequence the saved registers shall be restored and the control shall be transfered to the value of register ref that was present at subroutine entry. There is no obligation to do so by (jmp ref) instruction, if the value was transfered elsewhere.

The first return value is passed in either the r0 or r01 register pair according to the return value size.

10.2 Full ABI🔗

The full ABI specifies the convention a program MUST use to remain fully compatible with full ABI programs. All the requirements of the minimal ABI shall be observed. In addition to that there are further requirements that programs using the full ABI need to satisfy.

10.2.1 Subroutine entry (full)🔗

FIXME

The register pair rab contains a pointer to dynamically enclosing frame of the current subroutine.

The register pair rcd contains a pointer to lexically parent frame of the current subroutine.

10.2.2 Frame structure🔗

A frame structure consists of the following elements:

offset

size

meaning

0

2

place to store rab

2

2

parent lexical frame pointer (normally equal to rcd)

4

2

place to store ref

6

n

local variables/argument spilling space start

10.2.3 Closure structure🔗

Closures are represented with the following structure:

offset

size

meaning

0

2

tag to be able to tell the structure type

2

2

codeptr

4

2

frameptr

6

2

arity