Hi! I have a couple of questions regarding the following functions:
function q_const(const x,c:INTEGER):INTEGER;
begin
if c=x then Result:=1 else result:=0;
end;
function q_var(var x,c:INTEGER):INTEGER;
begin
if c=x then Result:=1 else result:=0;
end;
The first thing I'd like to know is:
Both "var" and "const" imply by reference. Should the produced assembly code differ between the two functions?
The second thing I'd like to know is:
function q_var_jne(var x,c:integer):integer;assembler;register;
asm
movl (%rsi),%eax
cmpl (%rdi),%eax
jne .Lj6
.Ll2:
movl $1,%eax //RUNS SLOWER
jmp .Lj9
.Lj6:
movl $0,%eax
.Lj9:
end;
function q_var_je(var x,c:integer):integer;assembler;register;
asm
movl (%rsi),%eax
cmpl (%rdi),%eax
je .Lj6
.Ll2:
movl $0,%eax //RUNS SLOWER
jmp .Lj9
.Lj6:
movl $1,%eax
.Lj9:
end;
function q_const_jne(const x,c:integer):integer;assembler;register;
asm
cmpl %edi,%esi
jne .Lj6
.Ll2:
movl $1,%eax //RUNS SLOWER
jmp .Lj9
.Lj6:
movl $0,%eax
.Lj9:
end;
function q_const_je(const x,c:integer):integer;assembler;register;
asm
cmpl %edi,%esi
je .Lj6
.Ll2:
movl $0,%eax //RUNS SLOWER
jmp .Lj9
.Lj6:
movl $1,%eax
.Lj9:
end;
Is this the correct behavior when using je/jne? It appears like the code starting the label je/jne points to starts to be executed faster.