Author Topic: error: symbol `msg' undefined  (Read 20582 times)

iwcoetzer

  • Guest
error: symbol `msg' undefined
« on: September 28, 2008, 01:10:35 PM »
Hi

I'm new to NASM - I downloaded the binaries and RadASM IDE and I'm currently trying to build an example .asm file.

I'm stuck with this error message:

C:\Nasm\Bin\NASMW -fobj "beer.asm"
beer.asm:26: error: symbol `msg' undefined
beer.asm:29: error: symbol `msg' undefined
beer.asm:32: error: symbol `msg' undefined
beer.asm:66: error: phase error detected at end of assembly.

Make error(s) occured.
Total compile time 969 ms


What could be the problem?

Thanks

nobody

  • Guest
Re: error: symbol `msg' undefined
« Reply #1 on: September 28, 2008, 01:49:44 PM »
Ahhh... "msg" could be undefined... Is this beer.asm like "99 bottles of", or does this open the CD tray so you've go someplace to put your beer? I see a "_message" in the latter (Fasm example), but no "msg"...

What you should see, assuming you've got like "push msg", is:

msg db " bottles of beer"

(probably zero-terminated) or so. Look for a mismatch in spelling. Nasm is case sensitive. Possible "wrap"???

If all else fails, post the code!

Best,
Frank

iwcoetzer

  • Guest
Re: error: symbol `msg' undefined
« Reply #2 on: September 28, 2008, 02:08:23 PM »
Hi, yes it is the CD opener example:


This is what it complains about ...

cmp dword [msg],WM_INITDIALOG
    je wm_initdialog

cmp dword [msg],WM_COMMAND
    je near wm_command

cmp dword [msg],WM_CLOSE
    je near wm_close


Here is the full code listing:




;============================================================================
;  Program name: Beer
;  Author: Yeoh HS
;  Date: 14 October 2003
;  Compiler: NASM + RadAsm
;  Purpose: To eject CDROM drive
;           Also demonstrate how to include icon and version info in program.
;
;============================================================================

%include 'C:\Documents and Settings\Ian\Desktop\Programming\Common\nagoa.inc'

[segment code USE32]

..start:
        call   GetModuleHandleA, NULL
        CONST   hInst , dd 0
        mov       [hInst], eax
        call   DialogBoxParamA, [hInst],DIALOG_ID, 0,DialogProc, 0
        call   ExitProcess, [hInst]


; ============ [ MAIN DIALOLOG PROC ] =====================:
proc DialogProc,hdlg,msg,wParam,lParam

cmp dword [msg],WM_INITDIALOG
    je wm_initdialog

cmp dword [msg],WM_COMMAND
    je near wm_command

cmp dword [msg],WM_CLOSE
    je near wm_close

return FALSE

;---------------------------------------------
    wm_initdialog:
       call LoadIcon, [hInst], IDI_ICON
       call mciSendString, cmd_open, NULL, 0,NULL
       call mciSendString, cmd_eject, NULL, 0,NULL
       call mciSendString, cmd_close, NULL, 0, NULL
       call ExitProcess,0
    return TRUE


    wm_command:
       ;
    return TRUE


    wm_close:
       call ExitProcess,0
    return FALSE

endproc
; ============== [ MAIN DIALOGPROC  END ] =============== :

[segment data USE32]

DIALOG_ID       equ  1000
IDI_ICON        equ  1
cmd_open        db 'open cdaudio',0
cmd_eject       db 'set cdaudio door open',0
cmd_close       db 'close cdaudio',0
;-----------------------------------------------------------

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: error: symbol `msg' undefined
« Reply #3 on: September 28, 2008, 05:34:30 PM »
Okay, looks like "msg" is supposed to be defined as "ebp + 12" - or possibly as "esp + 8"... The "proc" macro in nagoa+.inc should be taking care of that for you! I don't know why it's not.

Y'know what? It almost looks like that macro is using "@" prepended to local and parameter variable names. Try replacing "msg" with "@msg" and see if it helps.

In any case, it should be "ebp + 12". If you give Nasm the "-e" switch, it'll emit preprocessed code - what gets sent to the assembler. Might help you debug why that macro isn't doing the expected thing... but the more I look at it, the more I think "@msg" is right...

Best,
Frank