I am having soooo much fun with assembly! How is this code? I modified some code from here to read a file line by line and extract my fields (kinda like a CSV). Anyway to tweak it? Had problems at first cause everything in my struct was dwords (showed me garbage till I chaneged most to bytes) got excited I finally gotten it to work, gonna go get a few Coronas....

Each line in the file has 9 fileds:
Any Image?FMJ-Software\Any Image?0???LastDirs.?0??????
Architag XRay XML Editor?VB and VBA Program Settings\Architag XRay XML Editor\RecentFiles?0???file?0??????
ASFRecorder?ASFRecorder\RecentURLList?2???URL?0??????



Structure:
MRUSTUFF STRUCT
DisplayName BYTE 100 dup (?)
MRUPath BYTE MAX_PATH dup (?)
ParseType DWORD ?
SectionName BYTE 100 dup (?)
ValueName BYTE 100 dup (?)
ValueBase DWORD ?
Count BYTE 100 dup (?)
DataType BYTE 2 dup (?)
ExeName BYTE MAX_PATH dup (?)
MRUSTUFF ends

.data?
MRUInfo MRUSTUFF <>


; Parse file line by line and extract between commas
push esi
push edi
mov esi, hTempBuf ;buffer returned from HeapAlloc

DisplayName:
lea edi, offset MRUInfo.DisplayName
@@:
mov al, byte ptr [esi]
inc esi
cmp al, '?'
je MRUPath
mov byte ptr [edi], al
inc edi
jmp @B

MRUPath:
mov byte ptr [edi], NULL
lea edi, offset MRUInfo.MRUPath
@@:
mov al, byte ptr [esi]
inc esi
cmp al, '?'
je ParseType
mov byte ptr [edi], al
inc edi
jmp @B

ParseType:
mov byte ptr [edi], NULL
lea edi, offset MRUInfo.ParseType
@@:
mov al, byte ptr [esi]
inc esi
cmp al, '?'
je SectionName
mov byte ptr [edi], al
inc edi
jmp @B

SectionName:
lea edi, offset MRUInfo.SectionName
@@:
mov al, byte ptr [esi]
inc esi
cmp al, '?'
je ValueName
mov byte ptr [edi], al
inc edi
jmp @B

ValueName:
mov byte ptr [edi], NULL
lea edi, offset MRUInfo.ValueName
@@:
mov al, byte ptr [esi]
inc esi
cmp al, '?'
je ValueBase
mov byte ptr [edi], al
inc edi
jmp @B

ValueBase:
mov byte ptr [edi], NULL
lea edi, offset MRUInfo.ValueBase
@@:
mov al, byte ptr [esi]
inc esi
cmp al, '?'
je Count
mov byte ptr [edi], al
inc edi
jmp @B

Count:
lea edi,offset MRUInfo.Count
@@:
mov al, byte ptr [esi]
inc esi
cmp al, '?'
je DataType
mov byte ptr [edi], al
inc edi
jmp @B

DataType:
mov byte ptr [edi], NULL
lea edi, offset MRUInfo.DataType
@@:
mov al, byte ptr [esi]
inc esi
cmp al, '?'
je ExeName
mov byte ptr [edi], al
inc edi
jmp @B

ExeName:
mov byte ptr [edi], NULL
lea edi, offset MRUInfo.ExeName
@@:
mov al, byte ptr [esi]
inc esi
cmp al, 0DH ; CR
je NewLine
cmp al, NULL
je Done
mov byte ptr [edi], al
inc edi
jmp @B

NewLine:
; add items to listview here
add esi, 1
PrintStringByAddr offset MRUInfo.DisplayName
PrintStringByAddr offset MRUInfo.MRUPath
PrintStringByAddr offset MRUInfo.ParseType
PrintStringByAddr offset MRUInfo.SectionName
PrintStringByAddr offset MRUInfo.ValueName
PrintStringByAddr offset MRUInfo.ValueBase
PrintStringByAddr offset MRUInfo.Count
PrintStringByAddr offset MRUInfo.DataType
PrintStringByAddr offset MRUInfo.ExeName
PrintLine
jmp DisplayName

Done:
; add last line to listview here
PrintStringByAddr offset MRUInfo.DisplayName
PrintStringByAddr offset MRUInfo.MRUPath
PrintStringByAddr offset MRUInfo.ParseType
PrintStringByAddr offset MRUInfo.SectionName
PrintStringByAddr offset MRUInfo.ValueName
PrintStringByAddr offset MRUInfo.ValueBase
PrintStringByAddr offset MRUInfo.Count
PrintStringByAddr offset MRUInfo.DataType
PrintStringByAddr offset MRUInfo.ExeName
pop edi
pop esi

; Free memory for temporary buffer
invoke HeapFree, hHeap, NULL, addr hTempBuf


So, what I have here is basically the same as a do/while loop in VB?
I will get this damn VB proggie converted sooner or later:-)

Thanks
Posted on 2002-11-04 19:33:42 by Gunner
You might want to go here, peel and see a Basic parser done in asm :grin: :

http://hitchhikr.multimania.com


cheers,

h.
Posted on 2002-11-04 20:11:56 by hitchhikr