I have a super simple .ASM file:
.486
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.code
main:
invoke ExitProcess, NULL
end main
Now when i compile and link it, i get the following (shown with dumppe -disasm):
00401000 start:
00401000 6A00 push 0
00401002 E801000000 call fn_00401008
00401007 CC int 3
00401008 fn_00401008:
00401008 FF2500204000 jmp dword ptr
My questions are:
1. Why at 00401007 is there CC INT 3 Interrupt 3 trap to debugger ?
2. Why is there a call to 00401008 fn_00401008 just to do a JuMP to the ExitProcess routine ?
I guess I am wondering why the code is not like this:
00401000 start:
00401000 6A00 push 0
00401008 FF2500204000 jmp dword ptr
My only guess is that I compiled/linked with debug and the extra call to jmp is there so that the debugger can trap the call, before the jump.
So how do I turn off DEBUG in ML/LINK ?
Regs,
.486
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.code
main:
invoke ExitProcess, NULL
end main
Now when i compile and link it, i get the following (shown with dumppe -disasm):
00401000 start:
00401000 6A00 push 0
00401002 E801000000 call fn_00401008
00401007 CC int 3
00401008 fn_00401008:
00401008 FF2500204000 jmp dword ptr
My questions are:
1. Why at 00401007 is there CC INT 3 Interrupt 3 trap to debugger ?
2. Why is there a call to 00401008 fn_00401008 just to do a JuMP to the ExitProcess routine ?
I guess I am wondering why the code is not like this:
00401000 start:
00401000 6A00 push 0
00401008 FF2500204000 jmp dword ptr
My only guess is that I compiled/linked with debug and the extra call to jmp is there so that the debugger can trap the call, before the jump.
So how do I turn off DEBUG in ML/LINK ?
Regs,
the int 3 is there to stop the code from getting to the end(no ret)
and the jumps are for OS compatablility, it jumps insteds of a direct call.
and the jumps are for OS compatablility, it jumps insteds of a direct call.
1) 0CCh is there to trap errors - rather weird the masm emites this. Yet a sign that is is
a highlevel assemvler.
2) to do with your typedefs and such (yeah, masm is highlevel). You "CALL" "directly" the API,
which means you go through linker proxies... with some other typedefs and such you can go
directly.
a highlevel assemvler.
2) to do with your typedefs and such (yeah, masm is highlevel). You "CALL" "directly" the API,
which means you go through linker proxies... with some other typedefs and such you can go
directly.
Ok, I changed the code to what the disassembly showed:
push 0
mov eax, ExitProcess
jmp eax
and the assembler still created the following:
00401000 6A00 push 0
00401002 B80A104000 mov eax,40100Ah
00401007 FFE0 jmp eax
00401009 CC int 3
0040100A FF2500204000 jmp dword ptr
I find this strange, but if thats what its got to do, then thats what its got to do.
If you know why can you let me in on it ?
ie: why the code generated does a JMP to 0040100A just to do another jump ?
Is there a "DONT COMPILE FOR DEBUG" option in ml and/or link ?
Regs,
push 0
mov eax, ExitProcess
jmp eax
and the assembler still created the following:
00401000 6A00 push 0
00401002 B80A104000 mov eax,40100Ah
00401007 FFE0 jmp eax
00401009 CC int 3
0040100A FF2500204000 jmp dword ptr
I find this strange, but if thats what its got to do, then thats what its got to do.
If you know why can you let me in on it ?
ie: why the code generated does a JMP to 0040100A just to do another jump ?
Is there a "DONT COMPILE FOR DEBUG" option in ml and/or link ?
Regs,
Gotta love FASM even more now:
Source:
00401000 start:
00401000 6A00 push 0
00401002 FF1535204000 call dword ptr [ExitProcess]
Source:
Format PE GUI 4.0
include 'stdcall.inc'
include 'import.inc'
stdcall [ExitProcess], 0
section '.idata' import data readable writeable
library kernel, 'KERNEL32.DLL'
kernel:
import ExitProcess, 'ExitProcess'
18.07.2002 09:00 1.536 test_fasm.exe
18.07.2002 08:42 2.560 test_masm.exe
the 0CCh is there because .code segment is dword aligned and masm uses 0CCh as fill byte. It would vanish if you code a "nop" after ExitProcess.
Is there a way to avoid that CALL / JMP to the API?
(didn't bitRAKE post a macro for that?)
Just interested about that.....
/me is future FASM user :grin:
(didn't bitRAKE post a macro for that?)
Just interested about that.....
/me is future FASM user :grin:
bAZiK,
MASM32 tool l2extia.exe exists just for that purpose.
MASM32 tool l2extia.exe exists just for that purpose.
bAZiK,
MASM32 tool l2extia.exe exists just for that purpose.
Thanks, never looked in that folder :)
Sven,
I go blind and mad making useful toys and you don't even look in the folder ?:grin:
Regards,
hutch@movsd.com
I go blind and mad making useful toys and you don't even look in the folder ?:grin:
Regards,
hutch@movsd.com
Ain't it good to know that MASM always did it right.
Just used the headers generated by L2EXTIA.EXE
Regards,
hutch@movsd.com :tongue:
Disassembly
00401000 start:
00401000 6A00 push 0
00401002 FF1500204000 call dword ptr [ExitProcess]
Just used the headers generated by L2EXTIA.EXE
Regards,
hutch@movsd.com :tongue:
BIN
#COM
*#DBERROR
*#DBSHOW
#EXAMPLE1
#EXAMPLE2
#EXAMPLE3
#EXAMPLE4
#EXAMPLE5
#EXAMPLE6
#EXAMPLE7
#EXAMPLE8
*HELP
*HTML
#ICZTUTES
INCLUDE
*L2EXTIA
LIB
LICENCE
M32LIB
MACROS
#oop
#PLUGINS
#PROCS
#TEMPLATE
*#VKDEBUG
I never looked in the folders with a '*' and deleted the folders with a '#' :)
Maybe MASM32v8 should include the EXAMPLE and ICZTUTES folder in a seperate package?
Sven,
Do you want to answer the flood of email about why the examples don't work or where are they or how do you write THIS code ?
After being mail bombed for a few versions, splitting it up so that the installation was not automatic and complete would be a formula for a bandwidth crisis that I don't need. :tongue:
Regards,
hutch@movsd.com
Do you want to answer the flood of email about why the examples don't work or where are they or how do you write THIS code ?
After being mail bombed for a few versions, splitting it up so that the installation was not automatic and complete would be a formula for a bandwidth crisis that I don't need. :tongue:
Regards,
hutch@movsd.com
Good point, Steve ! ;)
What about moving them in a folder "EXAMPLES" ?
I'd only need to delete one then :tongue:
What about moving them in a folder "EXAMPLES" ?
I'd only need to delete one then :tongue:
Ok, can someone tell me what this tool does and how to run it ?
Regs,
Regs,
Same as l2inca.exe, but generates direct imports without a jump table.
James,
It is a utility that reads the linker data from the standard Microsoft libraries and writes a set of INCLUDE files that are in EXTERNDEF format instead of the format that the default masm prototypes are written in.
It produces a shorter API call but duplicates that call every time so that commonly used APIs like SendMessage() end up generating more code. MASM by default builds the standard PROTOYPE format that produces a lookup table at the end of the binary file and this has some to do with MASM's primary purpose of writing VXD and later format drivers.
The form created by L2EXTIA.EXE produces calls in much the same way as VC. It is there so that people who are interested have the choice in how their binary code is generated.
Regards,
hutch@movsd.com
It is a utility that reads the linker data from the standard Microsoft libraries and writes a set of INCLUDE files that are in EXTERNDEF format instead of the format that the default masm prototypes are written in.
It produces a shorter API call but duplicates that call every time so that commonly used APIs like SendMessage() end up generating more code. MASM by default builds the standard PROTOYPE format that produces a lookup table at the end of the binary file and this has some to do with MASM's primary purpose of writing VXD and later format drivers.
The form created by L2EXTIA.EXE produces calls in much the same way as VC. It is there so that people who are interested have the choice in how their binary code is generated.
Regards,
hutch@movsd.com
Hutch,
Thanks for the clearification.
I guess when code size and/or execution speed become an issue I will look into the tools more.
Regs,
ps- U sure u cant join my Java Virtual Machine project ?
Thanks for the clearification.
I guess when code size and/or execution speed become an issue I will look into the tools more.
Regs,
ps- U sure u cant join my Java Virtual Machine project ?
ps- U sure u cant join my Java Virtual Machine project ?
Old... ermm... Experienced hutch and JAVA? Dont.think.he.likes.the.syntax :)
Better ask at www.RentACoder.com ;)
bAZik,
Hutch would not have to do java, just some of the virtual machine. Like garbage collection, byte code execution and other really interesting bits. Of course I would be doing as much of it as I can.
Pitty u cant help. What was that "un-named" language you were working on ?
Regs,
Hutch would not have to do java, just some of the virtual machine. Like garbage collection, byte code execution and other really interesting bits. Of course I would be doing as much of it as I can.
Pitty u cant help. What was that "un-named" language you were working on ?
Regs,