News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

I can't declare variables

Started by Sergiu FUNIERU, March 03, 2010, 12:17:07 AM

Previous topic - Next topic

Sergiu FUNIERU

I'm trying to create a program that will make a new folder, with the current time as its name.
Something like:
2009.03.02_04.05.01

I'm stripped a part of the code from one examples in the \examples folder. The original program was designed to display the current date on the push of a button.

1. I don't understand why I receive errors when I try to declare the variables.

2. Can I declare a variable anywhere in the program?

3. I want to add a leading zero to the everything that's one digit.
Example:
I want to change the hour "7" from "7", to "07".

I was thinking of this code:
   movzx eax, stm.wMonth
   mov month, ustr$(eax)
   .if eax < 10
      mov month, cat$ (month, "0", ustr$(eax))         
   .endif
   
Is it okay to do two operations before copying the result to month?

My current form of this code is :
.686
.model flat, stdcall
option casemap :none
 
include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\gdi32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Comctl32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\shell32.inc
include \masm32\include\oleaut32.inc
include \masm32\include\msvcrt.inc
include \masm32\include\dialogs.inc
include \masm32\macros\macros.asm

includelib \masm32\lib\masm32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\oleaut32.lib
includelib \masm32\lib\msvcrt.lib


.code

start:
 
call main
invoke ExitProcess,eax

main proc

str1:DWORD
str2:DWORD
str3:DWORD
str4:DWORD
str5:DWORD
str6:DWORD

hour:DWORD
minute:DWORD
second:DWORD
year:DWORD
month:DWORD
day:DWORD

stm:SYSTEMTIME

buffer1[260]:BYTE
buffer2[260]:BYTE
buffer3[260]:BYTE
buffer4[260]:BYTE

mov str1, ptr$(buffer1)
mov str2, CTXT(" second")
mov str3, CTXT(" seconds")
mov str5, CTXT(" AM")
mov str6, CTXT(" PM")

invoke GetTime,ADDR stm
.if stm.wHour > 11
  m2m str5, str6
.endif

movzx eax, stm.wHour
mov hour, ustr$(eax)

movzx eax, stm.wMinute
mov minute, ustr$(eax)

movzx eax, stm.wYear
mov year, ustr$(eax)


movzx eax, stm.wMonth
mov month, ustr$(eax)
.if eax < 10
mov month, cat$ (month, "0", ustr$(eax))
.endif

movzx eax, stm.wDay
mov day, ustr$(eax)

movzx eax, stm.wSecond
push eax
.if eax > 1
  m2m str2, str3
.endif
pop eax
mov second, ustr$(eax)

mov str1, cat$(str1, year, "." , month,  ".", day, "_", hour, ".", minute, ".", second)

mkdir str1

end start

jj2007

Quotemain proc
LOCAL str1:DWORD
LOCAL str2:DWORD
LOCAL str3:DWORD
LOCAL str4:DWORD
LOCAL str5:DWORD
LOCAL str6:DWORD

LOCAL hour:DWORD
LOCAL minute:DWORD
LOCAL second:DWORD
LOCAL year:DWORD
LOCAL month:DWORD
LOCAL day:DWORD

LOCAL stm:SYSTEMTIME

LOCAL buffer1[260]:BYTE
LOCAL buffer2[260]:BYTE
LOCAL buffer3[260]:BYTE
LOCAL buffer4[260]:BYTE

mov str1, ptr$(buffer1)
mov str2, CTXT(" second")
mov str3, CTXT(" seconds")
mov str5, CTXT(" AM")
mov str6, CTXT(" PM")

invoke GetSystemTime, ADDR stm
.if stm.wHour > 11
  m2m str5, str6
.endif

movzx eax, stm.wHour
mov hour, ustr$(eax)

movzx eax, stm.wMinute
mov minute, ustr$(eax)

movzx eax, stm.wYear
mov year, ustr$(eax)


movzx eax, stm.wMonth
mov month, ustr$(eax)
.if eax < 10
mov month, cat$ (month, "0", ustr$(eax))
.endif

movzx eax, stm.wDay
mov day, ustr$(eax)

movzx eax, stm.wSecond
push eax
.if eax > 1
  m2m str2, str3
.endif
pop eax
mov second, ustr$(eax)

mov str1, cat$(str1, year, "." , month,  ".", day, "_", hour, ".", minute, ".", second)

mkdir str1
  ret
main endp