flat assembler
Message board for the users of flat assembler.

Index > Main > Invalid operands

Author
Thread Post new topic Reply to topic
Mino



Joined: 14 Jan 2018
Posts: 163
Mino 03 Mar 2018, 00:29
Hello,
I don't understand the mistake I made. The compiler tells me "Error: invalid operands", but I don't really understand why... Maybe you already told me that, but then I've already forgotten (sorry if that's the case).
Without further delay, here is all my code (the names of the variables, parameters,... may seem "strange", this is not too much the problem here. I don't even think it's one of them:

Code:
format PE console
entry main
section '.idata' data readable import
include 'INCLUDE\win32a.inc'
library msvcrt, 'msvcrt.dll', \ 
        kernel32, 'kernel32.dll'
import kernel32, ExitProcess, 'ExitProcess'
import msvcrt, printf, 'printf'
section '.data' data readable writeable
wpostf.text db ?
wpostf.frmt db ?
wpostf_41 db "Hello", 0
wpostf_18467 db "%s", 0
section '.code' code executable
wpostf:
mov wpostf.text, eax
mov wpostf.frmt, ecx
cinvoke printf, wpostf.frmt, wpostf.text
ret
main:
push eax
mov eax, ecx
mov eax, wpostf_41
mov ecx, wpostf_18467
call wpostf
invoke ExitProcess, 0
    


Would you help me Very Happy ?
Thank you and have a nice day.

_________________
The best way to predict the future is to invent it.
Post 03 Mar 2018, 00:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20453
Location: In your JS exploiting you and your system
revolution 03 Mar 2018, 04:48
You need square brackets about memory operands that are targets or sources.
Code:
mov [wpostf.text], eax    
But also note that you only allocated one byte with db, yet you are trying to store 4 bytes with eax. Perhaps you should increase the storage size:
Code:
wpostf.text dd ?    
Also:
Code:
cinvoke printf, [wpostf.frmt], [wpostf.text]    
Post 03 Mar 2018, 04:48
View user's profile Send private message Visit poster's website Reply with quote
Mino



Joined: 14 Jan 2018
Posts: 163
Mino 03 Mar 2018, 11:01
Thank you:)
Your solution works well, was indeed the size (db) that was not enough.
Post 03 Mar 2018, 11:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.