Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple source code... but can´t compile it :( 2

Status
Not open for further replies.

Fursten

Programmer
Dec 27, 2000
403
0
0
PT
Hi,

I´m using MASM32 (version7 I think) to compile this "simple" code:

;set 32 Bit "flat" memory model:

.386
.model flat

;windows.inc for MASM needs the following option set:
IFDEF masm
option casemap :none
ENDIF

;constants and structures for the
;WinAPI core functions (TASM/MASM-Syntax):

include WINDOWS.inc


;include external (windows) functions:

IFDEF masm
MessageBoxA equ _MessageBoxA@16
ExitProcess equ _ExitProcess@4
ENDIF

extrn ExitProcess : near
extrn MessageBoxA : near


;put the data here:

.data

MessageBoxJustatitle db "Unbelievable, but reality",0
MessageBoxUselessContent db "Great message, isn`t it ?",0
ErrorCode dd 0


;and the code there:

.code

;execution starts here
_letsbegin:

;masses of code, this MessageBox, for example

push MB_ICONHAND or MB_OKCANCEL
push offset MessageBoxJustatitle
push offset MessageBoxUselessContent
;One could pass the window handle here,
;but windows are introduced in the next tutorial:
push 0
call MessageBoxA
;return value: in EAX resides a value
;indicating which button was clicked on



;thats enuf today: lets get outta here


push ErrorCode
call ExitProcess
;astalavista, baby...


;define the entry point:
end _letsbegin

However I got a lot of error messages like these:

c:\<file>\windows.inc(35) : error A2119: language type must be specified

(have a lot of these.......................)
c:\<file>\windows.inc(8746) : error A2008: syntax error: in structure
(a lot of these too)

c:\<file>\windows.inc(8758) : error A20008: structure improperly initialize

(a lot of these too)

What is happen? So much erros to a simple piece of code?
I can´t even compile my first &quot;hello world&quot; program in assembly? lol

Need help!

Thank you

Sérgio Oliveira


 
i dont really know about how MASM works (ie added functionallity) but normally you push only works with the registers ie al,ah,ax,eax as withn ebx,ecx,edx and a few others.

if you are trying to push MB_ICONHAND onto the stack i would expect to see something like

assume ds=YOUR_DATA_SEGMENT
mov ax,YOUR_DATA_SEGMENT_SELECTOR
mov ds,ax
mov eax,[MB_ICONHAND] (if 32bit operand)
push eax

or

mov ax,[MB_ICONHAND] (if 16bit or 8bit operand)
push ax
&quot;People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!&quot;
 
Sergio... try at win32asmboard.cjb.net

Maybe you should just try using the 'Template' provided with the MASM32V7 package... unless you're using MASM v7 not the MASM32 v7 package... I based my template on the provided template and I never get that sort of problem.

Straiph... this is win32 asm... the 386 now supports pushing immediates and memory locs (there's a .386 at the top). &quot;Information has a tendency to be free. Which means someone will always tell you something you don't want to know.&quot;
 
yes, the use of the MOD,R/M and SIB are very common on most operations. This leads me to examine my own style and see where I can become more efficient.

Thankyou.
&quot;People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!&quot;
 
He he he... If you really want efficiency I suggest you try looking for Agner Fog's 'How to optimize for the Pentium
family of microprocessors.' I got it in Windows' .hlp format if you don't want to search for it any more. Very nice document on how to optimize for most Intel processors, although it's kinda difficult to start reading it (hard to figure out where to start IMO).

SIB rocks especially with lea, you can add a constant, another number, and add another number that's shifted. Say you need to multiply by 9,
lea eax,[eax][eax*8]

very nasty optimization trick IMO since the Pentium tries to get it executed in one clock cycle (barring interlocks and stuff like that). &quot;Information has a tendency to be free. Which means someone will always tell you something you don't want to know.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top