MP EXP.1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Experiment No.

1
1. Aim: Use of programming tools (Debug/TASM/MASM/8086kit) to perform basic
arithmetic operations on 8-bit/16-bit data.
2. Objective: To understand the programming tools used in assembly language
programming for 8086.
3. Outcomes: The learner will be able to
 Write basic programs for 8-bit/16-bit arithmetic operation.
 Execute basic commands for assembly language program.
4. Hardware / Software Required: MASM assembler, Text Editor, DOSBOX, Operating
System-Ubuntu/Windows
5. Theory:

 Debug: Translating the assembly language to machine code is similar to building


a circuit from a schematic diagram. Debugging can help in deter
ining:
o Values of register.
o Flow of program.
o Entry and exit point of a function.
o Entry into if or else statement.
o Looping of code.
o Calculation check.
 TASM: Turbo Assembler is an assembler for software development published by
Borland in 1989. It runs on and produces code for 16- or 32-bit x86 MS-DOS and
compatibles or Microsoft Windows. TASM itself is a 16-bit program. It will run
on 16- and 32-bit versions of Windows, and produce code for the same versions,
but it does not generate 64-bit x86 code.
 MASM: The Microsoft Macro Assembler (MASM) is an x86 assembler that uses
the Intel syntax for MS-DOS and Microsoft Windows. Beginning with MASM
8.0, there are two versions of the assembler: One for 16-bit & 32-bit assembly
sources, and another (ML64) for 64-bit sources only.
 8086 kit: 8086 Microprocessor Trainer Kit is proposed to smooth the progress of
learning and developing designs of 8086 microprocessor from Intel. It has Facility
to connect PC’s 101/104 Keyboard making this kit as standalone, User can enter
user programs in Assembly languages. User verifies the programs through LCD
or PC. User friendly Firmware confirms facilitating the beginners learns
operations of a microprocessor quickly.

6. Program: For this experiment we are using MASM as programming tool.

i) Addition of two 8-bit numbers

.model small
.stack 100h
.data
NUM DB 12H, 34H
SUM DB 2 DUP(0)
.code
START: MOV AX,@data
MOV DS,AX ;Initialize data segment Register
MOV AL,NUM ;First number loaded into AL
MOV AH,0H ;For carry AH register is cleared
ADD AL,NUM+1 ;Second number added with AL
JNC DOWN ;Check for carry
INC BX ;If carry generated increment the AH
DOWN: MOV SUM,AL ;Storing the sum value
MOV SUM+1,AH ;Storing the carry value
INT 3H
END START
ENDS
Output:
ii) Addition of two 16-bit numbers

.model small
.stack 100h
.data
NUM DW 1234H, 0F234H
SUM DW 2 DUP(0)
.code
START: MOV AX,@data
MOV DS,AX ;Initialize data segment Register
MOV AX,NUM ; First number loaded into AX
MOV BX,0H ; For carry BX register is cleared
ADD AX,NUM+2 ; Second number added with AX
JNC DOWN ; Check for carry
INC BX ; If carry generated increment the BX
DOWN: MOV SUM,AX ; Storing the sum value
MOV SUM+2,BX ; Storing the carry value
INT 3H
END START
ENDS
iii) Subtraction of two 8-bit numbers

.model small
.stack 100h
.data
NUM DB 45H, 34H
DIFF DB 2 DUP(0)
.code
START: MOV AX,@data
MOV DS,AX ;Initialize data segment Register
MOV AL,NUM ;First number loaded into AL
MOV AH,0H ;For carry AH register is cleared
SUB AL,NUM+1 ;Second number subtracted from AL
JNC DOWN ;Check for borrow
INC BX ;If borrow generated increment the AH
DOWN: MOV DIFF,AL ;Storing the sum value
MOV DIFF+1,AH ;Storing the carry value
INT 3H
END START
ENDS
iv) Subtraction of two 16-bit numbers

.model small
.stack 100h
.data
NUM DW 1234H, 0234H
SUM DW 2 DUP(0)
.code
START: MOV AX,@data
MOV DS,AX ;Initialize data segment Register
MOV AX,NUM ; First number loaded into AX
MOV BX,0H ; For carry BX register is cleared
ADD AX,NUM+2 ; Second number subtracted from AX
JNC DOWN ;Check for borrow
INC BX ; If borrow generated increment the BX
DOWN: MOV SUM,AX ; Storing the sum value
MOV SUM+2,BX ; Storing the carry value
INT 3H
END START
ENDS

v) Multiplication of two 8-bit numbers

.model small
.stack 100h
.data
NUM DB 12H, 34H
PROD DB 2 DUP(0)
.code
START: MOV AX,@data
MOV DS,AX
LEA SI,NUM ;SI pointed to the Multiplicand
MOV AH, 0 ;clear AH register
MOV AL,[SI] ;Multiplicand has to be in AL register
MOV BL,[SI+1] ;SI+2 pointed to the Multiplier and move it to BL
MUL BL ;Perform the multiplication
MOV PROD,AL ;16 bit product stored in AH-AL registers
MOV PROD+1, AH
INT 3H
END START
ENDS
vi) Multiplication of two 16-bit numbers

.model small
.stack 100h
.data
NUM DW 1234H,1234H
PROD DW 2 DUP(0)
.code
START: MOV AX,@data
MOV DS,AX
LEA SI,NUM ;SI pointed to the Multiplicand
MOV AX,[SI] ;Multiplicand has to be in AX register
MOV BX,[SI+2] ;SI+2 pointed to the Multiplier and move it to BX
MUL BX ;Perform the multiplication
MOV PROD,AX ;32 bit product stored in DX-AX registers
MOV PROD+2,DX
INT 3H
END START
ENDS

vii) Division of two 8-bit numbers

.model small
.stack 100h
.data
NUM1 DB 46H
NUM2 DB 11H
QUO DB 1 DUP(0)
REM DB 1 DUP(0)
.code
START: MOV AX,@data
MOV DS,AX
MOV AL,NUM1 ;Move the lower bit of Dividend to AL
MOV AH,00 ; Move the higher bit of Dividend to AH
DIV NUM2 ; Perform the Division operation
MOV QUO,AL ; Store the quotient to AL
MOV REM,AH ; Store the reminder to AH
INT 3H
END START
ENDS
viii) Division of two 16-bit numbers
.model small
.stack 100h
.data
NUM1 DW 2246H
NUM2 DW 1111H
QUO DW 1 DUP(0)
REM DW 1 DUP(0)
.code
START: MOV AX,@data
MOV DS,AX
MOV AX,NUM1 ;Move the lower bit of Dividend to AX
MOV DX,00 ; Move the higher bit of Dividend to DX
DIV NUM2 ; Perform the Division operation
MOV QUO,AX ; Store the quotient to AX
MOV REM,DX ; Store the reminder to DX
INT 3H
END START
ENDS

7. Conclusion: Write in your own words.

You might also like