1 / 6

Lab 5

Lab 5. Multiplication, Division Instructions. Multiplication Instruction. MUL source Unsigned multiplication. IMUL source Signed multiplication . Multiplicand assumed in AL (8 bit ) or in AX (16 bit ). Source may be a register or a memory byte.

ull
Télécharger la présentation

Lab 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab 5 Multiplication, Division Instructions

  2. Multiplication Instruction • MUL source • Unsigned multiplication • IMUL source • Signed multiplication. • Multiplicand assumed in AL (8 bit) or in AX (16 bit). • Source may be a register or a memory byte. • 8 bit * 8 bit = 16 bit 16 bit * 16 bit = 32 bit

  3. Example 1 • Type a procedure to calculate N! org 100h MOV CX,5 MOV AX,1 ; AX holds product TOP: MUL CX ; product = product X term LOOP TOP ret

  4. Division Instruction • DIV divisor • Unsigned division. • IDIV divisor • Signed division. • Divisor is 8 bit or 16 bit register or memory byte. • Dividend is assumed in AX for 8 bit divisor or in AX:DX for 16 bit divisor. • Quotient is in AL for 8 bit divisor or in AX for 16 bit divisor. • Remainder is in AH for 8 bit divisor or in DX for 16 bit divisor. • 16 bit / 8 bit = 8 bit and remainder 8 bit • 32 bit / 16 bit = 16 bit and remainder 16 bit

  5. Example 2 • Translate into ASSMBLER the following high-level assignment statement: ANSWER = 130 / A + B / C - D / 7 ORG 100H MOV AX,130 ;move constant to reg CWD ;expand to DX:AX IDIV A ;assume QUOTIENT 130/A in AX MOV ANSWER,AX ;ANSWER=130/A MOV AL,B CBW ;expand to AX IDIV C ;assume quotient B/C in AX CBW ;convert byte quotient in AL to a word ADD ANSWER,AX ;ANSWER=130/A + B/C MOV AX,D MOV BL,7 ;put constant in reg IDIV BL ;assume quotient D/7 in AL CBW ;expand to AX so you can SUB from ANSWER SUB ANSWER,AX;ANSWER=130/A + B/C - D/7 ret A DW 5 ANSWER DW ? B DB 9 C DB 3 D DW 49

  6. Exercises • Calculate the following assignment statement in emu. RESULT = A*5 / B*2 + 3 Where A = 4 and B = 2 , show the result on screen.

More Related