flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
revolution 19 May 2009, 05:43
You need to initialise your register first:
Code: ... start: mov eax,0 ;<--- start with a known value (can use 'xor eax,eax' if you want) add al,[Three] ... Code: ... start: movzx eax,[Three] ;<--- zero the upper part of EAX ... |
|||
![]() |
|
Misha06 19 May 2009, 05:56
That was what I originally tried to do, but every time I run the file Windows tells me the program has crashed.
Code: start: mov eax,0 mov al,[Three] ... |
|||
![]() |
|
Madis731 19 May 2009, 06:00
I will help you out - the working code:
EDIT: Moving eax-zeroing to the correct place Code: include 'win32ax.inc' .data Three db 3 Four db 4 ToPrint dd ? .code start: xor eax,eax add al,[Three] add al,[Four] add al,30h mov [ToPrint],eax invoke MessageBox, NULL,ToPrint,"Math", MB_OK invoke ExitProcess,0 .end start Last edited by Madis731 on 19 May 2009, 07:06; edited 1 time in total |
|||
![]() |
|
Misha06 19 May 2009, 06:05
Thank you for your time, but I believe thats what I originally had, and to my chagrin it gives me the same results
![]() Here, is a print screen of the crash that happens when I try to zero out eax register: http://yfrog.com/e9crashj |
|||
![]() |
|
revolution 19 May 2009, 06:07
Oh, this also needs to be:
Code: invoke MessageBox, NULL,ToPrint,"Math", MB_OK |
|||
![]() |
|
Misha06 19 May 2009, 06:09
Oh thank you but, the results are still odd - I get something like "^?xv"
|
|||
![]() |
|
revolution 19 May 2009, 06:10
The string in ToPrint needs to be null terminated. So setting the high part of EAX to zero gives you this.
|
|||
![]() |
|
Misha06 19 May 2009, 06:11
Okay, thank you now everything is working perfectly.
|
|||
![]() |
|
madmatt 19 May 2009, 06:25
One other little thing, the 'xor eax,eax' will never get executed in your data section, you should put that just below the 'start:' label.
|
|||
![]() |
|
Madis731 19 May 2009, 06:56
EDIT: a little too late
![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.