flat assembler
Message board for the users of flat assembler.
Index
> Windows > Access violation, Write Address = ffffffc |
Author |
|
revolution 01 May 2017, 14:00
PUSH and POP must be in reverse order from each other.
BTW: For Windows you only need to preserve EBX, EBP, ESI and EDI. |
|||
01 May 2017, 14:00 |
|
Sloppysecond 01 May 2017, 14:29
revolution wrote: PUSH and POP must be in reverse order from each other. Thank you. Now i've got such code : Code: push eax
push ebx
push ecx
push esi
push ebp
push esp
push edx
..................................
FINISH :
pop edx
pop esp
pop ebp
pop esi
pop ecx
pop ebx
pop eax
But anyway i'have got this exception in the end of the program. |
|||
01 May 2017, 14:29 |
|
revolution 01 May 2017, 14:42
It probably isn't a good idea to be PUSHing or POPing ESP. Also you can't use ESP as a general purpose register like that. Remember that ESP is the stack pointer so after you change it your stack is now lost.
|
|||
01 May 2017, 14:42 |
|
Sloppysecond 01 May 2017, 14:50
revolution wrote: It probably isn't a good idea to be PUSHing or POPing ESP. Also you can't use ESP as a general purpose register like that. Remember that ESP is the stack pointer so after you change it your stack is now lost. Ouch i didn't think about that. Will correct code using EDI. |
|||
01 May 2017, 14:50 |
|
VEG 01 May 2017, 15:17
Sloppysecond, it is better to use pushad and popad in your situation. It preserves/restores all registers in one command.
|
|||
01 May 2017, 15:17 |
|
Sloppysecond 01 May 2017, 15:29
revolution wrote: Remember that ESP is the stack pointer so after you change it your stack is now lost. Thank you! The problem was solved by changing using of ESP on the EDI. I guess without you i would kill many hours to understand this. Can you answer me on the theoretical question : 1)Why do we need to push some registers and after using pop them? From that do we preserve them? From changing by other threads? I have never did it before and used only ECX, EBX, EDX and EAX. But in this task more registers were needed. |
|||
01 May 2017, 15:29 |
|
Sloppysecond 01 May 2017, 15:32
VEG wrote: Sloppysecond, it is better to use pushad and popad in your situation. It preserves/restores all registers in one command. Thank you, i didn't know about this commands. Will read about them. |
|||
01 May 2017, 15:32 |
|
revolution 01 May 2017, 15:34
When you PUSH you save the value on the stack, and later you POP to recover the original value. It is part of the Windows calling standard, all functions are expected to not corrupt EBX, EBP, ESI and EDI.
|
|||
01 May 2017, 15:34 |
|
Sloppysecond 01 May 2017, 15:39
revolution wrote: When you PUSH you save the value on the stack, and later you POP to recover the original value. It is part of the Windows calling standard, all functions are expected to not corrupt EBX, EBP, ESI and EDI. Thank you. |
|||
01 May 2017, 15:39 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.