flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Release a variable |
Author |
|
revolution 15 Feb 2018, 11:20
What variable do you want to delete? I runtime variable in global space? A runtime variable in local space? An assembly time variable defined with "="? A preprocessor variable defined with "equ" or "define"?
|
|||
15 Feb 2018, 11:20 |
|
Mino 15 Feb 2018, 11:43
Here's a part of my code:
Code: macro writeln text { push text call [printf] push CRLF call [printf] } CRLF is a variable that makes a return to line, here: Code: CRLF db '',13,10,0 When I call my macro, like that: Code: writeln MyText Everything works well, so I get MyText with a return to line. However, when I call a second time in a row writeln with a second variable: Code: writeln MyText writeln MySecondText I'm getting this: Quote:
And of course, I would like him to show me this: Quote:
I imagined, at the end of my macro, to delete the variable. But on second thought, I don't think that's the best way to do it. Have I met your expectations? Thank you _________________ The best way to predict the future is to invent it. |
|||
15 Feb 2018, 11:43 |
|
revolution 15 Feb 2018, 12:44
CRLF is not actually a variable, it is a pointer. You can't delete it, it is part of the address space (presumably in global memory, but you don't show where it is).
But the code you posted doesn't appear to be wrong. Perhaps you can post an entire example that shows the problem. Last edited by revolution on 15 Feb 2018, 13:25; edited 2 times in total |
|||
15 Feb 2018, 12:44 |
|
Mino 15 Feb 2018, 13:04
Here's the complete code:
Code: format PE console entry main include 'INCLUDE\win32a.inc' section '.idata' data readable import library msvcrt, 'msvcrt.dll',\ kernel32, 'kernel32.dll' import msvcrt, printf, 'printf' import kernel32, ExitProcess, 'ExitProcess' section '.data' data readable writeable CRLF db '',13,10,0 ARGof_writeln1 db "Hello, world!" ARGof_writeln2 db "Bonjour le monde !" section '.code' code executable macro writeln text { push text call [printf] push CRLF call [printf] } macro end { call [ExitProcess] } main: push eax mov eax, ecx writeln ARGof_writeln1 writeln ARGof_writeln2 end _________________ The best way to predict the future is to invent it. |
|||
15 Feb 2018, 13:04 |
|
revolution 15 Feb 2018, 13:10
The problem here is that you haven't terminated the strings.
Code: ARGof_writeln1 db "Hello, world!",0 ;<--- add a terminating zero byte ARGof_writeln2 db "Bonjour le monde !",0 ;<--- add a terminating zero byte |
|||
15 Feb 2018, 13:10 |
|
Mino 15 Feb 2018, 13:21
It's a stupid mistake, actually.
Thank you for your help |
|||
15 Feb 2018, 13:21 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.