Hello to all!
Just a few questions that have been bothering me for a while now:
- How do you change which register MASM uses for the ADDR statement (it always uses EAX) ?
- What's the syntax to differentiate between relative, absolute and indirect jumps & calls ? (neither the opcodes reference nor the assembler reference tells you the syntax for instructions in enough detail...)
; This code is NOT valid, but shows the effect of jmp (call has a push EIP in front)
; Note: these are all near jumps
add EIP,xxx ; relative (xxx is the displacement relative to the next instruction)
lea EIP,[xxx] ; absolute (xxx is the memory address to jump to)
mov EIP,[xxx] ; indirect (xxx is the memory address of the memory address to jump to)
- Where is the proper place where all the downloads (most recent MASM, windows.inc, etc) are located?
- Are there MSVCRT.INC and MSVCRT.LIB files available? I don't seem to have them in my MASM directory.
MASM32 has MSVCRT support. Conditional jumps are NEAR in win32 with a 32k range and SHORT if you use the form that has signed byte range. Unconditional jumps "JMP" have DWORD range.
Jxx SHORT label ; signed BYTE range (128 byte)
Jxx NEAR label ; signed WORD range (32k)
JMP label ; DWORD range (4 gig)
Fast reply!
What I meant was: there are all these different versions of jump and call instructions, yet there doesn't seem to be a way to specify which to use.
E.g.:
jmp [eax]
How do you choose between jumping to the memory address in EAX ("absolute"), and jumping to the memory address stored in the pointer that EAX points to ("absolute indirect")?
I had to copy the libmsvcrt.a file out of my C/C++ compiler's lib folder into the MASM lib folder (and rename it to msvcrt.lib), and manually write an .inc file, because they weren't there.
Is my version of MASM outdated ? ... after typing ML at the command line it came up with v. 6.14.8444 ... so that's probably a yes...
Quote from: hutch-- on August 03, 2006, 10:41:26 PM
MASM32 has MSVCRT support. Conditional jumps are NEAR in win32 with a 32k range and SHORT if you use the form that has signed byte range. Unconditional jumps "JMP" have DWORD range.
Jxx SHORT label ; signed BYTE range (128 byte)
Jxx NEAR label ; signed WORD range (32k)
JMP label ; DWORD range (4 gig)
Actually, NEAR jumps are 32 bits in 32-bit mode (win32). I used to make that mistake until Frank Kotler caught me on it.
Cheers,
Randy Hyde
Hello!
I quickly created a small test for the absolute and absolute indirect calls/jumps. Here is what I've got:
dumyPTR dd offset dumy
...
dumy PROC
ret
dumy ENDP
...
mov eax,offset dumy
call DWORD PTR eax ; absolute jump using a register
call eax ;the DWORD PTR can be leaved off
mov eax,offset dumyPtr
call DWORD PTR [eax] ; indirect jump using a register
; the size specifier is needed and the square brackets are necessary!
I hope I didn't mess up anything :)
About the size of jumps I didn't really bother so far, I think I use 32bit absolute jump/calls in about 80% of the cases.
Greets, Gábor