Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bear with me, I'm still learning asm
#1
I've noticed something in an example I found on this forum. I think it was called FastPset32 or something like that. Anyway, it was a really fast version of PSET. I was playing with something else today and noticed that FastPset32 uses the eax and ebx registers. The first thing that it does is mov's something to eax. I'm curious, does Intel's JMP instruction save the registers for you? It seems like there should be a series of PUSH commands to save the registers so that the function doesn't crash another part of the program that might rely on those registers. Or does the FreeBasic compiler save them or something?
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#2
the compiler saves all the required regs (therefore theres a bit of overhead when using inline asm)

eventually, ideally, reg tracking code could be written to figure out what regs are trashed (harder with instructions implicitly using regs, hey?), but for now theres just a mass save and restore before and after the asm block, respectively
Reply
#3
there are no saves on jmp, register handling is really left down to you to keep track of.

when you start an asm block in fb, it preserves ebx, esi, edi

ie

Asm

End Asm

becomes

push ebx
push esi
push edi

pop edi
pop esi
pop ebx

(the exact order may be different but thats not important)

This is because these 3 regs are those that are required to be preserved by the most common OS's. This is not ideal, if you aren't even going to use them, but hopefully this will get better in the future.

Also messing with ebp, and esp is generally a bad idea, ebp is normally used to setup a stack frame, for local variables.

When you call a routine, you really have to expect that all the registers will be trashed, while they shouldn't all get clobbered, sometimes they do. I think you're supposed to preserve the direction flag too, but you'll have to look that up if/when you get round to using it.

Reading something like Randall Hydes Art of Assembly might help you out, i learnt quite a lot of the basics from there, although i still have a lot to learn.
EVEN MEN OF STEEL RUST.
[Image: chav.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)