The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: $nooc on February 09, 2008, 11:13:21 PM

Title: Hey, this actually doesn't work.
Post by: $nooc on February 09, 2008, 11:13:21 PM
after i set up MASM32 correctly my first step was to try if i can compile this sample: http://www.masm32.com/board/index.php?topic=257.0

but i get this error:

Quote
RC: fatal error RC1110: could not open rsrc.rc!

CVTRES: fatal error CVT1101: cannot open rsrc.res for reading

sry, i don't have any idea whats wrong..
Title: Re: Hey, this actually doesn't work.
Post by: GregL on February 10, 2008, 02:09:32 AM
$nooc,

Looks like you're trying to compile a resource file that doesn't exist. I assume you are using the MASM32 Editor. Select Project and then Console Assemble & Link from the menu.

Title: Re: Hey, this actually doesn't work.
Post by: $nooc on February 12, 2008, 09:26:17 PM
ok that works, but how can i check if my code is correct and doesn't has any mistakes for example syntax errors..

or another question:
does anyone know a link where the syntax of assembler is explained? because i don't even know how to call a function like getchar()
-> my program closes right after it appears on the screen..

i am an absolute beginner and it's quiet hard for me to learn that stuff in english.. so i really could need a page or something where everything is good explained for someone that doesn't know anything about assembler ^^
Title: Re: Hey, this actually doesn't work.
Post by: GregL on February 12, 2008, 09:57:15 PM
$nooc,

Glad to hear it's working.

