flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Main > Invalid operands

Author
Thread Post new topic Reply to topic
Mino



Joined: 14 Jan 2018
Posts: 104

Invalid operands

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 kernel32ExitProcess'ExitProcess'
import msvcrtprintf'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.texteax
mov wpostf.frmtecx
cinvoke printfwpostf.frmtwpostf.text
ret
main:
push eax
mov eaxecx
mov eaxwpostf_41
mov ecxwpostf_18467
call wpostf
invoke ExitProcess0




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: 15733
Location: Crossing the Cauchy horizon

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: 104

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


Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2018, Tomasz Grysztar.
Powered by rwasa.