×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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 "hello world" program in assembly? lol

Need help!

Thank you

Sérgio Oliveira


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

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

"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"

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

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).

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

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

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.

"People who have nothing to say, say it too loud and have little knowledge. It's the quiet ones you need to worry about!"

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

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).

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close