Forum Links and Website (http://website.masm32.com/) (at the top of this page). There is a lot of stuff there, under "Technical Reference" get the "Intel Manuals", also "Iczelion's Tutorials" for a Windows tutorial.

Something I didn't see listed there is the MASM Programmer's Guide (http://www.box.net/shared/ubg3cejdr5).

Also, some free chapters (http://www.kipirvine.com/asm/) of a pretty good (although expensive) book. I recommend you start with these.


Title: Re: Hey, this actually doesn't work.
Post by: $nooc on February 13, 2008, 08:15:56 AM
thank you Greg!

i'll check those links as soon as i got home :)

god bless the internet   :cheekygreen:


thank you for your help!


edit:

one question (thats maybe a stupid one):
i red the first lines of chapter one of the book you advised me to. it says that it uses MASM 8.0 but i have the MASM 10.0 beta..
does this matter?
Title: Re: Hey, this actually doesn't work.
Post by: GregL on February 13, 2008, 08:01:18 PM
$nooc,

Quotedoes this matter?

No, there isn't anything he is doing in that book that MASM 6.14 can't handle. He's just using what was the latest and greatest at that time, it's not necessarily better. If you want to strictly follow along with his examples and use his libraries then you will need to download Visual Studio 2005 and MASM 8.0. MASM 8.0 can be downloaded here (http://www.microsoft.com/downloads/details.aspx?familyid=7a1c9da0-0510-44a2-b042-7ef370530c64&displaylang=en). I think you can get a lot out of the book without doing that though. Just adapt what he's doing to your own code and MASM32.

Quoteit says that it uses MASM 8.0 but i have the MASM 10.0 beta..

You mean you have MASM32 10.0 Beta. There is a difference between MASM32 and MASM. MASM32 is a package that includes MASM 6.14 along with include files, libraries, macros, tutorials and documentation. MASM is the Microsoft Macro Assembler itself (ML.EXE).






Title: Re: Hey, this actually doesn't work.
Post by: $nooc on March 28, 2008, 01:18:33 PM
hi guys!

i had to do a lot for school and so i didn't tried to learn assembler for that time.. bur now i got some ^^


maybe someone can answer me that questions:

when i compile the program that's listet below an error occurs..

R1110: file rsrc.rc could not be found..

i don't really know what that .rc file is and why my program need this file.. i don't even know 'where' the assembler is looking for that file..

but although.. the program seems to be executable.. the console appears and disappears the same second ( i know that's normal ^^)

at first i thought i should know how to call a function in assembler..

so i added the line:

invoke Beep,750,300

but nothing happens..
msdn says Bepp() requires Kernel32.dll.

i included that like this:

include \masm32\include\kernel32.inc

and i didn't forget the definitions:

includelib \masm32\lib\kernel32.lib

so why it doesnt make a sound?
Title: Re: Hey, this actually doesn't work.
Post by: $nooc on March 29, 2008, 10:21:12 AM
are the questions too stupid? ^^
Title: Re: Hey, this actually doesn't work.
Post by: MichaelW on March 29, 2008, 11:59:09 AM
The R1110 error is from the resource compiler, and since it ran without a resource definition file present it must have been invoked (if you are using Quick Editor you would do this by selecting Compile Resource File on the Project menu). The code for a complete application that uses the Beep function is  here (http://www.masm32.com/board/index.php?topic=4311.msg32253#msg32253). Again, if you are using Quick Editor you could build the EXE by pasting the source into the edit window, then save the source by selecting Save on the File menu, or by clicking the Save button on the toolbar, then select Console Assemble & Link from the Projects menu. Assuming the assemble and link succeeded (it should), you could then use the Run command on the Project menu to run it.
Title: Re: Hey, this actually doesn't work.
Post by: $nooc on March 30, 2008, 10:34:53 AM
well.. the program from the link (http://www.masm32.com/board/index.php?topic=4311.msg32253#msg32253) works, but if i try to call Beep in the other code:


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

;                 Build this with the "Project" menu using
;                       "Console Assemble and Link"

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .486                                    ; create 32 bit code
    .model flat, stdcall                    ; 32 bit memory model
    option casemap :none                    ; case sensitive

    include \masm32\include\windows.inc     ; always first
    include \masm32\macros\macros.asm       ; MASM support macros

  ; -----------------------------------------------------------------
  ; include files that have MASM format prototypes for function calls
  ; -----------------------------------------------------------------
    include \masm32\include\masm32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc

  ; ------------------------------------------------
  ; Library files that have definitions for function
  ; exports and tested reliable prebuilt code.
  ; ------------------------------------------------
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib

    .code                       ; Tell MASM where the code starts

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

start:                          ; The CODE entry point to the program

   
    print chr$("Hey, this actually works1",13,10)
    print chr$("Hey, this actually words2",13,10)
    invoke Beep, 750,300
   
    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start                       ; Tell MASM where the program ends



i only get a syntax error...
Title: Re: Hey, this actually doesn't work.
Post by: Vortex on March 30, 2008, 10:44:56 AM
Masm assembles the code above without any problem. What is the error message you receive?
Title: Re: Hey, this actually doesn't work.
Post by: $nooc on March 30, 2008, 10:56:19 AM
oh it was my fault! masm didn't save it!

if i save the code i always use CTRL+S but it seems like this doesn't always work..

masm assembles it and my speaker says: beeeep ^^

thank you !

but i have still some questions:

why is there no "invoke" in front of print?
what does the chr$ makro do? it is a makro, isn't it?
Title: Re: Hey, this actually doesn't work.
Post by: Vortex on March 30, 2008, 11:32:27 AM
print is a macro defined in macros.asm :

    print MACRO arg1:REQ,varname:VARARG      ;; display zero terminated string
        invoke StdOut,reparg(arg1)
      IFNB <varname>
        invoke StdOut,chr$(varname)
      ENDIF
    ENDM


chr$ is another macro defining NULL terminated strings in the data section :


chr$ MACRO any_text:VARARG
        LOCAL txtname
        .data
          txtname db any_text,0
        .code
        EXITM <OFFSET txtname>
      ENDM
Title: Re: Hey, this actually doesn't work.
Post by: MichaelW on March 30, 2008, 12:06:12 PM
Here is a version that uses only API functions:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      hStdOut   dd 0
      byteCount dd 0
      msg1      db "Hey, this actually does work!",13,10,13,10,0
      msg2      db "Press Enter to exit...",0
      buffer    db 0,0
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov hStdOut, eax
    invoke WriteFile,hStdOut,ADDR msg1,SIZEOF msg1 - 1,ADDR byteCount,NULL
    invoke Beep,750,300
    invoke Sleep,200
    invoke Beep,750,300
    invoke WriteFile,hStdOut,ADDR msg2,SIZEOF msg2 - 1,ADDR byteCount,NULL
    invoke GetStdHandle,STD_INPUT_HANDLE
    invoke ReadFile,eax,ADDR buffer,1,ADDR byteCount,NULL
    invoke ExitProcess,0
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start


Title: Re: Hey, this actually doesn't work.
Post by: Adamanteus on March 30, 2008, 12:30:42 PM
Here is a version of another name of macro :

TextAddr  MACRO any_text:VARARG
    EXITM chr$ (any_text)
ENDM
Title: Re: Hey, this actually doesn't work.
Post by: $nooc on April 01, 2008, 10:38:28 AM
thank you guys for your explanations :)
Title: Re: Hey, this actually doesn't work.
Post by: MrBogus on April 02, 2008, 06:40:30 PM
Quote from: Vortex on March 30, 2008, 11:32:27 AM
print is a macro defined in macros.asm :

    print MACRO arg1:REQ,varname:VARARG      ;; display zero terminated string
        invoke StdOut,reparg(arg1)
      IFNB <varname>
        invoke StdOut,chr$(varname)
      ENDIF
    ENDM


chr$ is another macro defining NULL terminated strings in the data section :


chr$ MACRO any_text:VARARG
        LOCAL txtname
        .data
          txtname db any_text,0
        .code
        EXITM <OFFSET txtname>
      ENDM


Where does StdOut came from? I've seached its declaration in macro.asm file but I haven't found any.
Just wanted to learn how print macro really works. Thanks.
Title: Re: Hey, this actually doesn't work.
Post by: Vortex on April 02, 2008, 06:50:34 PM
StdOut.asm can be found here :

\masm32\m32lib\stdout.asm
Title: Re: Hey, this actually doesn't work.
Post by: MrBogus on April 02, 2008, 07:01:35 PM
Thanks for the quick reply. But why is it that there is no statement such as this


include \masm32\m32lib\stdout.asm


in macros.inc file?
Title: Re: Hey, this actually doesn't work.
Post by: MichaelW on April 02, 2008, 10:42:04 PM
For MASM32 there is no macros.inc file - most of the MASM32 macros are in the file masm32\macros\macros.asm. Placing the statement:

include \masm32\m32lib\stdout.asm

In macros.asm would effectively include the source file in macros.asm, and this would cause multiple problems building any source that included macros.asm, starting with multiple model directives and duplicated include files. The source file stdout.asm, like the other source files for the MASM32 library, is structured so it can be assembled and linked into the library masm32.lib. A source can use the MASM32 library procedures by including masm32.lib and masm32.inc, along with the include files and libraries that the MASM32 library depends on, and the source can then call any of the macros in macros.asm without problems.