Reputation: 113
I want to create an application that shows an array of character in console with x86 assembly language. i write it in Visual Studio 2012 Ultimate Version. In addition my Windows is 7 64 bit. When run it in compiler, I mean in visual studio, I've this error:
main.cpp(8): error C2443: operand size conflict
main.cpp(11): error C2432: illegal reference to 16-bit data in 'second operand'
My code is:
void main(){
char nameAndId[] = "name:mohammad mahdi derakhshani .\n";
int sc=-1;
while(nameAndId[sc++]!=0){
_asm{
push si
line 8: mov si,sc
xor edx,edx
line 10: mov dl,nameAndId[si]
mov ah,2
int 21h
pop si
}
}
}
How can i fix this problem?
Upvotes: 0
Views: 444
Reputation: 1104
You are using 16-bit SI
register instead of 32-bit one ESI
.
For the other side, I don't know if int 21
still works but I recommend to get a pointer to WriteConsoleA
api using GetProcAddress
and call the api instead of using the old d.o.s. functions.
Third: When the loop begins, sc
equal -1, so you reference nameAndId[-1]
. Change sc++
with ++sc
.
Upvotes: 1