Skip to content

Latest commit

 

History

History
249 lines (159 loc) · 4.47 KB

internal.md

File metadata and controls

249 lines (159 loc) · 4.47 KB

y_cgen - v1.0

Reserve space in COD for newly generated code.

(c) 2022 YSI contibutors, licensed under MPL 1.1

Functions

@_y_cgen0_y_@:

Syntax

@_y_cgen0_y_@()

Remarks

Calls the CGEN() function a massive number of times, to generate a lot of useless assembly whose space we can reuse for useful code (i.e. y_hooks stubs).

Depends on

Attributes

  • public

Estimated stack usage

55 cells

@_y_cgen1_y_@:

Syntax

@_y_cgen1_y_@()

Remarks

Denotes the end of the unused code block, so very much relies on the compiler placing this function directly after @_y_cgen0_y_@.

Attributes

  • public

Estimated stack usage

1 cells

CGEN:

Syntax

CGEN(&a, &b, &c, &d, &e, &f, &g, &h, &i, &j, &k, &l, &m, &n, &o, &p, &q, &r, &s, &t, &u, &v, &w, &x, &y, &z)

Parameters

Name Info
a &
b &
c &
d &
e &
f &
g &
h &
i &
j &
k &
l &
m &
n &
o &
p &
q &
r &
s &
t &
u &
v &
w &
x &
y &
z &

Returns

Remarks

This is just a function that takes very little pawn code, but an awful lot of p-code, to call. The pawn is just CGEN(), but thanks to having a huge number of reference parameters all with default constant values the generated assembly is massive, with twenty-six heap allocations and pushes. It doesn't even do anything, just reserves a huge block of code space in which we can generate new code.

Estimated stack usage

1 cells

CGen_GetAddr:

Syntax

CGen_GetAddr(func[])

Parameters

Name Info
func [] Function name to get the address of.

Returns

The address of the function.

Remarks

Why this doesn't use functions from in y_amx I don't know.

Depends on

Estimated stack usage

3 cells

CGen_OOM:

Syntax

CGen_OOM(ctx[])

Parameters

Name Info
ctx [21] The AsmContext that ran out of space.

Remarks

Called by amx_assembly when more code is written than there is space for, or on some other errors.

Depends on

Attributes

  • public

Estimated stack usage

8 cells

CGen_SetupCodeSpace:

Syntax

CGen_SetupCodeSpace()

Remarks

Initialises the storage for unused code, and ensures that the functions being clobbered by said code are at least left in a semi-valid state.

Depends on

Estimated stack usage

4 cells

VA_OnCodeInit:

Syntax

VA_OnCodeInit()

Remarks

Initialise the library.

Depends on

Attributes

  • public

Estimated stack usage

11 cells