 |
|
IF OPERATOR: INTEL EXAMPLES |
Back to:
Examples of full operators
Here you can see the results of full conditional operators translation.
You may need to look for some details about conditions coding
and how assign operator is compiling.
1. IF x<0 THEN s := -1 ELSE s := 1; (4FE - address of variable x, 4FC - s)
| Address, code | Operations | Pascal comments |
|
286 A1 FE 04
| mov ax,[04FE]
| Extract x
|
289 B9 00 00
28C 39 C8
| mov cx,0
cmp ax,cx
| Is x < 0 ?
| |
28E 7D 08
| jge 298 (if >=0)
| Jump to ELSE branch
| | |
290 B8 FF FF
293 A3 FC 04 |
mov ax,ffff (i.e. -1)
mov [04FC],ax |
THEN s := -1;
| |
296 EB 06 |
jmp 29E |
ELSE bypass | | |
298 B8 01 00
29B A3 FC 04
|
mov ax,1
mov [04FC],ax |
ELSE s := 1;
| | | |
29E |
2. IF x<0 THEN s := -1; (4FE - address of variable x, 4FC - s)
This short form of IF operator can be easily derived from the previous example
by removal of ELSE branch and its bypass:
| Address, code | Operations | Pascal comments |
|
286 A1 FE 04
| mov ax,[04FE]
| Extract x
|
289 B9 00 00
28C 39 C8
| mov cx,0
cmp ax,cx
| Is x < 0 ?
| |
28E 7D 06
| jge 296 (if >=0)
| Jump to next operator
| | |
290 B8 FF FF
293 A3 FC 04 |
mov ax,ffff (i.e. -1)
mov [04FC],ax |
THEN s := -1;
| | | |
296 |
3. IF b THEN c := '0' ELSE c := '1'; (4FD - address of BOOLEAN variable b, 4FC - c)
| Address, code | Operations | Pascal comments |
299 A0 FD 04
29C 30 E4
| mov al,[04FD]
xor ah,ah (clear ah) | Extract b (byte value)
|
29E B9 00 00
2A1 39 C8
| mov cx,0
cmp ax,cx
| Is b <> 0 (TRUE)?
|
2A3 74 08
| jz 2AD (if =0)
| Jump to ELSE branch if FALSE
| | |
2A5 B8 30 00
2A8 A2 FC 04 |
mov ax,30
mov [04FC],ax |
THEN c := '0';
| |
2AB EB 06 |
jmp 2B3 |
ELSE bypass | | |
2AD B8 31 00
2B0 A2 FC 04 |
mov ax,31
mov [04FC],al |
ELSE c := '1';
| | | |
2B3 |
Back to:
|