CONDITION ANALYSIS: "E97" BRICKS

Back to:
index Intel
I called bricks the short pieces of code, that "COMPAS" generate as a part of operator. Compiler builds result machine code from the bricks.

Step 1 (extract first operand to R1)

Step 2 (compare with the second operand)

Step 3 (jump, if condition is FALSE)

Examples of full condition


Condition analysis: step 1 (extract first operand to R1)

(see step 1 for assign operator)



Back to:
index top Intel

Condition analysis: step 2 (compare with the second operand)

Compare simple variable (e.g. a) or variable with concrete index (e.g. b[2]) with R1 (assume, that variable address is 90):
04E1 R1 - (90)
0090

Compare index variable (e.g. b[i]) with R1 (assume, that i address is 90 and b[0] address is D0):
01E2 (90) ==> R2
0090 i
0EA2 shift R2 (*2)
02D2 R2 + D0 ==> R2
00D0 b[0] address
0461 R1 - (R2)

Compare constant >15 with R1 (assume, that constant is 40):
04D1 R1 - 40
0040

Compare constant <=15 with R1 (assume, that constant is 1010=A16):
24A1 R1 - 10



Back to:
index top Intel

Condition analysis: step 3 (jump, if condition is FALSE)

Jump instructions for different conditions:
if result < 0 then ... 2C0D jump on >=0
{addr}
if result >= 0 then ... 3C0D jump on <0
{addr}
if result = 0 then ... 4C0D jump on <>0
{addr}
if result <> 0 then ... 5C0D jump on =0
{addr}
if result > 0 then ... 6C0D jump on <=0
{addr}
if result <= 0 then ... 7C0D jump on >0
{addr}



Back to:
index top Intel

Examples of full conditions

1. i < k (DE - address of variable i, DC - k)
01E1
00DE
(DE) ==> R1 Extract i
04E1
00DC
R1 - (DC) Compare i and k
2C0D
????
jump on >=0 Jump, if FALSE
Instead of ???? "COMPAS" will substitute concrete address.

2. 2 = a[i] (DE - address of variable i, D0 - a[0])
2121 2 ==> R1 Left part
01E2 DE ==> R2
00DE i address
0EA2 shift R2 (*2)
02D2 R2 + D0 ==> R2
00D0 a[0] address
Prepare a[i] address in R2
0461 R1 - (R2)
Compare a[i] with R1
4C0D jump if <>0
????
Jump, if FALSE



Back to:
index top Intel