background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٨٤

 

 

ARITHMETIC INSTRUCTIONS 

 The  8086  can  perform  arithmetic  operations  on  binary  numbers  (signed  or 

unsigned)  and  on  decimal  numbers  (packed  or  unpacked).  As  Table  1  shows, 

there 

are 

instructions 

for 

the 

four 

standard 

arithmetic 

functions-addition, 

subtraction,  multiplication,  and  division.  There  are  also  instructions  that  "sign-

extend"  operands;  these  let  you  combine  data  of  different  sizes  (e.g.,  add  a  byte 

to a word).  

      ﺔ!!!ﯿﺋﺎﻨﺜﻟا مﺎ!!!ﻗرﻻا ﻰ!!!ﻠﻋ تﺎ!!!ﯿﻠﻤﻌﺑ مﻮ!!!ﻘﯾ نا ﺞﻟﺎ!!!ﻌﻤﻠﻟ ﻦ!!!ﻜﻤﯾ

)

     ﺎرة!!!ﺷا نوﺪ!!!ﺑ ﻢ!!!ﻗر ، ﺎرة!!!ﺷﺎﺑ ﻢ!!!ﻗر

 (

  ﺮﯾﺔ!!!ﺸﻌﻟا مﺎ!!!ﻗرﻻاو

(packed  or  unpacked)

 

 .

!!!ﺬﻟﻚ اﻻﯾﻌ!!!ﻛو ﺔ!!!ﻌﺑرﻻا تﺎ!!!ﯿﻠﻤﻌﻟا لوﺪ!!!ﺠﻟا ﻦﯿ!!!ﺒﯾو

 ﺬا!!!ھو ةرﺎ!!!ﺷﻻا ﻊ!!!ﺳﻮﯾ يﺬ!!!ﻟا تاز

ﯾﺴﻤﺢ ﺑﻀﻢ ﺑﯿﺎﻧﺎت ﺑﺎﺣﺠﺎم ﻣﺨﺘﻠﻔﺔ

.

  

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٩٤

 

 

1-Addition Instructions

  

1. Add (ADD) and Add With Carry (ADC)  

The ADD  and ADC  instructions can add 8- or 16-bit operands. ADD adds  a source and 

destination operand and puts the result in the destination. Symbolically, we can represent 

this as  

 ﯾﻤﻜﻦ ﻻﯾﻌﺎزي

ADD and ADC

 

ان ﺗﺠﻤﻊ ﻣﻌﻠﻮﻣﺎت ﺑ

 ﻄﻮل

8 or 16 bit

 

 وﯾﺘﻢ اﺿﺎﻓﺔ اﻟﻤﺼﺪر اﻟﻰ اﻟﻤﺴﺘﻘﺮ وﯾﺨﺰن

اﻟﻨﺎﺗ

 ﺞ ﻓﻲ اﻟﻤﺴﺘﻘﺮ

  

destination = destination + source  

ADC does the same thing as ADD, except it includes the Carry Flag (CF) in the addition, 

like this:  

 وﯾﺸﺎﺑﮫ اﯾﻌﺎز

ADC

 

 اﯾﻌﺎز

ADD

 

ﺑﺎﺳﺘﺜﻨﺎء اﻧﮫ ﯾﺠﻤﻊ اﯾﻀﺎ

 

  ﻗﯿﻤﺔ

Carry Flag (CF)

  

destination = destination + source + carry  

 

Now  you  can  see  why  the  8086  has  two  separate  add  instructions.  One 

instruction, ADD, can add single-byte or single-word numbers and the low-order 

terms of 32-bits numbers. The other, ADC, is used to add the higher-order terms 

of two 32-bits numbers.  

  واﻻن  ﻧﺴﺘﻄﯿﻊ  ان  اﻟﻤﻌﺎﻟﺞ

  ﻟﮫ  اﯾﻌﺎزي  ﺟﻤﻊ  ﻣﻨﻔﺼﻠﯿﻦ  ﻋﻦ  ﺑﻌﻀﮭﺎ  اﻟﺒﻌﺾ

  .

  اﻻول  ھﻮ  اﯾﻌﺎز

ADD

 

 واﻟﺬي  ﺑﺎﻣﻜﺎﻧﮫ  ان

 ﯾﺠﻤﻊ ﺑﺎﯾﺖ واﺣﺪ او ﻛﻠﻤﺔ واﺣﺪة او اﻟﺠﺰء اﻻدﻧﻰ ﻣﻦ اﻟﺮﻗﻢ

32-bits

 

 وﯾﺴﺘﺨﺪم اﯾﻌﺎز

ADC

 

ﻟﺠﻤﻊ اﻟﺠﺰء اﻻ

 ﻋﻠﻰ ﻣﻦ

 اﻟﺮﻗﻢ

32-bits

 

.

  

For example: 

ADD AX , CX   

adds the 16-bit contents of AX and CX and returns the result in AX. If your operands are 

longer than 16 bits, you can use this kind of sequence: 

 اﻻﯾﻌﺎز اﻟﺴﺎﺑﻖ ﯾﺠﻤﻊ ﻣﺤﺘﻮى

16 bit 

 

 ﻟﻤﺴﺠﻠﻲ

AX and CX

 

واﻟﻨﺎﺗﺞ ﯾ

 ﺨﺰن ﻓﻲ ﻣﺴﺠﻞ

AX

 .

 واذاﻛﺎن ﻃﻮل اﻟﺮﻗﻤﯿﻦ

 اﻃﻮل ﻣﻦ

16-bit

 

ﻓﺎﻧﻨﺎ ﻧﺴﺘﺨﺪم ھﺬا اﻟﻨﻮع ﻣﻦ ﺗﺴﻠﺴﻞ اﻻﯾﻌﺎزات

  

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٠٥

 

 

 

ADD   AX,CX ;Add low – order 16 bits, 

ADD   BX,DX ;then high – order 16 bits, 

which adds the 32-bit number in CX and DX to the one in AX and BX. Here, the ADC 

instruction includes any carry out of (CX) + (AX) into (DX)+ (BX). 

 وﺗﺴﻠﺴﻞ اﻻﯾﻌﺎزات ﯾﻘﻮم ﺑﺠﻤﻊ رﻗﻤﯿﻦ ﺑﻄﻮل

32-bit 

  

 ﺣﯿﺚ ﯾﻜﻮن

 اﻟﺮﻗﻢ

 اﻻول ﻓﻲ اﻟﻤﺴﺠﻠﯿﻦ

CX and DX

 

 واﻟﺮﻗﻢ

 اﻟﺜﺎﻧﻲ ﻓﻲ اﻟﻤﺴﺠﻠﯿﻦ

AX and BX

 

 وﯾﻘﻮم اﻻﯾﻌﺎز

ADC

 

  ﺑﺎﺧﺬ ﺑﻨﻈﺮ اﻻﻋﺘﺒﺎر

carry out

 

ان ﺣﺪث ﻣﻦ ﻋﻤﻠﯿﺔ ا

 ﻟﺠﻤﻊ

 ﺑﯿﻦ اﻟﻤﺴﺠﻠﯿﻦ

(DX)+ (BX)

 

 اﻟﻰ ﻋﻤﻠﯿﺔ اﻟﺠﻤﻊ ﺑﯿﻦ اﻟﻤﺴﺠﻠﯿﻦ

(CX) + (AX)

.

  

You  may  also  add  a  memory  operand  to  a  general  register  (or  vice  versa)  or  add  an 

immediate value to a register or to memory. Some examples are:  

وﯾﻤﻜﻦ ان ﯾﺠﻤﻊ ﻣﻮﻗﻊ ذاﻛﺮة ﻣﻊ ﻣﺴﺠﻞ ﻋﺎم و

 اﻟﻌﻜﺲ ﺑﺎﻟﻌﻜﺲ او اﺿﺎﻓﺔ اﻟﻘﯿﻤﺔ اﻟﻤﺒﺎﺷﺮة اﻟﻰ ﻣﺴﺠﻞ او ﻣﻮﻗﻊ اﻟﺬاﻛﺮة وھﺬه

ﺑﻌﺾ اﻻﻣﺜﻠﺔ ﻋﻠﻰ ھﺬا اﻟﻤﻮﺿﻮع

  

ADD  AX , MEM_WORD; Add a memory operand to a register 

ADD  MEM_WORD , AX ; or vice versa 

ADD  AL , 10 ; Add a constant to a register 

ADD  MEM_BYTE , 0FH ; or to a memory location 

Note that most combinations are legal, but you may not add memory-to memory, nor may 

you use an immediate value as a destination.  

وﯾﺠﺐ ان ﻧﻼﺣﻆ اﻧﮫ ﻻﯾﻤﻜﻦ ان ﻧﺠﻤﻊ ﻣﻮﻗﻌﯿﻦ ذاﻛﺮة ﻣﺒﺎﺷﺮة او اﺳﺘﺨﺪام اﻟﻘﯿﻤﺔ اﻟﻤﺒﺎﺷﺮة ﻛﻤﺴﺘﻘﺮ

.

  

2.(AAA and DAA) Instructions Adjust for Addition  

The  8086  always  adds  numbers  as  if  they  were  binary.  What  happens  if  they  are 

binary-coded decimal (BCD) numbers? Let's find out by looking at an examples. 

 ان ﻣﻌﺎﻟﺞ

8086 

 

 ﯾﻘﻮم ﺑﺠﻤﻊ اﻻرﻗﺎم ﻛﺎرﻗﺎم ﺛﻨﺎﺋﯿﺔ وﻟﻜﻦ

اذا ﻛﺎن اﻻرﻗﺎ

 م ﻣﻦ ﻧﻮﻋﯿﺔ

BCD

 

 ﻓﻜﯿﻒ ﯾﺘﻢ اﻟﺘﻌﺎﻣﻞ ﻣﻊ ھﺬا

اﻟﻤﻮﺿﻮع ﻓﻠﻨﺮى ﺑﻌﺾ اﻻﻣﺜﻠﺔ

.

  

 

 

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

١٥

 

 

1.  Unpacked BCD number and AAA Instruction  

If you add the unpacked BCD numbers 26 and 42, the 8086 performs this Hexadecimal 

addition:  

 اذا ﺗﻢ اﺿﺎﻓﺔ رﻗﻤﯿﻦ

unpacked BCD

 

 ھﻤﺎ

26 and 42

 

ﻓﺎن اﻟﻤ

 ﻌﺎﻟﺞ ﺳﯿﻘﻮم ﺑﺎﺟﺮاء ﻋﻤﻠﯿﺔ اﻟﺠﻤﻊ ﺑﺎﻟﻨﻈﺎم اﻟﺴﺎدس

  ﻋﺸﺮي وﻛﺎﻻﺗﻲ

  

26 

42 + 

68       hexadecimal 

 

08       BCD 

If we use an AAA instruction after the addition operation will clear the 4 bit in the left 

of register AL and leave the 4 bit in the right of AL and have no effect on AH and no 

effect on flags  because the Low digit is less the number 9. 

 اذا ﺗﻢ اﺳﺘﺨﺪام اﯾﻌﺎز

 AAA

 ﻟﺘﺤﻮﯾﻞ  ﻧﺎﺗﺞ اﻟﺠﻤﻊ ﻣﻦ اﻟﻨﻈﺎم اﻟﺴﺎدس اﻟﻌﺸﺮي اﻟﻰ ﻧﻈﺎم

BCD

 

 ﻓﺎن اﯾﻌﺎز

AAA

 

  ﯾﻘﻮم  ﺑﺘﺼﻔﯿﺮ  اﻻرﺑﻌﺔ  اﻟﻰ  اﻟﯿﺴﺎر

High  DIGIT

 

  ﻣﻦ  اﻟﻤﺴﺠﻞ

AL

 

وﯾﺘﺮك  اﻻرﺑﻌﺔ اﻟﻰ اﻟ

  ﯿﻤﯿﻦ

LOW  DIGIT

 

 ﺑﺪون ﺗﻐﯿﯿﺮ وﻟﯿﺲ ھﻨﺎك ﺗﺎﺛﯿﺮ ﻋﻠﻰ

AH

 

 وﻻ ﻋﻠﻰ

FLAGS

 

 ﻻن اﻟﺮﻗﻢ اﻟﻨﺎﺗﺞ ﻓﻲ

LOW DIGIT 

 

اﻗﻞ ﻣﻦ اﻟﺘﺴﻌﺔ

.

  

This  instruction  is  deal  with  only  4  bit  in  the  right  of  AL  and  only  it  deal  with  AL 

register  if  the  4  bit  in  the  right  is  exceed  number  9  it  add  six  to  correct  this  digit  and 

clear  the  digit  in  the  left  and  add  1  to  the  AH  and  set  1  to  AF  and  CF  and  check  the 

value of PF and SF. 

 وھﺬا ﯾﻌﻨﻲ ان اﻻﯾﻌﺎز ﻓﻘﻂ ﯾﺘﻌﺎﻣﻞ ﻣﻊ اﻻرﺑﻌﺔ ﺑﺘﺎت ﻓﻲ اﻟﯿﻤﯿﻦ ﻣﻦ اﻟﻤﺴﺠﻞ

AL

 

 وﻓﻘﻂ اﻟﻤﺴﺠﻞ

AL

 

 وﻋﻨﺪﻣﺎ ﯾﺘﺠﺎوز

 اﻟﻨﺎﺗﺞ ﻓﻲ

LOW DIGIT

 

اﻟ

 ﺮﻗﻢ

9

 

 ﻓﺎﻧﮫ ﯾﺼﺤﺢ ﺑﺎﺿﺎﻓﺔ

6

 

 اﻟﻰ اﻟﺮﻗﻢ وﯾﻘﻮم ﺑﺘﺼﻔﯿﺮ

High Digit

 

 اﻟﻰ اﻟﯿﺴﺎر وﻛﺬﻟﻚ

 ﯾﻀﯿﻒ واﺣﺪ اﻟﻰ اﻟﻤﺴﺠﻞ

AH

 

وﻧﺠﻌﻞ ﻗﯿﻢ ال

flag

 

 ﻛﺎﻻﺗﻲ

AF=1

 

 و

CF=1

 

 وﻧﺪﻗﻖ ﻗﯿﻤﺘﻲ

PF and SF

.

  

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٢٥

 

 

26 

48 + 

6E 

 

04 

 وﯾﻀﯿﻒ

1

 

  اﻟﻰ ﻗﯿﻤﺔ ﻣﺴﺠﻞ

AH

 

 وﺗﻜﻮن ﻗﯿﻢ

Flags

 

 ﻛﺎﻻﺗﻲ

  

AF=1, CF=1, PF=0,SF=0 

2.  Packed BCD number and DAA Instruction  

If you add the packed BCD numbers 46 and 43, the 8086 performs this Hexadecimal 

addition:  

 اذا ﺗﻢ اﺿﺎﻓﺔ رﻗﻤﯿﻦ

packed BCD

 

 ھﻤﺎ

46 and 43

 

 ﻓﺎن اﻟﻤﻌﺎﻟﺞ ﺳﯿﻘﻮم ﺑﺎﺟﺮاء ﻋﻤﻠﯿﺔ اﻟﺠﻤﻊ ﺑﺎﻟﻨﻈﺎم اﻟﺴﺎدس

  ﻋﺸﺮي وﻛﺎﻻﺗﻲ

  

46 

43 + 

89       hexadecimal 

 

89       BCD 

If  we  use  an  DAA  instruction  after  the  addition  operation  will  have  no  effect  on  the 

two digits in the register AL and have no effect on AH and no effect on flags  because 

the Low digit and High digit is less the number 9. 

اذا ﺗﻢ اﺳﺘ

 ﺨﺪام اﯾﻌﺎز

 DAA

 ﻟﺘﺤﻮﯾﻞ ﻧﺎﺗﺞ اﻟﺠﻤﻊ ﻣﻦ اﻟﻨﻈﺎم اﻟﺴﺎدس اﻟﻌﺸﺮي اﻟﻰ ﻧﻈﺎم

BCD

 

 ﻓﺎن اﯾﻌﺎز

DAA

 

 ﻟﻦ

  ﯾﻜﻮن  ﻟﮫ  ﺗﺎﺛﯿﺮ  ﻋﻠﻰ  اﻟﺮﻗﻤﯿﻦ  ﻓﻲ  ﻣﺴﺠﻞ

AL

 

  وﻻ  ﻋﻠﻰ  اﻟﻤﺴﺠﻞ

AH

 

  وﻻ  ﻋﻠﻰ

Flags

 

 وذﻟﻚ  ﻻﻧﮫ  ﻛﻞ  ﻣﻦ  اﻟﺮﻗﻤﯿﻦ

Low digit and High digit

 

ھﻤﺎ اﻗﻞ ﻣﻦ ﺗﺴﻌﺔ

.

  


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٣٥

 

 

This DAA instruction is deal with two digits the register  AL and only it deal with AL 

register  if  the  4  bit  in  the  right  (low  digit)  exceed  number  9  or  if  the  4  bit  in  the  left 

(High digit) exceed number 9 or both exceed number 9 it will add six to correct the digit 

which will exceed number 9 and have no effect on the AH and set 1 to AF and CF and 

check the value of PF and SF. 

  وھﺬا  ﯾﻌﻨﻲ  ان  اﻻﯾﻌﺎز

DAA

 

  ﯾﺘﻌﺎﻣﻞ  ﻣﻊ

  اﻟﺮﻗﻤﯿﻦ  ﻓﻲ

  اﻟﻤﺴﺠﻞ

AL

 

  وﻋﻨﺪﻣﺎ  ﯾﺘﺠﺎوز  اﻟﻨﺎﺗﺞ  ﻓﻲ

LOW  DIGIT

 

 اﻟﺮﻗﻢ

9

 

 اوﻋﻨﺪﻣﺎ ﯾﺘﺠﺎوز اﻟﻨﺎﺗﺞ ﻓﻲ

High DIGIT

 

 اﻟﺮﻗﻢ

9

 

 اوﻋﻨﺪﻣﺎ ﯾﺘﺠﺎوز اﻟﻨﺎﺗﺞ ﻓﻲ اﻟﺮﻗﻤﯿﻦ  اﻟﺮﻗﻢ

9

 

 ﻓﺎﻧﮫ ﯾﺼﺤﺢ

 ﺑﺎﺿﺎﻓﺔ

6

 

 اﻟﻰ اﻟﺮﻗﻢ

 اﻟﺬي ﺗﺠﺎوز اﻟﺮﻗﻢ ﺗﺴﻌﺔ وﻟﯿﺲ ﻟﮫ ﺗﺎﺛﯿﺮ ﻋﻠﻰ

اﻟﻤ

 ﺴﺠﻞ

AH

 

وﻧﺠﻌﻞ ﻗﯿﻢ ال

flag

 

 ﻛﺎﻻﺗﻲ

AF=1

 

 و

CF=1

 

 وﻧﺪﻗﻖ ﻗﯿﻤﺘﻲ

PF and SF

.

  

 

46 

89 + 

CF 

 

35 

و

 ﻻﯾﺆﺛﺮ ﻋﻠﻰ

 

  ﻗﯿﻤﺔ ﻣﺴﺠﻞ

AH

 

 وﺗﻜﻮن ﻗﯿﻢ

Flags

 

 ﻛﺎﻻﺗﻲ

  

AF=1, CF=1, PF=1,SF=0 

3. Increment Destination by One (INC) 

The  INC  instruction  adds  1  to  a  register  or  memory  operand  but,  unlike  ADD, 

does  not  affect  the  Carry  Flag  (CF).  INC  is  convenient  for  increasing  loop 

counters  .It  can  also  be  used  to  increase  an  index  register  or  pointer  when  you 

are accessing consecutive locations in memory. Examples are:  

 ان اﯾﻌﺎز

INC

 

ﯾﻀﯿﻒ واﺣﺪ

 

 اﻟﻰ ﻣﺤﺘﻮى ﻣﺴﺠﻞ او ﻣﻮﻗﻊ اﻟﺬاﻛﺮة وﻟﻜﻨﮫ ﻟﯿﺲ ﻣﺜﻞ اﯾﻌﺎز

ADD

 

 ﻓﺎﻧﮫ ﻻﯾﺆﺛﺮ ﻋﻠﻰ

CF

 .

 وھﻮ ﯾﺴﺘﺨﺪم ﻓﻲ زﯾﺎدة ﻋﺪادات اﻟﺤﻠﻘﺎت اﻟﺘﻜﺮارﯾﺔ وﯾﻤﻜﻦ ان ﯾﺰﯾﺪ ﻗﯿﻤﺔ ﻣﺴﺠﻞ ﻓﮭﺮﺳﺔ او ﻣﺆﺷﺮ وذﻟﻚ ﻋﻨﺪ ﻣﻌﺎﻟﺠﺔ ﻣﻮاﻗﻊ

 ﻣﺘﺴﻠﺴﻠﺔ ﻓﻲ اﻟﺬاﻛﺮة واﻻﻣﺜﻠﺔ ﻟﻠﻤﻮﺿﻮع ھﻲ

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٤٥

 

 

INC  CX                     ;Increment a word register 

INC   AL                    ;Increment a byte register 

INC   MEM_BYTE    ; Increment a byte in memory 

INC   MEM_WORD    ; Increment a word in memory 

 
2-Subtraction Instructions  

 

1. How the Microprocessor Subtracts  

Like  every  other  general-purpose  microprocessor,  the  8086,  has  no  internal  subtraction 

unit. However, it does have an addition unit an adder and can subtract numbers by adding 

them.   

 ﻣﺜﻞ ﻛﻞ اﻟﻤﻌﺎﻟﺠﺎت ذات اﻻﺳﺘﺨﺪام اﻟﻌﺎم ﻓﺎن اﻟﻤﻌﺎﻟﺞ

8086

 

 ﻻﯾﻤﺘﻠﻚ وﺣﺪة ﻃﺮح داﺧﻠﯿﺔ ﺑﻞ ﯾﻤﺘﻠﻚ وﺣﺪة ﺟﻤﻊ وﯾﻤﻜﻨﮫ ﻣﻦ

ﻃﺮح اﻻﻋﺪاد ﻣﻦ ﺧﻼل ﺟﻤﻌﮭﻢ

.

  

To see how to subtract by adding, consider how you subtract 7 from 10. 

 وﻟﻨﺮى ﻛﯿﻒ ﯾﺘﻢ اﻟﻄﺮح ﻣﻦ ﺧﻼل اﻟﺠﻤﻊ ﻣﻦ ﺧﻼل ﻃﺮح اﻟﺮﻗﻢ

 

 ﻣﻦ اﻟﺮﻗﻢ

10

 

The 8086 subtracts in two steps. First, it changes the sign of, or complements, the second 

number  (the  subtrahend).  Then  it  adds  the  minuend  and  complemented  subtrahend  to 

produce  the  result.  Because  the  8086  works  with  base  2  (binary)  numbers,  the 

complement is a two's-complement. To obtain the two's-complement of a binary number, 

take its positive form and reverse each bit (change each 1 to 0 and each 0 to 1), then add 

1 to the result. 

 

اﻻوﻟﻰ ﯾﻘﻮم ﺑﻌﻤﻞ ﻣﻜﻤ، ﻦﯿﺗﻮﻄﺨﺑ حﺮﻄﻟﺎﺑ مﻮﻘﯾ ﺞﻟﺎﻌﻤﻟا نا

 ﻠﺔ ﻟﻠﺮﻗﻢ اﻟﻤﻄﺮوح وﻣﻦ ﺛﻢ ﯾﺘﻢ اﺿﺎﻓﺔ اﻟﺮﻗﻢ اﻟﻤﻄﺮوح ﻣﻨﮫ

اﻟﻰ  ﻣﻜﻤﻠﺔ  اﻟﺮﻗﻢ  اﻟﻤﻄﺮوح

  .

  وﺑﻤﺎ  ان  اﻟﻤﻌﺎﻟﺞ

8086

 

 ﺔــﻘـﯾﺮـﻄﺑ  نﻮﻜـﺘﺳ  ﺔﻠـﻤـﻜﻤﻟا  نﺎﻓ  ﻲﺋﺎﻨﺜﻟا  مﺎـﻈــﻨﻟا  ﻊﻣ  ﻞﻣﺎﻌﺘﯾ

two's-complement

 

 وﻟﻠﺤﺼﻮل  ﻋﻠﻰ  ھﺬه  اﻟﻤﻜﻤﻠﺔ  ﻧﻘﻠﺐ  ﻛﻞ  ﺻﻔﺮ  اﻟﻰ  واﺣﺪ  واﻟﻌﻜﺲ  ﺑﺎﻟﻌﻜﺲ  وﻧﻀﯿﻒ  واﺣﺪ  اﻟﻰ

اﻟﻨﺎﺗﺞ

.

  

 

 

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٥٥

 

 

Applying  this  to  our  "10  -  7"  example,  the  8-bit  binary  representations  of  10  and  7  are 

00001010B and 00000111B, respectively. Take the two's complement of 7 as follows:  

 وﺑﺘﻄﺒﯿﻖ ھﺬه اﻟﻄﺮﯾﻘﺔ ﻋﻠﻰ ﻣﺜﺎﻟﻨﺎ

"10 - 7"

 

 ﻓﺎن اﻟﺘﻤﺜﯿﻞ

  ﻟﻠﺮﻗﻤﯿﻦ

10

 

 و

7

 

ﺑﻄﻮل ﺛﻤﺎﻧﯿﺔ ﺑ

 ﺘﺎت ﺳﯿﻜﻮن ﺑﺎﻟﺸﻜﻞ اﻟﺘﺎﻟﻲ

00001010B and 00000111B

 

 وﻋﻤﻠﯿﺔ اﻟﻤﻜﻤﻠﺔ ﻟﻠﺮﻗﻢ

7

 

11111000      (reverse all bits) 

              1 +   (add  1) 

11111001      (two's-complement of 7, or -7) 

Now the subtraction operations becomes 

0000 1010      (= 10) 

1111 1001       (= - 7) 

0000 0011      (answer = 3) 

2.Subtract (SUB) and Subtract With Borrow (SBB)  

SUB  and  SBB  are  similar  to  their  addition  counterparts  (ADD  and  ADC),  but  with 

subtraction,  the  Carry  Flag  (CF)  acts  as  a  borrow  indicator.  SUB  subtracts  a  source 

operand from a destination operand and returns the result in the destination. That is,  

ان اﯾﻌﺎزي اﻟﻄﺮح

 

 SUB and SBB

 

 ﻊـﻤـﺠﻟا يزﺎﻌﯾا ﻰﻟا ﺔﮭـﺑﺎـﺸﻣ

(ADD and ADC)

 

 وﻟﻜﻦ ﺑﺎﻟﻄﺮح ﻓﺎن

Carry Flag (CF) 

 

 ﯾﻌﺎﻣﻞ ﻛﻤﺆﺷﺮ

borrow

 .

 واﯾﻌﺎز

SUB

 

 ﯾﻘﻮم ﺑﻄﺮح اﻟﻤﺼﺪر ﻣﻦ اﻟﻤﺴﺘﻘﺮ وﯾﺨﺰن اﻟﻨﺎﺗﺞ ﻓﻲ

اﻟﻤﺴﺘﻘﺮ

  

destination == destination - source  

SBB does the same thing, except it also subtracts out the Carry Flag (CF), like this:  

destination == destination - source - carry  

As  with  addition,  the  subtraction  instructions  perform  two  separate  functions.  One 

instruction,  SUB,  subtracts  single-byte  or  single-word  numbers,  or  the  low-order  terms 

of  32-bit  numbers.  The  other,  SBB,  subtracts  the  higher-order  terms  of  two  32-bit 

numbers. For example, the instruction  

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٦٥

 

 

 ﻓﺎن اﯾﻌﺎز، ﻊﻤﺠﻟا ﺔﻟﺎﺣ ﻲﻓ بﻮﻠﺳﻻا ﺲﻔﻨﺑ

  اﻻﯾﻌﺎز اﻻول، ﺔﻠﺼﻔﻨﻤﻟا لاوﺪﻟا ﻦﻣ ﻦﯿﻋﻮﻧ مﺪﻘﺗ حﺮﻄﻟا تا

SUB

 

ﯾﻄﺮح رﻗﻤﯿﻦ ﺑﻄﻮل ﺑﺎﯾﺖ او

 

 رﻗﻤﯿﻦ ﺑﻄﻮل

word

 

 او اﻟﺠﺰء اﻻدﻧﻰ ﻣﻦ رﻗﻤﯿﻦ ﺑﻄﻮل

32-bit

 

 واﻻﯾﻌﺎز اﻻﺧﺮ ھﻮ

SBB

 

 ﯾﻄﺮح اﻟﺠﺰء اﻻﻋﻠﻰ ﻣﻦ رﻗﻤﯿﻦ ﺑﻄﻮل

32-bit

 

وﻛﻤﺜﺎل ﻓﺎن اﻻﯾﻌﺎز

  

SUB  AX , CX 

subtracts CX from AX and returns the result in AX.  

For operands longer than 16 bits, use this kind of sequence:  

SUB   AX,CX ;Subtract low – order 16 bits, 

SUB   BX,DX ;then high – order 16 bits, 

Here we subtract the 32-bit number in CX and DX from the one in AX and BX. When 

SBB subtracts DX from BX, it includes any borrow out of the first subtraction.  

You  may  also  subtract  a  memory  operand  from  a  register  (or  vice  versa)  or  an 

immediate value from a register or memory location. You may not subtract one memory 

value  from  another  directly,  nor  may  you  use  an  immediate  value  as  a  destination. 

Examples of legal forms are:  

  وﯾﺘﻢ  ﻃﺮح  اﻟﺮﻗﻢ

32-bit

 

  اﻟﻤﻮﺟﻮد  ﻓﻲ

CX  and  DX

 

  ﻣﻦ  اﻟﺮﻗﻢ  اﻟﻤﻮﺟﻮد  ﻓﻲ

AX  and  BX

  .

 وﯾﻄﺮح  اﻻﯾﻌﺎز

SBB

 

 اﻟﻤﺴﺠﻞ

DX

 

 ﻣﻦ اﻟﻤﺴﺠﻞ

BX

 

 وﺗﻘﻮم ﺑﺎﻟﺘﻌﺎﻣﻞ ﻣﻊ اي

borrow

 

ﻗﺪ ﯾﻨﺘﺞ ﻣﻦ ﻋﻤﻠﯿﺔ اﻟﻄﺮح اﻻوﻟﻰ

.

  

وﯾﻤﻜﻦ ان ﯾﻄﺮح ﻣﻮﻗﻊ ذاﻛﺮة ﻣﻦ  ﻣﺴﺠﻞ ﻋﺎم واﻟﻌﻜﺲ ﺑﺎﻟﻌﻜﺲ او ﻃﺮح  اﻟﻘﯿﻤﺔ اﻟﻤﺒﺎﺷﺮة

 

 ﻣﻦ  ﻣﺴﺠﻞ  او  ﻣﻮﻗﻊ  اﻟﺬاﻛﺮة

 وﯾﺠﺐ ان ﻧﻼﺣﻆ اﻧﮫ ﻻﯾﻤﻜﻦ ان ﻧﻄﺮح ﻣﻮﻗﻌﯿﻦ ذاﻛﺮة ﻣﺒﺎﺷﺮة او اﺳﺘﺨﺪام اﻟﻘﯿﻤﺔ اﻟﻤﺒﺎﺷﺮة ﻛﻤﺴﺘﻘﺮ

 وھﺬه ﺑﻌﺾ اﻻﻣﺜﻠﺔ

ﻋﻠﻰ ھﺬا اﻟﻤﻮﺿﻮع

  

SUB  AX , MEM_WORD; subtract  memory from a register 

SUB  MEM_WORD , AX ; or vice versa 

SUB  AL , 10 ; subtract constant from a register 

SUB  MEM_BYTE , 0FH ; or from a memory location 

3. Decrement Destination by One (DEC) 

The  DEC  instruction  subtracts  1  from  a  register  or  memory  operand  but  unlike 

SUB, does not affect the Carry Flag (CF). DEC is often used to decrement a loop 

counter  until  it  becomes  zero  or  negative  .It  can  also  be  used  to  decrease  an 

index register or pointer when you are accessing consecutive memory locations. 

Some Examples are:  


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٧٥

 

 

 ان اﯾﻌﺎز

DEC

 

ﯾﻄﺮح واﺣﺪ ﻣﻦ ﻣﺤﺘﻮى ﻣﺴﺠﻞ او ﻣﻮﻗﻊ اﻟﺬاﻛﺮة وﻟﻜﻨﮫ ﻟﯿﺲ ﻣ

 ﺜﻞ اﯾﻌﺎز

SUB

 

 ﻓﺎﻧﮫ ﻻﯾﺆﺛﺮ ﻋﻠﻰ

CF

 .

 وھﻮ  ﯾﺴﺘﺨﺪم  ﻓﻲ  ﻧﻘﺼﺎن  ﻋﺪادات  اﻟﺤﻠﻘﺎت  اﻟﺘﻜﺮارﯾﺔ  وﯾﻤﻜﻦ  ان  ﯾﻘﻠﻞ  ﻗﯿﻤﺔ  ﻣﺴﺠﻞ  ﻓﮭﺮﺳﺔ  او  ﻣﺆﺷﺮ  وذﻟﻚ  ﻋﻨﺪ  ﻣﻌﺎﻟﺠﺔ

 ﻣﻮاﻗﻊ ﻣﺘﺴﻠﺴﻠﺔ ﻓﻲ اﻟﺬاﻛﺮة واﻻﻣﺜﻠﺔ ﻟﻠﻤﻮﺿﻮع ھﻲ

  

DEC  CX                     ;Decrement a word register 

DEC   AL                    ;Decrement a byte register 

DEC   MEM_BYTE    ; Decrement a byte in memory 

DEC   MEM_WORD    ; Decrement a word in memory 

4.Negate (NEG) 

The  NEG  instruction  subtracts  the  destination  operand  from  zero,  thus  forming  the 

operand's two's – complement.  

ان

 

 اﯾﻌﺎز

NEG

 

 ﯾﻄﺮح اﻟﻤﺴﺘﻘﺮ ﻣﻦ اﻟﺼﻔﺮ وھﺬا ﯾﻮﻟﺪ

two's – complement

 

ﻟﻠﺮﻗﻢ ﻓﻲ اﻟﻤﺴﺘﻘﺮ

.

  

 

MOV   AL,0FF 

NEG 

AL=  1111 1111 

         0000 0000    COMPLEMENT    

                        1    ADD 1 

         0000 0001 

AL=01 

 

 

 

 

 

 

 

 

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٨٥

 

 

5. Compare Destination to Source (CMP

)  

Like the SUB instruction, CMP subtracts a source from a destination and sets or clears 

the flags based on the result (see Table 3-5). But unlike SUB, CMP does not save the 

result of the subtraction; that is, it doesn't alter the destination. CMP's sale purpose is to 

set up the flags for decision-making by conditional jump instructions 

 اﯾﻌﺎز اﻟﻤﻘﺎرﻧﺔ

  

CMP

 

 ﯾﺸﺒﮫ اﯾﻌﺎز اﻟﻄﺮح

SUB

 

 ﺑﺎن ﯾﻄﺮح اﻟﻤﺼﺮ ﻣﻦ اﻟﻤﺴﺘﻘﺮ وﯾﻘﻮم ﺑﻮﺿﻊ واﺣﺪ او ﺻﻔﺮ ﻓﻲ

flags

 

 وﺑﺎﻻﻋﺘﻤﺎد ﻋﻠﻰ اﻟﻨﺘﯿﺠﺔ ﻛﻤﺎ ﻓﻲ اﻟﺠﺪول

3-5

 

  وﻟﻜﻦ ﻟﯿﺲ ﻣﺜﻞ،

SUB

 

 ﻓﺎن اﯾﻌﺎز

CMP

 

 ﻻﯾﺨﺰن ﻧﺎﺗﺞ اﻟﻄﺮح وﻻﯾﻐﯿﺮ

 اﻟﻤﺴﺘﻘﺮ وھﻮ ﯾﺴﺘﺨﺪم ﻓﻲ ﻋﻤﻠﯿﺔ ﺗﻐﯿﯿﺮ ﻗﯿﻢ

flags

 

وذﻟﻚ ﻟﺘﺤﺪﯾﺪ ﻗﺮار ﺑﺎﺣﺪ اﯾﻌﺎزات اﻟﻘﻔﺰاﻟﻤﺸﺮوﻃﺔ

  

 

 

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٩٥

 

 

Multiplication Instructions  

 Multiply (MUL) multiplies unsigned numbers and Integer Multiply (IMUL) multiplies 

signed numbers. Both can multiply bytes or words 

 

 اﯾﻌﺎز اﻟﻀﺮب

MUL

 

 ﯾﻀﺮب ارﻗﺎم ﺑﺪون اﺷﺎرة واﻻرﻗﺎم اﻟﺼﺤﯿﺤﺔ

و

 اﻻﯾﻌﺎز

IMUL

 

 ﯾﻀﺮب اﻻرﻗﺎم ﺑﺎﻻﺷﺎرة

وﻛﻼھﻤﺎ ﯾﻀﺮب ارﻗﺎم ﺑﻄﻮل ﺑﺎﯾﺖ او ﻛﻠﻤﺔ

  

Multiply, Unsigned (MUL) and Integer Multiply, Signed (IMUL)  

The 8086 multiply instructions have the general forms 

MUL       SOURCE 

IMUL      SOURCE 

where source is a byte- or word-length general register or memory location. For the second 

operand, MUL and IMUL use the contents of AL (for byte operations) or AX (for word 

operations). They return double-length products as follows: 

 ﻌﺎﺯﻱـﻴﻻﺍ ﻥﺎﻓ ﻲﻨﺎـﺜﻟﺍ لﻤﺎﻌـﻤﻟﺍﻭ ﺓﺭﻜﺍﺫ ﻊـﻗﻭـﻤ ﻭﺍ ﻡﺎـﻋ لـﺠﺴﻤ ﻲﻓ ﺔﻤـﻠﻜ ﻭﺍ ﺕﻴﺎﺒ ﻥﻭﻜﻴ ﺩﻗ ﺭﺩﺼﻤﻟﺍ ﻥﺍ ﺙﻴﺤ

MUL and IMUL

 

 ﺘﺴﺘﺨﺩﻡ ﻤﺤﺘﻭﻯ ﺍﻟﻤﺴﺠل

AL

 

 ﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﺒﺎﻴﺕ ﻭﻤﺴﺠل

AX

 

 ﻟﻌﻤﻠﻴﺎﺕ ﺍﻟﻜﻠﻤﺔ ﻭﺍﻟﻘﻴﻤﺔ ﺍﻟﻨﺎﺘﺠﺔ ﺴﺘﻜﻭﻥ

ﻀﻌﻑ ﻁﻭل ﺍﻻﺭﻗﺎﻡ ﺍﻟﺘﻲ ﺘﻡ ﻀﺭﺒﻬﺎ

:

  

. Multiplying bytes produces a 16-bit product in AH (high byte) and AL (low byte) 

. Multiplying words produces a 32-bit product in DX (high word) and AX (low word) 

Upon  completion,  the  Carry  and  Overflow  Flags  (CF  and  OF)  tell  how  much  of  the 

product is relevant. For MUL if the high-order half of the product is zero, CF and OF are 

0;  otherwise,  they  are  1.  For  IMUL,  if  the  high-order  half  of  the  product  is  just  a  sign-

extension of the low-order half, CF and OF are 0; otherwise, they are 1.  

وﺑﺎﻟﻨﺴﺒﺔ ﻟﻞ

flags

 

 ﺎن

CF and OF

 

 ﺗﻜﻮن ﻟﮭﺎ ﻋﻼﻗﺔ ﺑﺎﻟﻨﺎﺗﺞ

 .

 ﻓﻔﻲ ﺣﺎﻟﺔ اﻟﻀﺮب

MUL

 

 اذاﻛﺎن ﺟﺰء

high-order

 

 ﻣﻦ اﻟﻨﺎﺗﺞ ھﻮ ﺻﻔﺮ ﻓﺎن ﻛﻞ ﻣﻦ

CF and OF

 

 ﺳﺘﻜﻮن ﻗﯿﻤﺘﮭﻤﺎ ﺻﻔﺮ واﻻ ﻓﮭﻲ واﺣﺪ وﻓﻲ ﺣﺎﻟﺔ

IMUL 

 

 اذاﻛﺎن ﺟﺰء

high-order

 

 ﻣﻦ اﻟﻨﺎﺗﺞ ھﻮ ﻣﺠﺮد ﺗﻤﺪﯾﺪ ﻟﻼﺷﺎرة ﺻﻔﺮ ﻓﺎن ﻛﻞ ﻣﻦ

CF and OF

 

ﺳﺘﻜﻮن ﻗﯿﻤﺘﮭﻤﺎ ﺻ

ﻔﺮ واﻻ ﻓﮭﻲ واﺣﺪ

  

 

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

٠٦

 

 

 

MUL  BX                     ;Unsigned multiply of BX times AX 

MUL  MEM_BYTE     ; Unsigned multiply of memory times AL 

IMUL   DL                  ; signed multiply of BL times AL 

IMUL   MEM_WORD    ; signed multiply of memory times AX 

 

Division Instructions 

Divide (DIV) performs an unsigned division, while Integer Divide (IDIV) performs a 

signed division 

 ان اﯾﻌﺎز

DIV

 

ﯾﻘﺪم ﻋﻤﻠﯿﺔ اﻟﻘﺴﻤﺔ ﻻﻋﺪاد ﺑﺪون اﺷﺎرة ﺑﯿﻨﻤﺎ

 

 

IDIV

 

ﯾﻘﺴﻢ ارﻗﺎم ﺑﺎﺷﺎرة

  

 Divide, Unsigned (DIV) and Integer Divide, Signed (IDIV)  

DIV       SOURCE 

IDIV      SOURCE 

where  source  is  a  byte-  or  word-sized  general  register  or  memory  location  that  contains 

the  divisor  (the  value  by  which  you  want  to  divide).  The  dividend  is  a  double-length 

operand  contained  in  either  AH  and  AL  (for  byte  operations)  or  DX  and  AX  (for  word 

operations).  

 ﻊ ﺫﺍﻜﺭﺓ ﺍﻟﺘﻲ ﺘﺤﺘﻭﻱ ﻋﻠﻰ ﻗﻴﻡ ﺍﻟﻤﻘﺴﻭﻡ ﻋﻠﻴﻪـﻗﻭـﻤ ﻭﺍ ﻡﺎـﻋ لـﺠﺴﻤ ﻲﻓ ﺔﻤـﻠﻜ ﻭﺍ ﺕﻴﺎﺒ ﻥﻭﻜﻴ ﺩﻗ ﺭﺩﺼﻤﻟﺍ ﻥﺍ ﺙﻴﺤ

 ﻭﺍﻟﻤﻘﺴﻭﻡ ﻗﺩ ﻴﻜﻭﻥ ﻓﻲ ﻤﺴﺠل

AH and AL

 ﻭﻗﺩ ﻴﻜﻭﻥ ﻓﻲ ﻤﺴﺠﻠﻲ

 

 

DX and AX

 

 ﻓﻲ ﺤﺎﻟﺔ ﺍﻟﻜﻠﻤﺎﺕ

  

  

DIV and IDIV produce the following results:  

. If the source operand is a byte, the quotient is returned in AL and the remainder in AH.  

. If the source operand is a word, the quotient is returned in AX and the remainder in DX.  

 

 


background image

ﺤﺎﺴﺒﺎﺕ ﻤﺘﻘﺩﻤﺔ ﺍﻟﻤﺭﺤﻠﺔ ﺍﻟﺜﺎﻟﺜﺔ              ﻫﻨﺩﺴﺔ ﻜﻬﺭﻭ ﻤﻴﻜﺎﻨﻴﻙ          ﺍﻟﻤﺩﺭﺱ ﻤﺴﺎﻋﺩ ﺍﻨﻤﺎﺭ ﺨﻠﻴل ﺍﺒﺭﺍﻫﻴﻡ

 

١٦

 

 

Both  instructions  leave  the  flags  undefined.  However,  if  the  quotient  cannot  fit  in  the 

destination  register  (AL  or  AX)-that  is,  if  it  overflows  the  destination  the  8086  has  a 

dramatic  way  of  telling  you  that  the  result  is  invalid:  it  generates  a  type  0  (divide  by  0) 

interrupt.  

وﺑﺎﻟﻨﺴﺒﺔ ﻟﻞ

flags

 

ﻓﺎن اﻻﯾ

 ﻌﺎزﯾﻦ ﻻﯾﺆﺛﺮان ﻋﻠﻰ اي

flags

 

 وﻟﻜﻦ ﻓﻲ ﺣﺎﻟﺔ ﻛﻮن ﻧﺎﺗﺞ اﻟﻘﺴﻤﺔ ﻻﯾﻤﻜﻦ ﺧﺰﻧﮫ ﻓﻲ ﻣﺴﺠﻠﻲ

AL or AX

  

 ﻓﺎن ﻋﻤﻠﯿﺔ

overflows

 

ﺳﻮف ﺗﻔﻌﻞ وﯾﻠﺪ ﻣﻔﺎﻃﻌﺔ اﻟﺘﻘﺴﯿﻢ ﻋﻠﻰ ﺻﻔﺮ

  

The following conditions cause a divide overflow:  

 وھﺬه اﻟﺤﺎﻻت ﺗﻮﻟﺪ

divide overflow

  

1. The divisor is zero.  

2. For an unsigned byte divide, the dividend is at least 256 times larger than 

the divisor.  

3. For an unsigned word divide, the dividend is at least 65,536 times larger 

than the divisor.  

4. For a signed byte divide, the quotient exceeds + 127 or -128.  

5. For a signed word divide, the quotient exceeds + 32,767 or -32,768.  

Here are some typical division operations: 

DIV    BX                     ;Divide DX:AX By BX, unsigned  

DIV  MEM_BYTE     ; Divide AH:AL By MEMORY, unsigned 

IDIV   DL                  ; Divide AH:AL By DL, signed 

IDIV   MEM_WORD    ; Divide DX:AX By MEMORY, signed 

 

 




رفعت المحاضرة من قبل: ضرغام العزاوي
المشاهدات: لقد قام 4 أعضاء و 233 زائراً بقراءة هذه المحاضرة








تسجيل دخول

أو
عبر الحساب الاعتيادي
الرجاء كتابة البريد الالكتروني بشكل صحيح
الرجاء كتابة كلمة المرور
لست عضواً في موقع محاضراتي؟
اضغط هنا للتسجيل