;It's work.

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
stm SYSTEMTIME<>
dayformat db "%02u/",0
monthformat db "%02u/",0
yearformat db "%04u",0
dateformat db "dd/MM/yyyy",0
buffer db 10 dup (0)

.code
start:
invoke GetLocalTime, addr stm
mov ax,stm.wYear
invoke wsprintf, ADDR buffer, ADDR dayformat, stm.wDay
invoke lstrcpy, ADDR dateformat,ADDR buffer
invoke wsprintf, ADDR buffer, ADDR monthformat, stm.wMonth
invoke lstrcat, ADDR dateformat,ADDR buffer
invoke wsprintf, ADDR buffer, ADDR yearformat, stm.wYear
invoke lstrcat, ADDR dateformat,ADDR buffer
invoke MessageBox, 0, addr dateformat, NULL, MB_OK
invoke ExitProcess,NULL
end start

;but
;-----------------------------------------------------------------------------------
;It isn't work

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

ShowDate PROTO

.data
stm SYSTEMTIME<>
dayformat db "%02u/",0
monthformat db "%02u/",0
yearformat db "%04u",0
dateformat db "dd/MM/yyyy",0
buffer db 10 dup (0)

.code
start:
ShowDate proc
invoke GetLocalTime, addr stm
mov ax,stm.wYear
invoke wsprintf, ADDR buffer, ADDR dayformat, stm.wDay
invoke lstrcpy, ADDR dateformat,ADDR buffer
invoke wsprintf, ADDR buffer, ADDR monthformat, stm.wMonth
invoke lstrcat, ADDR dateformat,ADDR buffer
invoke wsprintf, ADDR buffer, ADDR yearformat, stm.wYear
invoke lstrcat, ADDR dateformat,ADDR buffer
ret
ShowDate endp

invoke ShowDate
invoke MessageBox, 0, addr dateformat, NULL, MB_OK
invoke ExitProcess,NULL
end start

;What's wrong?
Posted on 2002-07-17 21:55:46 by fox
Try putting your proc before start:



ShowDate proc
invoke GetLocalTime, addr stm
mov ax,stm.wYear
invoke wsprintf, ADDR buffer, ADDR dayformat, stm.wDay
invoke lstrcpy, ADDR dateformat,ADDR buffer
invoke wsprintf, ADDR buffer, ADDR monthformat, stm.wMonth
invoke lstrcat, ADDR dateformat,ADDR buffer
invoke wsprintf, ADDR buffer, ADDR yearformat, stm.wYear
invoke lstrcat, ADDR dateformat,ADDR buffer
ret
ShowDate endp

start:

....
:)
Posted on 2002-07-17 22:00:06 by stryker
thanks.
But it still wrong,I can't find out what's wrong!


.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

ShowDate PROTO

.data
stm SYSTEMTIME<>
dayformat db "%02u/",0
monthformat db "%02u/",0
yearformat db "%04u",0
dateformat db "dd/MM/yyyy",0
buffer db 10 dup (0)

.code
ShowDate proc
invoke GetLocalTime, addr stm
invoke wsprintf, ADDR buffer, ADDR dayformat, stm.wDay
invoke lstrcpy, ADDR dateformat,ADDR buffer
invoke wsprintf, ADDR buffer, ADDR monthformat, stm.wMonth
invoke lstrcat, ADDR dateformat,ADDR buffer
invoke wsprintf, ADDR buffer, ADDR yearformat, stm.wYear
invoke lstrcat, ADDR dateformat,ADDR buffer
ret
ShowDate endp
start:
invoke ShowDate
invoke MessageBox, 0, addr dateformat, NULL, MB_OK
invoke ExitProcess,NULL
end start
Posted on 2002-07-17 22:10:38 by fox
.386

.MODEL FLAT, STDCALL
OPTION CASEMAP:NONE
INCLUDE \masm32\INCLUDE\windows.inc
INCLUDE \masm32\INCLUDE\kernel32.inc
INCLUDE \masm32\INCLUDE\user32.inc
INCLUDELIB \masm32\LIB\user32.lib
INCLUDELIB \masm32\LIB\kernel32.lib
INCLUDE \masm32\INCLUDE\masm32.inc
INCLUDELIB \masm32\LIB\masm32.lib

.DATA

g_STM SYSTEMTIME<>
g_dbSlash DB "/", 0

.DATA?

g_dbTempbuf DB 5 DUP(?)
g_dbBuffer DB 20 dup (?)

.CODE

ShowDate PROC

invoke GetLocalTime, OFFSET g_STM

xor eax, eax
mov ax, g_STM.wDay
invoke dwtoa, eax, OFFSET g_dbBuffer
invoke lstrcat, OFFSET g_dbBuffer, OFFSET g_dbSlash

xor eax, eax
mov ax, g_STM.wMonth
invoke dwtoa, eax, OFFSET g_dbTempbuf
invoke lstrcat, OFFSET g_dbBuffer, OFFSET g_dbTempbuf
invoke lstrcat, OFFSET g_dbBuffer, OFFSET g_dbSlash

xor eax, eax
mov ax, g_STM.wYear
invoke dwtoa, eax, OFFSET g_dbTempbuf
invoke lstrcat, OFFSET g_dbBuffer, OFFSET g_dbTempbuf

ret

ShowDate ENDP

START:

call ShowDate
invoke MessageBox, NULL, OFFSET g_dbBuffer, NULL, MB_OK
invoke ExitProcess,NULL

END START
:) Not Optimized.
Posted on 2002-07-17 22:29:21 by stryker
Thank you!
Posted on 2002-07-17 22:40:37 by fox