a few notes that might be of help.
The CPU has 8 general purpose registers.
EAX, ECX, EDX can be used whenever you like. You don't need to preserve them but if you leave your own ASM code for any reason then the code you call will not preserve them either. Keep that in mind when you have a BASIC statement in among your ASM. If you want to preserve these registers while you call a BASIC routine then you need to save them yourself and restore them when you return from BASIC.
EBX, ESI, EDI you need to preserve so make sure that, if you use them in your own ASM, you save them first and restore them afterwards before executing another BASIC statement.
Also ESI and EDI are where the compiler keeps its register variables so it's usually a good idea, until you get more used to ASM, to disable register variables with a #REGISTER NONE statement otherwise you'll use a register without realising you've overwritten a variable as well.
ESP is the stack pointer and it's not usually a good idea to mess directly with this.
EBP usage is more involved. It is usable as a general purpose register and must be preserved like EBX, ESI and EDI but it is also used by the compiler to reference BASIC variables.
You can use this register but only if your ASM does not access named BASIC variables while you're using it.
It's usually better to avoid using EBP but if you really need that one extra register in your ASM then it can be used with care.
Remember these 2 opcodes, they can be useful:
Code:
!pushad 'save all CPU registers on the stack .. .. your own ASM here .. !popad 'restore all CPU registers from the stack
Leave a comment: