You are on page 1of 15

Lecture 4.

Main unprivileged
commands - II

Command: ROR receiver, counter


Purpose: Cyclic shift to the right

Command: ROL receiver, counter


Purpose: Cyclic shift to the left

Command: RCR receiver, counter


Purpose: Cyclic shift to the right through the
carryover flag

Command: RCL receiver, counter


Purpose: Cyclic shift to the left through the
carryover flag
Lecture 4. Main unprivileged
commands - II

Figure 9. Cyclic shifts


Lecture 4. Main unprivileged
commands - II
Operations with bits and bytes
Command: BTS base, shift
Purpose: Checking and installing bit

Command: BTR base, shift


Purpose: Checking and resetting bit

Command: BTC base, shift


Purpose: Checking and inverting bit

Command: BSF receiver, source


Purpose: Direct search of bit

Command: BSR base, shift


Purpose: Inverse search of bit
Lecture 4. Main unprivileged
commands - II

Command: SETcc receiver


Purpose: Byte installation on a condition
Lecture 4. Main unprivileged
commands - II
Table 6. SETcc commands
Lecture 4. Main unprivileged
commands - II

Commands of control transfer


Command: JMP operand
Purpose: Unconditional transition
Depending on transition type there distinguish:
transition of short type (short transition) — if transition address is ranging from -127 to +128 bytes form the JMP
command;
transition of near type (near transition) — if transition address is in the same segment as the JMP command;
transition of far type (far transition) — if transition address is in the other segment. Also far transition may be
executed in the same segment, if in segment part of operand there is a number, coinciding with the CS current
value;
transition with task switching — control transfer to other task in the multitask environment.

Command: Jcc label


Purpose: Conditional transition
Lecture 4. Main unprivileged
commands - II
Table 7. Options of the Jcc command
Lecture 4. Main unprivileged
commands - II
Command: JCXZ label
Purpose: Transition, if CX = 0

Command: JECXZ label


Purpose: Transition, if ECX = 0

Command: LOOP label


Purpose: Loop

mov cx,0Ah
loop_start: add ax,cx
loop loop_start

The LOOP command is completely equivalent to the couple of


commands
dec ecx
jz label
Lecture 4. Main unprivileged
commands - II
Command: LOOPE label
Purpose: Cycle, while there is equal

Command: LOOPZ label


Purpose: Cycle, while there is zero

Command: LOOPNE label


Purpose: Cycle, while there is not equal

Command: LOOPNZ label


Purpose: Cycle, while there is not zero

mov cx,str_length
move_loop: stosb
lodsb
cmp al,13
loopnz move_loop
Lecture 4. Main unprivileged
commands - II

Command: CALL operand


Purpose: Procedure call

Command: RET number


RETN number
RETF number
Purpose: Return from procedure

Command: INT number


Purpose: Interruption call

Command: IRET
IRETD
Purpose: Return from the interruption handler
Lecture 4. Main unprivileged
commands - II

Command: INT3
Purpose: Call of interruption 3

Command: INTO
Purpose: Call interruption 4 at overflow

Command: BOUND index, boundaries


Purpose: Checking exit from massive boundaries

Command: ENTER size, level


Purpose: Entrance to procedure
Lecture 4. Main unprivileged
commands - II

Figure 10. Stack frame of procedure of the 0th level (MAIN)


Lecture 4. Main unprivileged
commands - II

Figure 11. Stack frame of procedure of the 1st level (PROCA)


Lecture 4. Main unprivileged
commands - II

Figure 12. Stack frame of procedure of the 2nd level (PROCB)


Lecture 4. Main unprivileged
commands - II

Command: LEAVE
Purpose: Exit from procedure

You might also like