X86 Assembly Guide Forth

x86 Assembly Using Forth (SwiftForth)

Notes on x86 Assembly and SwiftForth

EBX is the top of the stack
0 [EBP] is the 2nd item on the stack
4 [EBP] is the 3rd item on the stack
8 [EBP] is the 4th item on the stack and so on…

Once you know this you can start creating your own words to manipulate anything on the data stack.

This means if we have:

1 <–top

Then EBX is 1

If we have:

23 1 <–top

Then 0 [EBP] is 23.

Example on Manipulating the 2nd item on the stack

If you want to manipulate the 2nd item on the stack use 0 [EBP]

\ Sample word

Now if your data stack looks like this:

1 2 <–TOP

Then run the word below in the SwiftForth Terminal

\ Make sure you have 2 numbers on the data stack and then type the word below

Will produce

2 2 <–TOP