News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

uses and align?

Started by n00b!, June 21, 2008, 10:47:06 AM

Previous topic - Next topic

n00b!

1. For what is this "uses"-instruction, like "Dword2Bin proc uses ebx"?

2. What does align do?
example:
GLOBAL MACRO variable:VARARG
  .data
  align 4
    variable
  .code
ENDM

jj2007

MyProc proc uses esi
...does what it says ;-)
On start of the procedure, esi is pushed, before leaving it's popped. It is just a handy way to use one of the reserved registers (esi, edi, ebx).

align 4 before a proc makes sure that the proc does not start on an odd address, which makes certain code a bit faster.

hutch--

noob,

Its an automated technique in MASM to preserve the registers that are USED in this manner. Its a convenience to have but its even better to understand why they are preserved.

If you have USES ESI it means that the ESI register is pushed at the start and popped on exit.

USES for EBX ES EDI does effectively the following noting that the pushes and pops are in reverse order.


    push ebx
    push esi
    push edi

  ; code that uses any or all of the three

    pop edi
    pop esi
    pop ebx


The ALIGN directive literally aligns the start address to the value specicied. This way the data can be read in a single processor action instead of two if the data was not aligned by at least its native data size. DWORD align is 4 bytes etc ....
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php