flat assembler
Message board for the users of flat assembler.

Index > Windows > Hot to use the REGISTERS correctly ?

Author
Thread Post new topic Reply to topic
Stcherbatchenko



Joined: 20 Apr 2004
Posts: 13
Stcherbatchenko
heh its me again but this time with a new one anyway, i wanted to know how to use the registers correctly coz i really dont know whats the difference in using anyone of them in any thing i make so if anyone can please help me with that it would be really good
Post 21 Apr 2004, 21:17
View user's profile Send private message Reply with quote
StringCheesian



Joined: 20 Feb 2004
Posts: 20
StringCheesian
Although some registers have prescribed uses (like ECX is traditionally the loop counter), that's merely a suggestion - you can use them for whatever you want. It doesn't matter.
Post 21 Apr 2004, 21:57
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
but better do not use ESP, if you dont know what you are doing.
don't use EBP if you use standard procedure (macros like "proc", "enter", "return" etc.)
in callback procedures (those called by windows, for example window procedure) preserve value of ESI, EDI, EBP, EBX

other genereal purpose registers (GPRs, that are EAX, EBX, ECX, EDX, ESI, EDI, ESP, EBP and their parts like AX, DL, CH etc.) are used idfferently, not with "mov", "add" etc.
Post 22 Apr 2004, 08:29
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Stcherbatchenko



Joined: 20 Apr 2004
Posts: 13
Stcherbatchenko
heh you lost me there VID *blushes* can you explain more breifly am just a new Smile
Post 22 Apr 2004, 08:33
View user's profile Send private message Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv
ebx, edi and esi are usually used as pointers, and used when the coder do not want to have values changed after calling some winapi. Some opcodes are shorter with certain registers. For instance xchg eax, ebx is 1 byte shorter than xchg ebx, ecx. Also for the case of div xx, where xx is a register or a memory, it is assumed that the 64bit to be divided is in eax and edx. eax containing the lower 32bit and edx the upper 32 bits

My word of advice for esp and ebp is not to touch it unless you know what you are doing.
Post 22 Apr 2004, 08:43
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.