News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

I buy a book and use masm32 study have problem

Started by yoursonfather, November 28, 2013, 07:24:34 AM

Previous topic - Next topic

yoursonfather

Assembly Language for x86 Processors, 6th edition
http://www.asmirvine.com/
i buy this book and author have his function(Irvine32.inc)
how can i  join it(Irvine32.inc) in the masm32



TITLE Add and Subtract              (AddSubAlt.asm)

; This program adds and subtracts 32-bit integers.
; 32-bit Protected mode version

.386
.MODEL flat,stdcall
.STACK 4096

ExitProcess PROTO,dwExitCode:DWORD
DumpRegs PROTO        ;book say this is MS-window function but i can not success

.code
main PROC

   mov   eax,10000h      ; EAX = 10000h
   add   eax,40000h      ; EAX = 50000h
   sub   eax,20000h      ; EAX = 30000h
   call   DumpRegs

   INVOKE ExitProcess,0
main ENDP
END main



dedndave

in the upper right corner - there is a link for downloading the Masm32 package
it wants to be installed in the root directory of the drive that you intend to store projects on

i haven't really mixed the 2 together - i think Jochen did it without too much hassle, though

DumpRegs is an Irvine32 function, i think

you want to start out with
        INCLUDE     Irvine32.inc
        INCLUDE     GraphWin.inc

;the following INCLUDELIB's may not be required if using VisualStudio - comment them out

        INCLUDELIB  Kernel32.lib
        INCLUDELIB  User32.lib
        INCLUDELIB  Irvine32.lib


that takes care of the model and processor, as well (view Irvine32.inc for details)
then, DumpRegs should work

dedndave

ExitProcess PROTO,dwExitCode:DWORD
no comma after PROTO....
ExitProcess PROTO dwExitCode:DWORD

dedndave

notice that i set the paths for the include and library files
you may have to alter the paths to suit your setup
or - remove the paths altogether if you are using visual studio
if you set up projects like Kip shows you in the book, visual studio knows where they are
        INCLUDE     C:\Irvine\Irvine32.inc
        INCLUDE     C:\Irvine\GraphWin.inc

;the following INCLUDELIB's may not be required if using VisualStudio - comment them out

        INCLUDELIB  C:\Irvine\Lib32\Kernel32.lib
        INCLUDELIB  C:\Irvine\Lib32\User32.lib
        INCLUDELIB  C:\Irvine\Lib32\Irvine32.lib

;###############################################################################################

        .DATA

;initialized data goes here

szMessage db 'Hello World !",0

;***********************************************************************************************

        .DATA?

;uninitialized data goes here

;###############################################################################################

        .CODE

;***********************************************************************************************

_main   PROC

        mov     edx,offset szMessage
        call    WriteString

        call    WaitMsg
        exit

_main   ENDP

;###############################################################################################

        END     _main

jj2007

1. As Dave already wrote, you need to install the Masm32 package
2. Irvine32Mb.inc is included in the MasmBasic package, and allows free mixing of Irvine32, Masm32 and MasmBasic syntax.
3. JWasm must be installed as \Masm32\bin\JWasm.exe

include \masm32\MasmBasic\MasmBasic.inc                ; download
include \masm32\MasmBasic\IrvineMb\Irvine32Mb.inc        ; needed to build Irvine's (many but not all) 32-bit examples

TITLE Add and Subtract              (AddSubAlt.asm)

; This program adds and subtracts 32-bit integers.
; 32-bit Protected mode version

.code
main PROC
        mov   eax,10000h      ; EAX = 10000h
        add   eax,40000h      ; EAX = 50000h
        sub   eax,20000h      ; EAX = 30000h
        call   DumpRegs
        Inkey CrLf$, "bye"
        exit
main endp
end main


P.S.: Instead of DumbRegs, you could use deb:
  deb 4, "On entry:", eax, ebx, ecx, edx, esi, edi, x:ebp, x:esp, ST(0), ST(1), ST(2), f:xmm0, xmm0, xmm1, xmm2, xmm3, xmm4, xmm5

It takes registers, local and global variables, and some more ;-)

yoursonfather

Quote from: dedndave on November 28, 2013, 07:32:33 AM
ExitProcess PROTO,dwExitCode:DWORD
no comma after PROTO....
ExitProcess PROTO dwExitCode:DWORD

