4 4 Bit Manipulation Instructions Shift instructions SHLSAL
4. 4 Bit Manipulation Instructions Shift instructions: SHL/SAL, SHR, SAR Examples: initial value in AX= 0110111100000001 B CF=0 0 SAL AX, 1 AX=1101111000000010 B lost AX=11111100000 B SAR AX, 4 CF=0 Shift instructions: SHLD, SHRD Examples: CX=0 BC 3 H; SHRD AX, CX, 4 unchanged AX= 5678 H CF=1 CX=0 BC 3 H; AX= 3567 H
4. 4 Bit Manipulation Instructions Rotate instructions: ROL, ROR, RCL, RCR Examples: initial value in AX= 0110111100000001 B CF=0 ROL AX, 1 AX=1101111000000010 B ROR AX, 4 AX=0010110111100000 B CF=0 Examples: initial value in AX= 0110111100000001 B and CF=1 RCL AX, 1 AX=1101111000000011 B CF= 0 RCR AX, 4 AX=0110110111100000 B CF=0
4. 5 Program Transfer Instructions JMP Short jump address is computed adding the signed byte operand to the address of the first byte following the JMP instruction. LOOP, LOOPE/LOOPZ, LOOPNE/LOOPNZ JCXZ, JECXZ
4. 5 Program Transfer Instructions Jcc The terms “less” and “greater” are used for comparisons of signed integers. The terms “above” and “below” are used for comparisons of unsigned integers.
4. 5 Program Transfer Instructions CALL RET … 0100 0103 … 0204 0207 … 0500. . . 0550 CALL EXSUB ADD AX, 1 CALL EXSUB ADD AX, 2 EXSUB PROC NEAR RET EXSUB ENDP Assembler directives Stack: specifying the begin 1 FFE ? ? 03 SP 07 and the end of a 1 FFF ? ? 01 02 NEAR or FAR 2000 ? ? SP procedure (subroutine) 2000
4. 5 Program Transfer Instructions INT … IPT= Interrupt 0000: 0084 Pointer Table 0000: 0085 0000: 0086 IRET, IRETD 0000: 0087 … 0100: 00 FF 0100: 0101 0100: 0103 INTO, BOUND B 4 16 26 07 4*21 H=84 H MOV AH, 2 CH; INT 21 H ADD AX, 1 … 0726: 16 B 4 ISR for INT 21. . . … IRET Stack: 1 FFA ? ? 03 SP 1 FFB ? ? 01 1 FFC ? ? 00 1 FFD ? ? 01 1 FFE ? ? 08 FLAGS=4108 H 1 FFF ? ? 41 2000 ? ? SP
4. 5 Program Transfer Instructions ENTER, LEAVE ENTER 6, 0 If Level=0, BP is saved on stack, BP is loaded with the content of SP, SP is decremented by Space 16. BP old value =1234 H BP new value =00 FEH SP old value =0100 H SP intermediate value =00 FEH SP final value =00 F 8 H … 00 F 8 00 F 9 00 FA 00 FB 00 FC 00 FD 00 FE 00 FF 0100 ? ? ? ? 34 ? ? 12 ? ? SP Reserved memory space SP BP SP LEAVE SP is loaded with the content of BP, BP is popped from stack. => values before ENTER restored. SP back to old value =0100 H BP back to old value =1234 H Stack Frame pointer
4. 6 Processor Control Instructions
- Slides: 8