28_02_2011_12.00_12.55_1.45_2.40
TRANSCRIPT
![Page 1: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/1.jpg)
Compiled by
Venugopala Rao A SSr. Lecturer, Dept of CSE, SSE Mukka.
Microprocessors06CS45
![Page 2: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/2.jpg)
8086 Family Assembler Language Programming CMP Destination, Source
Destination – Source (the result is not stored anywhere) Destination and Source operands can not be memory locations at
the same time It modifies flags AF CF OF PF SF ZF (if ZF is set, destination =
source) E.g. MOV AL, 5 MOV BL, 5 CMP AL, BL ; AL = 5, ZF = 1 (so equal!)
2 Venugopal Rao A S, SSE Mukka
![Page 3: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/3.jpg)
8086 Family Assembler Language Programming MUL Source
Perform unsigned multiplication operation If source operand is a byte, AX = AL * Source If source operand is a word, (DX AX) = AX * Source Source operands can not be an immediate data It modifies CF and OF (AF,PF,SF,ZF undefined)E.g. MOV AL, 0C8h MOV BL, 4 MUL BL ; AX = 0320h (800)
3 Venugopal Rao A S, SSE Mukka
![Page 4: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/4.jpg)
8086 Family Assembler Language Programming IMUL Source
Performs signed binary multiplication operation If source operand is a byte, AX = AL * Source If source operand is a word, (DX AX) = AX * Source Source operand can not be an immediate data It modifies CF and OF (AF,PF,SF,ZF undefined)E.g.
MOV AL, -2 MOV BL, -4 IMUL BL ; AX = 8
Try this in a program
4 Venugopal Rao A S, SSE Mukka
MOV AL, 20HMOV CL, 80HMUL CL
MOV AL, 20HMOV CL, 80HIMUL CL
![Page 5: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/5.jpg)
8086 Family Assembler Language Programming DIV Source
Performs unsigned division operation If source operand is a byte, AL = AX / Source; AH = Remainder
of AX / Source If source operand is a word, AX=(DX AX)/Source;
DX=Remainder of (DX AX)/Source Source operands can not be an immediate dataE.g.
MOV AX, 00CBh MOV BL, 4 DIV BL ; AL = 50 (32h), AH = 3
5 Venugopal Rao A S, SSE Mukka
Examples: MOV AX, 5MOV BL, 2DIV BL
![Page 6: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/6.jpg)
8086 Family Assembler Language Programming IDIV source
Performs signed division operation If source operand is a byte, AL = AX / Source; AH = Remainder
of AX / Source If source operand is a word, AX=(DX AX)/Source;
DX=Remainder of (DX AX)/Source Source operands can not be an immediate data E.g.
MOV AX, 0FF35h MOV BL, 4 IDIV BL ; AL = -50 (0CEh), AH = -3 (0FDh)
6 Venugopal Rao A S, SSE Mukka
Examples: MOV AL, -5MOV BL, 2IDIV BL
![Page 7: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/7.jpg)
8086 Family Assembler Language Programming NEG destination
The result is represented in 2’s complementDestination can be a register or a memory locationIt modifies flags AF CF OF PF SF ZF E.g. MOV AL, 5 ; AL = 05h NEG AL ; AL = 0FBh (-5) NEG AL ; AL = 05h (5)
CBW Extends a signed 8-bit number in AL to a signed 16-bit data and stores it
into AX It does not modify flags
CWD Extends a signed 16-bit number in AX to a signed 32-bit data and stores it
into DX and AX. DX contains the most significant word It does not modify flags 7 Venugopal Rao A S, SSE Mukka
![Page 8: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/8.jpg)
8086 Family Assembler Language Programming JMP Instructions:
Unconditional jumpIt moves microprocessor to execute another part of the program Target can be represented by a label, immediate data, registers, or memory
locations It does not affect flagsSimilar to Go To statements
Conditional JumpJump is based on some condition on flag register contents Similar to usage of if, if then else, while , do while etc
We can further classify JMP into two more classesIntersegment JMP Intrasegment JMP
8 Venugopal Rao A S, SSE Mukka
![Page 9: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/9.jpg)
8086 Family Assembler Language Programming Intrasegment transfer v/sIntersegment transfer
Intrasegment transfer: the microprocessor jumps to an address within the same segment
Intersegment transfer: the microprocessor jumps to an address in a difference segment
Uses assembler directive near and far to indicate the types of JMP instructions
For intrasegment transfer, we can provide only new IP value in JMP instructions. E.g.: JMP 1000H
For intersegment transfer, we need provide both new CS and IP values in JMP instructions E.g.: JMP 2000H : 1000H
9 Venugopal Rao A S, SSE Mukka
![Page 10: 28_02_2011_12.00_12.55_1.45_2.40](https://reader036.vdocument.in/reader036/viewer/2022082512/5517a1684a795967438b476d/html5/thumbnails/10.jpg)
8086 Family Assembler Language Programming Conditional JumpJZ Label_1
If ZF =1, jump to the target address labeled by Label_1; otherwise, do not jump
JNZ Label_1 If ZF =0, jump to the target address labeled by Label_1; otherwise,
do not jump Various other jump instruction:
10 Venugopal Rao A S, SSE Mukka
JNC JAE JNB JC JB JNAE JNGJNE JE JNS JS JNO JO JNPJPO JP JPE JA JBNE JBE JNAJGE JNL JL JNGE JG JNLE JLE