Follow

Stack manipulations in SubX

I've been noodling on a Forth-inspired (but likely insane) syntactic sugar for stack manipulations in raw machine code. Behold:

{ 0 0 ->%ecx
...
}

This expands to:

push 0/imm32
push 0/imm32
copy %esp to %ecx
...
add 8 to %esp

Basically you get a (fairly unsafe) block scope containing an 8-byte local in %ecx.

To temporarily spill a register:

{ %ecx
...
}

Function call:

{ z y x
call f/disp32
}

The '}' turns into code to undo pushes in the '{' line.

@vertigo

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!