I want to be able to load a byte from a char array in reg a 8 bit reg so i can cmp it with anther char from a char arrray.
here is what i've tried:
int strsrcha(char* srchin,char* srch,int start=0)
int alen=strlen(srchin),blen=strlen(srch),numr=0;

mov eax,blen
cmp eax,alen
jbe no2
return -2;

for(int a=start; a<alen; a++)

mov eax,a
mov al,srchin
mov eax,numr
mov bl,srch
cmp al,bl
jne else1

inc numr

mov eax,numr
cmp eax,blen
jne endofloop
return a-blen+1;

mov eax,numr
dec eax
mov al,srch
mov ebx,a
mov bl,srchin
cmp al,bl
jne no3
dec a
mov numr,0

return -1;

i get 4 of thses errors how can i fix this?
error C2443: operand size conflict
Posted on 2003-05-03 01:21:06 by Josh160
loading a byte from a char array to an 8 bit register:
#include <stdio.h>

int main()
char x[] = "test";
mov al, BYTE PTR [x]
mov ah, BYTE PTR [x+1]
mov dl, BYTE PTR [x+2]
mov dh, BYTE PTR [x+3]
xchg al, dl
xchg ah, dh
mov BYTE PTR [x], al
mov BYTE PTR [x+1], ah
mov BYTE PTR [x+2], dl
mov BYTE PTR [x+3], dh
printf("%s", x);
Tested on VC6 :)

operand size conflicts happen when your loading or storing a value greater than what a register or memory can handle or size mismatch.

for example:

mov eax, dl

assuming variable ds is BYTE or WORD size

mov ds, eax

EAX here is a 32 bit, you cannot load a 32 bit register to a 8 or 16 bit memory/register


p.s. would be nice if you point to us the offending code so it would be easier to debug immediately. :grin:

:grin: I'm too lazy to copy, paste and compile. :grin: :grin:
Posted on 2003-05-03 02:10:14 by arkane