i put   "Example programs and link library source code for Visual Studio 2012" all in the masm32 include 
it can Compiler
but i   click "AddSub2.exe"  not thing work






TITLE Add and Subtract, Version 2         (AddSub2.asm)

; This program adds and subtracts 32-bit integers
; and stores the sum in a variable.

INCLUDE D:\masm32\include\Irvine32.inc
INCLUDE D:\masm32\include\GraphWin.inc
INCLUDELIB  D:\masm32\include\Kernel32.lib
INCLUDELIB  D:\masm32\include\User32.lib
INCLUDELIB  D:\masm32\include\Irvine32.lib

.data
val1     dword  10000h
val2     dword  40000h
val3     dword  20000h
finalVal dword  ?

.code
main PROC

mov eax,val1 ; start with 10000h
add eax,val2 ; add 40000h
sub eax,val3 ; subtract 20000h
mov finalVal,eax ; store the result (30000h)
call DumpRegs ; display the registers

exit
main ENDP
END main

dedndave

you put the Irvine includes in the masm32\include folder ?
not sure that's a good idea

if you installed masm32 on the D: drive, the project must be on the D: drive
and, you don't really want to put the drive letter in the includes
    INCLUDE     \masm32\include\masm32rt.inc
the masm32 package is designed to use root-relative paths

not sure where you put the Irvine32 includes and libraries
but, you could put them in D:\Irvine or D:\masm32\Irvine
i guess you can put them in D:\masm32\include - but, i wouldn't do it that way

no matter where you put them, make sure the paths match the location
the LIB files are in the LIB folder - the INC files are in the INCLUDE folder
notice that \masm32\lib folder also has a kernel32.lib and user32.lib - that's why i would use different folders
INCLUDELIB  D:\masm32\include\Kernel32.lib
INCLUDELIB  D:\masm32\include\User32.lib
INCLUDELIB  D:\masm32\include\Irvine32.lib


you have it as LIB files in the INCLUDE folder - unless you put the files there, it shouldn't assemble

jj2007

Quote from: yoursonfather on November 28, 2013, 08:57:22 AM
it can Compiler
but i   click "AddSub2.exe"  not thing work

Try from a commandline prompt. Most probably, VS forgets to keep the console window open (decent editors like MasmBasic's RichMasm detect a console program automatically and wait for a keystroke after the exe finishes ;)).

dedndave

also, Irvine has a function called WaitMsg - similar to masm32's "inkey" macro
both have an "exit" macro, which can cause a conflict, actually

    call    WaitMsg
    INVOKE  ExitProcess,0

yoursonfather


1.is this code"ExitProcess PROTO,dwExitCode:DWORD
DumpRegs PROTO"    need Visual Studio?  i do not have this
i install new ml.exe(8.0) but  still when i click "my program.exe" not this happen

2.if my computer do not have any Operating system can i control cpu?or gpu? how can them write first program?





thank dedndave and jj2007 answer me  :t   i trying all day masm32  and Language .they are double hard


i will trying Visual Studio2010 for free.......

dedndave

well - you're probably trying to bite off more than you can chew   :biggrin:

what i mean is, you are trying to get both Irvine32 and Masm32 working at the same time
assembly language requires some patience, at first
and, it's easier if you take things 1 step at a time
trying to set up and learn assembly language, Irvine, masm32, and Visual Studio all at once is too much

today is a holiday, here in the US
but, tomorrow, we can spend more time to get you up and running
we can do a program using just Irvine and a program using just Masm32
then, move forward from there

the first meaningful program is likely to be some sort of operating system
i mean - it's one thing to write some code to make a machine do something
but, until you can edit and save the program, it's just playing around   :P
the first program i wrote was in the form of hexadecimal values entered into an EPROM burner - lol
and, the EPROM burner we had wasn't very forgiving - it had minimal edit capabilities

once you get to where you can save files to a disk (or a tape, back then),
you can write an assembler to make programming easier
once they had one computer up and running - they likely wrote cross-assemblers
when IBM developed the code for their first PC, they probably did so using an IBM 360/380 mainframe
(heaven forbid they use an atari or similar)

my older brother worked for a company that put together Altair 8080 computers - lol
the operating system was microsoft basic 1.0, and it loaded from an 8" floppy disk
you turned it on, put the disk in, typed "boot" or something similar - and went and got coffee