News:

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

Main Menu

MASM in Windows 7

Started by Evan, November 25, 2013, 12:44:52 PM

Previous topic - Next topic

Evan

I managed to get a hello world console working with MASM in Windows 7.

I'm feeling a little confused about everything.

print "Hello World",13,10
Is all I understand.

dedndave

masm syntax is probably what you want

http://masm32.com/board/index.php?topic=2468.msg26081#msg26081

not the easiest document in the world to understand
rather than reading it like a book, i use it more as a reference
i.e. i look up a specific subject and read about it

Vortex

Hi Evan,

Checking \masm32\macros\macros.asm, you can find the code of the printf macro.


hamper

Hi Evan,

Sounds like you're at the start of a long and thoroughly enjoyable learning process  :t

This little program is very useful for outputting values to the console when you are working your way through assembly language programming, checking things out, and finding out how everything works. You can build it as a console application even when you (eventually) get into programming your first windows application (in which case it displays the console as well as the window).


;######################################################################################
; Output to console using printf and print          CONSOLE BUILD            conout.asm
;######################################################################################

; Make sure any floating point values are declared as real8
; Make sure any integer values are declared as either sdword or dword

; printf operates in the normal C manner and can take the following format specifiers:
; i signed integer
; u unsigned integer
; f floating point
; All the usual escape sequences can be used, for example \n

; print outputs any predefined nul-terminated string
;    so assuming for example you have already defined
;       mystring byte "hello",13,10,0
;    then the syntax is
;       print addr mystring

;--------------------------------------------------------------------------------------

.686
.model flat, stdcall
option casemap :none

; the following are the MINIMUM include and includelib files required for printf and
; print to function properly, but you may need to include others depending on what you
; wish to do if it is more than the small example shown below

include kernel32.inc
include macros.asm
include msvcrt.inc
include masm32.inc

includelib kernel32
includelib msvcrt
includelib masm32

.data
mysdword sdword -1234
mydword  dword 5678
myreal8  real8 123.456789
mystring byte "Hello, World",13,10,0

.code
start:

printf("My sdword is %i\n",mysdword)
printf("My dword is  %u\n",mydword)
printf("My real8 is  %f\n",myreal8)
print addr mystring

printf("\n\n")
exit

end start


You need to get hold of a copy of the "Microsoft MASM Programmer's Guide". I think (if memory serves) that it's included in one of the zip files that includes the updated version of the assembler ml.exe, maybe available from Iczelion's site (which also has a lot of useful examples and guidance).

If you do manage to get hold of a copy, have a look through the section dealing with simplified segment directives. It gives good information about how programs are structured under the "flat" memory model.


Avizma

Hi Evan!
I think, the book by Vlad Pirogov "The Assembly Programming Master Book ", will be very helpful for you.