Ok, I'm writing a parser for a "image watching" program that checks to see if an image on the web has been updated by checking the HTML header's "last-modified:" section...

I've successfully parsed the line (for example)
wed28nov200120:50:08gmt

but I want to store the values that I have into a more manageable string of numbers... So the above would be

20011128205008
or
(year)(month)(day)(hour)(minute)(second)
This way I could write the day to the file name

20011128205008logo.gif
(if the file name was logo)

I could then easily parse this string and compare the values to the Header file (and see if a newer version of the image was avaiable)

The problem is... I have all the values broken into their respective numbers (not strings) and I don't know hwo to put them back in the order I want)...

I'd really appreciate if someone could help me put the numbers back into a string like : 20011128205008

Here is the code so far (not optimized -- ie. used "lodsb" and "stosb" instead of mov al, byte ptr )

any quick and ditry solution would be just as helpful :)

Sliver



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

Main PROTO
ParseHeaderDate PROTO :DWORD
ParseHeaderDate PROC uses esi ecx edi StringDate:DWORD
LOCAL MyDate[100]:BYTE
LOCAL TempString[10]:BYTE
LOCAL WeekDay:DWORD
LOCAL Day:DWORD
LOCAL Month:DWORD
LOCAL Year:DWORD
LOCAL Hour:DWORD
LOCAL Minute:DWORD
LOCAL Second:DWORD

;Date = wed28nov200120:50:08gmt
invoke lstrcpy,addr MyDate,StringDate

invoke StrLen,addr MyDate
mov ecx,eax

lea esi, MyDate
mov ecx, 6
@@:
push ecx

mov edi, DAYS[ecx*4]

mov ecx,2
repe cmpsb
je @F

lea esi, MyDate

pop ecx
dec ecx
jnz @B
@@:
pop ecx
inc ecx
mov WeekDay, ecx
PrintDec WeekDay
;Date = d28nov200120:50:08gmt
inc esi
;Date = 28nov200120:50:08gmt
lea edi, TempString
lodsb
stosb
lodsb
stosb
mov byte ptr [edi],0
invoke a2dw, addr TempString
mov Day, eax
PrintDec Day
;Date = nov200120:50:08gmt

mov eax, esi
mov ecx, 11
@@:
push ecx

mov edi, MONTHS[ecx*4]

mov ecx,2
repe cmpsb
je @F

mov esi, eax

pop ecx
dec ecx
jnz @B
@@:
pop ecx
inc ecx
mov Month, ecx
PrintDec Month
inc esi
;Date = 200120:50:08gmt
lea edi, TempString
lodsb
stosb
lodsb
stosb
lodsb
stosb
lodsb
stosb
mov byte ptr [edi],0
invoke a2dw, addr TempString
mov Year, eax
PrintDec Year
lea edi, TempString
lodsb
stosb
lodsb
stosb
mov byte ptr [edi],0
invoke a2dw, addr TempString
mov Hour, eax
PrintDec Hour
inc esi
lea edi, TempString
lodsb
stosb
lodsb
stosb
mov byte ptr [edi],0
invoke a2dw, addr TempString
mov Minute, eax
PrintDec Minute
inc esi
lea edi, TempString
lodsb
stosb
lodsb
stosb
mov byte ptr [edi],0
invoke a2dw, addr TempString
mov Second, eax
PrintDec Second
inc esi
ret
ParseHeaderDate endp



.data
TestDate db "wed28nov200120:50:08gmt",0

_mon db "mon",0
_tue db "tue",0
_wed db "wed",0
_thu db "thu",0
_fri db "fri",0
_sat db "sat",0
_sun db "sun",0

_jan db "jan",0
_feb db "feb",0
_mar db "mar",0
_apr db "apr",0
_may db "may",0
_jun db "jun",0
_jul db "jul",0
_aug db "aug",0
_sep db "sep",0
_oct db "oct",0
_nov db "nov",0
_dec db "dec",0

; array of pointers to our strings
DAYS dd offset _mon, offset _tue, offset _wed,\
offset _thu, offset _fri, offset _sat, offset _sun
MONTHS dd offset _jan, offset _feb, offset _mar, \
offset _apr, offset _may, offset _jun, offset _jul, \
offset _aug, offset _sep, offset _oct, offset _nov, \
offset _dec


.code

start:
invoke Main
invoke ExitProcess,0

; #########################################################################

Main proc
invoke ParseHeaderDate, addr TestDate
ret
Main endp

end start
Posted on 2002-04-01 01:38:00 by Sliver
Since I'm too lazy to look at your code ;) I suggest you placed that inside a structure for easier access and clearer code. Now here's the plan:

1. Use dwtoa function from the masm library to convert the individual numbers into strings.
2. concatenate all the converted numbers into one final string buffer.
3. compare them...

year -> dwtoa -> tmpBufr -> lstrcat with the final buffer
month -> dwtoa -> tmpBufr -> lstrcat with the final buffer
...
string compare...

I know this is not the best solution but I have to get some snooze. :)
Posted on 2002-04-01 01:48:33 by stryker