Lab2

# makefile for program 1

PROJECT = Lab2

NAME = Sheng_Jiang

Date = 5/25/05

ROOTDRIVE = C

VERSION = V1

SRCS =

$(PROJECT).asm

makefile

MASM32 = $(ROOTDRIVE):/masm32

ML = $(MASM32)/bin/ml

LINK = $(MASM32)/bin/link

Zip = H:/mydoc/Tools/Bin/zip

MLFLAGS = /I. /I $(MASM32)include /Zi /Zd /Zf /c /Fl /coff /Cp

LINKFLAGS = /subsystem:console /libpath:$(MASM32)lib

all: $(PROJECT).exe

$(PROJECT).obj: $(PROJECT).asm

$(ML) $(MLFLAGS) $(PROJECT).asm

$(PROJECT).exe: $(PROJECT).obj

$(LINK) $(LINKFLAGS) $(PROJECT).obj

clean:

del $(PROJECT).exe *.obj *.lst *.map

zip: clean

del $(NAME)_$(PROJECT)_$(VERSION).zip

$(Zip) $(NAME)_$(PROJECT)_$(VERSION).zip $(SRCS)

;=====================================================================

; hello.asm – Example Assembler program

; Propose: a program that displays the following information on the console:

; Line 1: full name

; Line 2: birthday

; Line 3: ACC student ID number

; Line 4: preferred email address

; Course: COSC 2425

; Author: Sheng Jiang

; Date: 5/23/05

;=====================================================================

.386

.MODEL flat, stdcall

; define a few constants

cr equ 0dh

lf equ 0ah

STD_OUTPUT_HANDLE equ -11

; win32 declarations

; kernel32.exe

GetStdHandle proto near32 stdcall,

nStdHandle:dword

WriteFile proto near32 stdcall,

hfile:dword, lpbuff:near32,

lmsg:dword, lwrt:near32, lpovr:near32

ExitProcess proto near32 stdcall,

dwExitCode:dword

;masm32 includes

include masm32.inc

includelib masm32.lib

;win32 includes

includelib kernel32.lib

;variables

.DATA

;Handle of the standard output

nStdHandle dword ?

;string to print

lpBuffer BYTE ‘Sheng Jiang’,cr,lf,”,cr,lf,”,cr,lf,’sheng_jiang’,cr,lf,0

;string length

nNumberOfBytesToWrite dword $-lpBuffer

;bytes written

nNumberOfBytesWritten dword ?

.CODE

SayHello PROC

; first get a handle to stdout for output from win32

invoke GetStdHandle, STD_OUTPUT_HANDLE

; save it for later

mov nStdHandle,eax

; now print the message – lots of parameters needed for this one!

invoke WriteFile, nStdHandle, near ptr lpBuffer, nNumberOfBytesToWrite, near ptr nNumberOfBytesWritten,0

; go back to the operating system when done

invoke ExitProcess, 0

SayHello ENDP

END SayHello

About Sheng Jiang 蒋晟

Microsoft MVP in Visual C , 2004- Forum moderator of the Visual C and .Net forums on CSDN Forum moderator of Chinese forums on Microsoft's MSDN forums
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s