Vous êtes sur la page 1sur 3

mer Selim Grel

217021

14.10.2015

Week2 Lab2
Lab Report
Introduction:
In this experiment, we will conduct unsigned multiplication in assembly language with
different size data in registers and we will pursuit changes in registers. We will see what
happens when data is over flowed to register size after multiplication.
Observation should be like below;
byte X byte will use only AX register to write result.
byte X word will use both AX and DX register to write result.
word X word will use both AX and DX register to write result.

Equipment:
emu8086 software program.
Body (Code & Explanation):

DTSEG SEGMENT
DATA1 DB 230 ;Define byte1
DATA2 DB 100 ;Define byte2
RESULT1 DW ?
RESULT2 DW ?
RESULT3 DW ?
DTSEG ENDS
SUB AX,AX
MOV AL,DATA1 ;

Move Data1 in BYTE

MOV BL,DATA2 ;

Move Data2 in BYTE, Register Addressing Mode

MUL BL
MOV RESULT1,AX

DATA3 DW 9998 ; Define word1

mer Selim Grel


217021

SUB AH,AH

14.10.2015

to clear AH, Substract AH from AH

MOV AL,DATA1 ;Move DATA1 in BYTE TO AL


MOV BX,DATA3 ;Move DATA3 in WORD TO BX
MUL BX

Multiply DATA1 with DATA3

MOV RESULT2,AX ;

Move AX to RESULT2

MOV [RESULT2]+2,DX;

Due to overflow, (Format:DXAX) mov DX result2+2

MOV CX,[RESULT2]+2 ;

to check result at DX

DATA4 DW 300 ;

Define word1

MOV AX,DATA3 ;

Move Data1 in BYTE

MOV BX,DATA4 ;Move Data1 in BYTE


MUL BX

;Multiply DATA3 with DATA4

MOV RESULT3,AX;

Move Result3 AX

MOV [RESULT3]+2,DX ;

Due to overflow, (Format:DX AX) mov DX result3+2

MOV CX,[RESULT2]+2 ; to check result at DX

Results:
Byte X Byte
AL=DATA1=E6H
BL=DATA2=64H
Result:
AH=59H, AL=D8H
Word X Byte
AL=DATA1=E6H
DATA3=270EH
*AH is cleared before multiplication
Result:

mer Selim Grel


217021

14.10.2015

DL=23H, AH=16H, AL=94H


Word X Word
AX=DATA3=270EH
BX=DATA4=12CH
Result:
DL= 2DH, AH=C4H, AL=68H
Conclusions:
In the experiment, we use register addressing mode to calculate multiplication and
after multiplication, we cleared registers, we observe that our program calculate wrong result.
Comparing with other conductors, we see that only one group's program calculate exact
result. On the other hand, to overcome such software mistake, we decide changed code a little
bit from usual and defined DATA3 and DATA4 later.
Answers to Questions:
1- For signed numbers, last bit (for 8 bit it is7th,for 16 bit it is 15th) or most significant bit in
register decides whether number is positive or negative. Therefore on 8 bit registers, it can be
written numbers from -128 to +127. Similarly, on 16 bit registers, it is from-32768 to 32766.
Unsigned numbers are positive integers only. All bit has value in terms of number. 8 bit
register takes values from 0 to 255, 16 bit registers takes values 0-65535.

Vous aimerez peut-être aussi