Assembler ebx,ecx registers do not work?

DSP related issues, mathematics, processing and techniques
Post Reply
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Assembler ebx,ecx registers do not work?

Post by KG_is_back »

Following code (while loop) works fine when eax is used, but crashes if any other register is used (in this example ebx). It also crashes if one of mentioned registers is in any way involved in counting loop index.

Code: Select all

streamout out;
float F1=1;
push ebx;

mov ebx,32;
loopjmp:
sub ebx,32;
jl finish;

//this code doesn't matter (it only counts loop length)
   movaps xmm0,out;
   addps xmm0,F1;
   movaps out,xmm0;

jmp loopjmp;
finish:

pop ebx;

is this a bug? or am I doing something wrong?

even following code crashes:

Code: Select all

streamout out;
float F1=1;
push ebx;

mov eax,32;
mov ebx,eax;
loopjmp:
mov eax,ebx;
sub eax,32;
jl finish;
mov ebx,eax;
//this code doesn't matter (it only counts loop length)
   movaps xmm0,out;
   addps xmm0,F1;
   movaps out,xmm0;

jmp loopjmp;
finish:

pop ebx;

it seems to me that "mov" instructions are buggy...
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Assembler ebx,ecx registers do not work?

Post by martinvicanek »

Confirmed. Even an ASM hop will crash if you replace eax by ebx:

This works:

Code: Select all

streamout dummy;
float F1=1;
mov eax,ecx; and eax,7; cmp eax,0; jnz end0;
movaps xmm0,dummy;
addps xmm0,F1;
movaps dummy,xmm0;
end0:

This crashes:

Code: Select all

streamout dummy;
float F1=1;
mov ebx,ecx; and ebx,7; cmp ebx,0; jnz end0;
movaps xmm0,dummy;
addps xmm0,F1;
movaps dummy,xmm0;
end0:
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Assembler ebx,ecx registers do not work?

Post by KG_is_back »

I think I know what the issue is:
You can also now use ebx, ecx and edx in the following opcodes:

add reg, reg
add reg, var
sub reg, reg


there is no "sub reg, integer"
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: Assembler ebx,ecx registers do not work?

Post by MyCo »

The e-registers support is very chaotic... thought Malc would sort it out, but it got worse. eg. "sub reg,int" only works with eax, while "add reg,int" works only with eax and ebx, and "and reg,int" works with eax,ebx,ecx but not edx... and so on... you basically have to check if the opcode output has something in it for every instruction.

In the latest version, "add/sub reg,reg" also support edx, edi and ebp... although you can't push/pop them for rescuing content... and the opcode output for ebp and edi are the same, so they are obviously wrong.

It's such a mess...
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Assembler ebx,ecx registers do not work?

Post by Tronic »

psrld
Work for you?
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Assembler ebx,ecx registers do not work?

Post by martinvicanek »

nope
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: Assembler ebx,ecx registers do not work?

Post by Tronic »

grrr :x
Post Reply