The assembly code below is equivalent to:

a=1;
b=1;
if(a=b){
x=2+2
}

It is generated code so don't worry about inefficiency. My problem is when I use the sete command I get the error "error: invalid combination of opcode and operands". Here is the code:

[list -]
%include 'win32n.inc'
[list +]

section .bss use32
section .data use32
section .code use32
	cpu 386

extern WriteFile
extern GetStdHandle
extern ExitProcess
import WriteFile kernel32.dll
import GetStdHandle kernel32.dll
import ExitProcess kernel32.dll

section .code

..start:
push	STD_OUTPUT_HANDLE
call	[GetStdHandle]			;Get stdout
mov	 [stdout_handle], eax	  ;Save the handle

mov		eax, 1
mov		[A], eax
mov		eax, 1
mov		[B], eax
mov		eax, [A]
push 	eax
mov		eax, [B]
pop		ebx
cmp 	eax, ebx
sete 	eax
test 	eax, 0
jz	L0
mov		eax, 2
push	eax
mov		eax, 2
pop		ebx
add		eax, ebx
mov		[X], eax
L0:
add		dword [X], 48

;Write a message to stdout
push	dword 0
push	dword 0
push	dword textlen
push	dword X
push	dword [stdout_handle]
call	[WriteFile]
jmp exit

exit:
push	dword 0					;Point at error code
call	[ExitProcess]
jmp		exit					;Should never reach here

section .data

stdout_handle	dd	0
string			dd	0
textlen			equ	$ - string
A			dd 0
X			dd 0
B			dd 0

What am I doing wrong?

Nevermind, the operand needs to be 16 bits, not 32.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.