flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution 26 Jan 2012, 03:31
EAX is not preserved by the API calls. Read about the "standard call" convention. EAX, ECX, EDX, EFLAGS are freely clobbered and you should not expect them to have the same value after you call an API function.
|
|||
![]() |
|
NanoBytes 26 Jan 2012, 03:39
I realize that, but if EAX where to change, that should not change the value in [EBP+-8]
|
|||
![]() |
|
sinsi 26 Jan 2012, 03:42
Code: cinvoke wsprintf,String1,'%d',EBX EAX maybe, not EBX? |
|||
![]() |
|
revolution 26 Jan 2012, 03:43
Well you should at least match the registers then
Code: MOV EAX,dword[EBP+-8];Move the parameters address into the source pointer cinvoke wsprintf,String1,'%d',EBX Last edited by revolution on 26 Jan 2012, 04:09; edited 1 time in total |
|||
![]() |
|
NanoBytes 26 Jan 2012, 03:55
I used both, to make sure that the problem was not comeing from just EAX, or just EBX
|
|||
![]() |
|
NanoBytes 26 Jan 2012, 12:27
Ok, i figured out the problem, but I cant figure out why it is doing it
Code: MOV EAX,dword[EBP+-8] cinvoke wsprintf,String1,'%d',EAX invoke WriteConsole,[outhandle],String1,EAX,0,0 cinvoke wsprintf,String1,'%c',10 invoke WriteConsole,[outhandle],String1,EAX,0,0 MOV EAX,dword[EBP+-4]; <---------------- CHANGED cinvoke wsprintf,String1,'%d',EBX invoke WriteConsole,[outhandle],String1,EAX,0,0 the address ate [EBP+-8] is moved up by 4, so now the address is stored in [EBP+-4] and I cant figure out why? _________________ He is no fool who gives what he cannot keep to gain what he cannot loose. |
|||
![]() |
|
revolution 26 Jan 2012, 14:15
NanoBytes wrote: the address ate [EBP+-8] is moved up by 4, so now the address is stored in [EBP+-4] and I cant figure out why? |
|||
![]() |
|
AsmGuru62 26 Jan 2012, 14:40
@NanoBytes:
This line: Code: cinvoke wsprintfA,buf,'%d',eax produces a strange code in debugger, which you should use btw. Stepping over this line produces Access Violation - which it should. I think it is because of '%d' used on the line. Try to declare it beside the 'buf' and pass the address like so: Code: str_Format db '%d',0 str_Buf rb 16 ... cinvoke wsprintfA,str_Buf,str_Format,eax |
|||
![]() |
|
revolution 26 Jan 2012, 15:05
AsmGuru62 wrote: @NanoBytes: |
|||
![]() |
|
AsmGuru62 26 Jan 2012, 17:37
So, which version of win32.inc will produce proper code?
|
|||
![]() |
|
NanoBytes 27 Jan 2012, 03:34
See, my program was made using my (very flaud) compiler, and includes several inclusion file, and is entwined with all of them, it would take longer to decipher what the code does, than it would to fix the problem. BTW, EBX stays the same, i checked, which means that the stack itself is being modified, which makes no sense because 'wsprintf' shouldn't affect the stack.
|
|||
![]() |
|
revolution 27 Jan 2012, 03:37
NanoBytes: Don't blame the wrong thing, wsprintf does not affect the stack or EBP. Indeed the entire Windows API does not alter the stack or EBP. You need to look elsewhere to find your problem.
|
|||
![]() |
|
AsmGuru62 27 Jan 2012, 04:55
As I mentioned - see what wsprintf does in debugger - the call itself isn't right with '%d' passed as parameter. But if you pass it as a variable - it works.
|
|||
![]() |
|
revolution 27 Jan 2012, 05:29
AsmGuru62 wrote: As I mentioned - see what wsprintf does in debugger - the call itself isn't right with '%d' passed as parameter. But if you pass it as a variable - it works. |
|||
![]() |
|
AsmGuru62 27 Jan 2012, 15:33
@revolution: so, where then the string '%d' gets allocated? On stack, on heap or inside code section?
|
|||
![]() |
|
mindcooler 27 Jan 2012, 15:41
Right in the code where its address is pushed (called) onto the stack.
|
|||
![]() |
|
AsmGuru62 27 Jan 2012, 17:24
So, it mixes data and code?
|
|||
![]() |
|
LocoDelAssembly 27 Jan 2012, 18:10
AsmGuru62,
This is what the x/xp versions of the includes do: Code: ;cinvoke printf '%d', eax push eax call @f db '%d', 0 @@: ; It actually doesn't use an anonymous label but a local label (but the code has exactly this same pattern) call [printf] add esp, 8 |
|||
![]() |
|
AsmGuru62 27 Jan 2012, 19:29
Cool, but...
Intel says that it is bad for performance to mix it. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.