flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Mac2004 12 Jun 2009, 18:18
Everhest: Areyou setting ES segment register properly before using scasd?
This is first thing that comes into my mind. Regards, Mac2004 |
|||
![]() |
|
Everhest 12 Jun 2009, 18:22
o_0 Why?
|
|||
![]() |
|
LocoDelAssembly 12 Jun 2009, 18:30
It won't work because it is requiring the <13, 10, 13, 10> sequence to be located at dword boundaries (i.e., EDI is incremented by 4 each time instead of 1). repne scasd is useful for dword arrays, but for searching patterns in strings it is not.
A possible solution (untested) would be the following: Code: proc GetHeaderLenght Header cld mov edi, [Header] mov ecx, 4096 mov eax, 0A0D0A0Dh ; This is the correct number to search for the <$0d, $0a, $0d, $0a> pattern .find$0D: repne scasb cmp ecx, 3 jb .notFound cmp [edi-1], eax jne .find$0D add edi, 3 .exit: mov eax, edi sub eax, [Header] ret .notFound: lea edi, [edi+ecx] jmp .exit endp |
|||
![]() |
|
Mac2004 12 Jun 2009, 19:09
eg.
Code: mov eax, ES_SELECTOR mov es, eax Using edi is actually using es:edi register pair and thus es register needs to be set properly. This link may help you a bit? http://faydoc.tripod.com/cpu/scasd.htm Regards Mac2004 |
|||
![]() |
|
LocoDelAssembly 12 Jun 2009, 19:34
Mac2004, it should be AX instead of EAX but yet I don't think that he is experiencing that problem too as 32-bit OSes not satisfying DS=ES=SS are rare (if there is really any).
Also, since he is using the proc macro, it is very likely he is using Windows, so, ES should be already set correctly (unless it was explicitly changed by him somewhere). [edit] By DS=ES=SS I mean the memory space those segments are allowing to access. Typically all of them four allow to access the entire 4 GB address space (i.e., "mov eax, [seg:edi]" should produce the same result no matter which one of the four seg you choose).[/edit] [edit2] Where I've said "four" it is "three"[/edit] Last edited by LocoDelAssembly on 13 Jun 2009, 04:54; edited 1 time in total |
|||
![]() |
|
Mac2004 13 Jun 2009, 04:22
Loco: I guess I'am so much used to 'assuming nothing' due to fact that I do my programming under plain protected mode.
So there's no OS to do anything for me.. |
|||
![]() |
|
Everhest 13 Jun 2009, 06:19
People BIG thank you...
|
|||
![]() |
|
Mac2004 13 Jun 2009, 07:09
Everhest: I guess you managed to solve the problem. That's good
![]() Regards, Mac2004 |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.