0% found this document useful (0 votes)
16 views

MPMC - Unit-2 Programs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

MPMC - Unit-2 Programs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

ADITYA COLLEGE OF ENGINEERING &

TECHNOLOGY

Microprocessors and Microcontrollers


Topic
8086 Programs

P.A.Sravanthi
Asst Professor
Department of Electronics and Communication Engineering
Aditya College of Engineering & Technology
Email: [email protected]
Aditya College of Engineering & Technology

UNIT-II
8086 Programming:
Program development steps, instructions, addressing modes,
assembler directives, writing simple programs with an assembler,
assembly language program development tools.

MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology

8086 Programs

MPMC P.A.SRAVANTHI
Program development steps Aditya College of Engineering & Technology

MPMC P.A.SRAVANTHI
Assembly Language Program Development Tools Aditya College of Engineering & Technology

Editor
•An Editor is a program which allows us to create a file containing the assembly language
statements for the program.
•As we type the program the editor stores the ACSII codes for the letters and numbers in
successive RAM locations.
• If any typing mistake is done editor will alert us to correct it.
• If we leave out a program statement an editor will let you move everything down and
insert a line.
•After typing all the program we have to save the program for a hard disk.
•This we call it as source file.
•The next step is to process the source file with an assembler.
•While using TASM or MASM we should give a file name and extension .ASM.
Ex: Sample. asm
MPMC P.A.SRAVANTHI
Assembly Language Program Development Tools Aditya College of Engineering & Technology

Assembler
•An Assembler is used to translate the assembly language mnemonics into machine
language( i.e binary codes).
•When you run the assembler it reads the source file of your program from where you
have saved it.
•The assembler generates two files. The first file is the Object file with the extension
.OBJ.
•The object file consists of the binary codes for the instructions and information about
the addresses of the instructions.
•After further processing, the contents of the file will be loaded in to memory and run.
The second file is the assembler list file with the extension .LST.

MPMC P.A.SRAVANTHI
Assembly Language Program Development Tools Aditya College of Engineering & Technology

Linker
•A linker is a program used to connect several object files into one large object file.
•While writing large programs it is better to divide the large program into smaller modules.
•Each module can be individually written, tested and debugged.
•Then all the object modules are linked together to form one, functioning program.
•These object modules can also be kept in library file and linked into other programs as
needed.
•A linker produces a link file which contains the binary codes for all the combined modules.
•The linker also produces a link map file which contains the address information about the
linked files.
•The linkers which come with TASM or MASM assemblers produce link files with
the .EXE extension.
MPMC P.A.SRAVANTHI
Assembly Language Program Development Tools Aditya College of Engineering & Technology

Locator

•A locator is a program used to assign the specific addresses of where the segments of
object code are to be loaded into memory.

•A locator program called EXE2BIN comes with the IBM PC Disk Operating System (DOS).
EXE2BIN converts a .EXE file to a .BIN file which has physical addresses.

MPMC P.A.SRAVANTHI
Assembly Language Program Development Tools Aditya College of Engineering & Technology

Debugger

•A debugger is a program which allows to load your object code program into system
memory, execute the program, and troubleshoot or debug it.
•The debugger allows to look into the contents of registers and memory locations after
the program runs. We can also change the contents of registers and memory locations
and rerun the program.
•Some debuggers allows to stop the program after each instruction so that you can check
or alter memory and register contents. This is called single step debug.
•A debugger also allows to set a breakpoint at any point in the program.
• If we insert a break point, the debugger will run the program up to the instruction
where the breakpoint is put and then stop the execution.

MPMC P.A.SRAVANTHI
Assembly Language Program Development Tools Aditya College of Engineering & Technology

Emulator

•An emulator is a mixture of hard ware and software.

• It is usually used to test and debug the hardware and software of an external system
such as the prototype of a microprocessor based instrument.

MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
OPR1 DW 3423H
MOV RESULT,AX
OPR2 DW 6789H
INT 3H
RESULT DW DUP(?)
CODE ENDS
DATA ENDS END START
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,OPR1
Addition of two 16-bit numbers
MOV BX,OPR2
ADD AX,BX

MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
OPR1 DW 3423H
MOV [RESULT],AX
OPR2 DW 6789H
INT 21H
RESULT DW 02H DUP(?)
CODE ENDS
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,OPR1
Subtraction of two 16-bit numbers
MOV BX,OPR2
SUB AX,BX

MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
OPR1 DW 1234H
MUL BX
OPR2 DW 5678H
MOV [RESULT],AX
RESULT DW 03H DUP(0)
MOV [RESULT+2],DX
DATA ENDS
INT 3H
CODE SEGMENT
CODE ENDS
START: MOV AX,DATA
END START
MOV DS,AX
XOR DX,DX
Multiplication of two 16-bit numbers
MOV AX,OPR1
MOV BX,OPR2

MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
OPR1 DW 0ABCDH
DIV BX
OPR2 DW 0EF98H
MOV [RESULT],AX
OPR3 DW 1234H
MOV [RESULT+2],DX
RESULT DW 03H DUP(0)
HLT
DATA ENDS
CODE ENDS
CODE SEGMENT
END START
START: MOV AX,DATA
MOV DS,AX
Division of two 32-bit/16-bit numbers
MOV DX,OPR1
MOV AX,OPR2
MOV BX,OPR3
MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
N1 DB 45H
OR AX,3030H
RESULT DW 01H DUP(?)
MOV [RESULT],AX
DATA ENDS
HLT
CODE SEGMENT
CODE ENDS
START: MOV AX,DATA
END START
MOV DS,AX
MOV AL,N1
MOV AH,AL
Conversion of a packed BCD
AND AL,0FH
to ASCII number
AND AH,0F0H
MOV CL,04H
MPMC ROR AH,CL P.A.SRAVANTHI
Aditya College of Engineering & Technology
ASSUME CS: CODE, DS: DATA
MOV CL, NUM
DATA SEGMENT
BACK: MUL CL
NUM DB 05H
LOOP BACK
RES DW 01H DUP(0)
MOV [RES], AX
DATA ENDS
HLT
CODE SEGMENT
CODE ENDS
ORG 1000H
END START
START: MOV AX, DATA
MOV DS, AX
XOR AX, AX
XOR CX, CX
INC AX
Factorial of a given number
MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology
ASSUME CS:CODE, DS:DATA
BACK: ROL AX,01H
DATA SEGMENT
JNC NEXT
OPR1 DW 1234H
INC BL
RESULT DB 01H DUP(0)
NEXT: DEC CL
DATA ENDS
JNZ BACK
CODE SEGMENT
MOV [RESULT],BL
START: MOV AX,DATA
HLT
MOV DS,AX
CODE ENDS
MOV AX,OPR1
END START
XOR BX,BX
MOV CL,10H
Counting of logical 1’s in a
word

MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology
REPEAT: MOV AL,[SI]
ASSUME CS:CODE, DS:DATA
ROL AL,01H
DATA SEGMENT
JC NEGATIVE
NUMBERS DB 34H, 40H, 85H, 0A3h,
INC BL
70H
JMP NEXT
RESULT DW 02 DUP(?)
NEGATIVE: INC BH
DATA ENDS
NEXT: INC SI
CODE SEGMENT
LOOP REPEAT
START: MOV AX, DATA
MOV
MOV DS, AX
[RESULT],BX
MOV SI, OFFSET NUMBERS Counting of +ve and
CODE ENDS
–ve numbers in a
END START
MOV BX,0000H given byte array
MOV CX,0005H
MPMC P.A.SRAVANTHI
Aditya College of Engineering & Technology
REPEAT: MOV AL,[SI]
ASSUME CS:CODE, DS:DATA ROR AL,01H
DATA SEGMENT JC ODD1
NUMBERS DB 34H, 40H, 85H, 0A3h, INC BL
70H
JMP NEXT
RESULT DW 02H DUP(?)
ODD1: INC BH
DATA ENDS
NEXT: INC SI
CODE SEGMENT
LOOP REPEAT
START: MOV AX, DATA
MOV
MOV DS, AX [RESULT],BX
MOV SI, OFFSET NUMBERS CODE ENDS Counting of odd and
END START
even numbers in a
MOV BX,0000H given byte array
MPMC MOV CX,0005H P.A.SRAVANTHI

You might also like