Microprocessor Experiment No.: 1 Use of Programming Tools Microprocessor Lab Experiment No.: 1 Use of Programming Tools
Microprocessor Experiment No.: 1 Use of Programming Tools Microprocessor Lab Experiment No.: 1 Use of Programming Tools
Microprocessor Lab
Experiment No.: 1
Experiment No. 1
1. Aim: Use of programming tools (Debug/TASM/MASM/8086kit) to perform basic
arithmetic operations on 88-bit/16-bit data.
2. Objective: To understand the programming tools used in assembly language
programming for 8086.
3. Outcomes: The learner wil
will be able to
• Write basic programs for 88-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
Ubuntu/Windows
5. Theory:
• Debug: Translating th
thee assembly language to machine code is similar to building
a circuit from a schematic diagram. Debugging can help in determining:
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
culation check.
• TASM:: Turbo Assembler is an assembler for software development published by
Borland in 1989. It runs on and produces code for 16
16- or 32-bit
bit x86 MS-DOS
MS and
compatibles or Microsoft Windows. TASM itself is a 16-bit
bit program. It will run
on 16- and 32-bit
bit versions of Windows, and produce code for the same versions,
but it does not generate 64
64-bit x86 code.
• MASM: The Microsoft Macro Assembler (MASM) is an x86 assembler that uses
the Intel syntax for MS
MS-DOS
DOS and Microsoft Windows. Beginning with MASM
MA
.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
erated 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:
.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
.model small
.stack 100h
.data
NUM DB 45
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
econd 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
DIFF+1,AH ;Storing the carry value
INT 3H
END START
ENDS
.model small
.stack 100h
.data
NUM DW 1234H, 0234H
SUM DW 2 DUP(0)
.code
START: MOV AX,@data
MOV DS
DS,AX ;Initialize data segment Register
MOV AX,NUM ; First number loaded into AX
MOV BX,0H ; For carry BXX 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
.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,[
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 AL registers
MOV PROD+1, AH
INT 3H
END START
ENDS
vi) Multiplication
tiplication of two 16
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 AX registers
MOV PROD+2,DX
INT 3H
END START
ENDS
.model small
.stack
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
QUO,AL ; Store the quotient to AL
A
MOV REM
REM,AH ; Store the reminder to AH
INT 3H
END START
ENDS