File second2.asm :
.386
.model flat,stdcall
option casemap:none
includelib d:\masm32\lib\kernel32.lib
includelib d:\masm32\lib\user32.lib
includelib d:\masm32\lib\msvcrt.lib
includelib d:\masm32\lib\masm32.lib
includelib d:\masm32\lib\gdi32.lib
include d:\masm32\include\kernel32.inc
include d:\masm32\include\user32.inc
include d:\masm32\include\windows.inc
include d:\masm32\include\gdi32.inc
include d:\masm32\include\masm32.inc
;********************************************************************
;数据段
;********************************************************************
.data
HelloMsg DB "Hello World", 0 ;*
CRLF DB 00Ah, 00Dh, 0
ExitMsg DB "Enter to Exit", 0
.data?
buffer DB ?
.code
Start:
invoke StdOut, addr HelloMsg ;*
invoke StdOut, addr CRLF
invoke StdOut, addr ExitMsg
invoke StdIn, addr buffer, 1
invoke ExitProcess, 0 ;*
End Start
;********************************************************************
编译:
ml /c /coff /Cp second2.asm
link /subsystem:CONSOLE second2.obj
;********************************************************************
.386
.model flat,stdcall
option casemap:none
includelib d:\masm32\lib\kernel32.lib
includelib d:\masm32\lib\user32.lib
includelib d:\masm32\lib\msvcrt.lib
includelib d:\masm32\lib\masm32.lib
includelib d:\masm32\lib\gdi32.lib
include d:\masm32\include\kernel32.inc
include d:\masm32\include\user32.inc
include d:\masm32\include\windows.inc
include d:\masm32\include\gdi32.inc
include d:\masm32\include\masm32.inc
; ------------
; Local macros
; ------------
print MACRO Quoted_Text:VARARG
LOCAL Txt
.data
Txt db Quoted_Text,0
.code
invoke StdOut,ADDR Txt
ENDM
input MACRO Quoted_Prompt_Text:VARARG
LOCAL Txt
LOCAL Buffer
.data
Txt db Quoted_Prompt_Text,0
Buffer db 128 dup(?)
.code
invoke StdOut,ADDR Txt
invoke StdIn,ADDR Buffer,LENGTHOF Buffer
mov eax, offset Buffer
ENDM
cls MACRO
invoke ClearScreen
ENDM
Main PROTO
; #########################################################################
.data
Msg1 db "Type something > ",0
Msg2 db "You typed > ",0
; #########################################################################
.code
start:
invoke Main
invoke ExitProcess,0
; #########################################################################
Main proc
LOCAL InputBuffer[128]:BYTE
; -------------------------------
; console mode library procedures
; -------------------------------
; ------------
; using macros
; ------------
cls
print "Console function test",13,10,13,10
input "Enter Some Text > "
invoke StdOut,eax ; return address in eax
; ----------------
; using procedures
; ----------------
invoke locate,10,10
invoke StdOut,ADDR Msg1
invoke StdIn,ADDR InputBuffer,LENGTHOF InputBuffer
invoke locate,10,11
invoke StdOut,ADDR Msg2
invoke StdOut,ADDR InputBuffer
ret
Main endp
; #########################################################################
end start
.386
.model flat,stdcall
option casemap:none
includelib d:\masm32\lib\kernel32.lib
includelib d:\masm32\lib\user32.lib
includelib d:\masm32\lib\msvcrt.lib
includelib d:\masm32\lib\masm32.lib
includelib d:\masm32\lib\gdi32.lib
include d:\masm32\include\kernel32.inc
include d:\masm32\include\user32.inc
include d:\masm32\include\windows.inc
include d:\masm32\include\gdi32.inc
include d:\masm32\include\masm32.inc
.data
aHelloWorld db 'hello world',0 ; DATA XREF: _main+30o
.code
start:
_main proc near
var_C0= byte ptr -0C0h
push ebp
mov ebp, esp
sub esp, 0C0h
push ebx
push esi
push edi
lea edi, [ebp+var_C0]
mov ecx, 30h
mov eax, 0CCCCCCCCh
rep stosd
push 1100h ; int
push 8899h ; int
;call ; fun(int,int)
add esp, 8
push offset aHelloWorld ; " hello world"
;call j__printf
invoke StdOut,ADDR aHelloWorld
add esp, 4
xor eax, eax
pop edi
pop esi
pop ebx
add esp, 0C0h
cmp ebp, esp
;call j___RTC_CheckEsp
mov esp, ebp
pop ebp
retn
_main endp
end start