Sie sind auf Seite 1von 80

www.prsolutions.

in
nd st

www.prsolutions.in

MICROPROCESSORS
LABORATORY MANUAL

Lab incharge HOD


Exercise No:M.1.1 Page No: 2

MICROPCROCESSORS
LABORATORY MANUAL

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 3

TABLE OF CONTENTS

S.NO NAME OF THE EXERCISE PAGE NO

I. MICROPROCESSOR 8086

M.1
1. Introduction 5
2. Using Turbo – Assembler-Linker-Debugger 8
(TASM,TLINK,TD)
3. Introduction to the trainer & Instructions to user 10

M.2
1.a). 8bit addition 18
b). 16bit addition 20
2.a). 8bit subtraction 22
b). 16bit subtraction 23
3.a). 8bit multiplication 24
b). 16bit multiplication 25
4.a). 8bit division 26
b). 16bit division 28
5. Multi byte addition 29
6. Multi byte subtraction 31
7. Signed multiplication 33
8. Signed division 34
9. ASCII addition 35
10. ASCII subtraction 36
11. ASCII multiplication 37
12. ASCII division 38

M.3
1. Packed to unpacked BCD 39
2. BCD to ASCII conversion 41

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 4

S.NO NAME OF THE EXERCISE PAGE NO

M.4
1. Block Transfer 42
2. String Reversal 43
3. String insertion 44
4. String deletion 45
5. Length of string 46
6. String comparison 47

M.5
1. Program design example (calculator) 48

M.6
1. DOS interrupts 56

II. INTERFACING

1. i8279 Keyboard/Display Interface 58


2. i8086 LED’s & switch interface 67

III. MICROCONTROLLER 8051

1. i8051 LED’s & switch interface 73

2. Transferring a block of data from 77


internal ROM to internal RAM

3. a) Internal ROM to external RAM 78


b) Internal ROM to external RAM 79

4. Understanding the three memory 80


areas of 00-FF

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 5

INTRODUCTION

EDITOR

An editor is a program, which allows you to create a file containing the assembly language
statements for your program. As you type in your program, the editor stores the ASCII codes for the
letters and numbers in successive RAM locations. When you have typed in all of your programs, you
then save the file on a floppy of hard disk. This file is called source file. The next step is to process
the source file with an assembler. In the TASM assembler, you should give your source file name the
extension, .ASM

ASSEMBLER

An assembler program is used to translate the assembly language mnemonics for instructions
to the corresponding binary codes. When you run the assembler, it reads the source file of your
program the disk, where you saved it after editing on the first pass through the source program the
assembler determines the displacement of named data items, the offset of labels and pails this
information in a symbol table. On the second pass through the source program, the assembler
produces the binary code for each instruction and inserts the offset etc that is calculated during the
first pass. The assembler generates two files on floppy or hard disk. The first file called the object
file is given the extension. OBJ. The object file contains the binary codes for the instructions and
information about the addresses of the instructions. The second file generated by the assembler is
called assembler list file. The list file contains your assembly language statements, the binary codes
for each instructions and the offset for each instruction. In TASM assembler, TASM source file
name ASM is used to assemble the file. Edit source file name LST is used to view the list file, which
is generated, when you assemble the file.

LINKER

A linker is a program used to join several object files into one large object file and convert to
an exe file. The linker produces a link file, which contains the binary codes for all the combined
modules. The linker however doesn’t assign absolute addresses to the program, it assigns is said to
be relocatable because it can be put anywhere in memory to be run. In TASM, TLINK source
filename is used to link the file.

DEBUGGER

A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot are debug it the debugger allows you to look at the
contents of registers and memory locations after your program runs. It allows you to change the
contents of register and memory locations after your program runs. It allows you to change the
contents of register and memory locations and return the program. A debugger also allows you to set
a break point at any point in the program. If you inset a breakpoint the debugger will run the program
upto the instruction where the breakpoint is set and stop execution. You can then examine register
and memory contents to see whether the results are correct at that point. In TASM, td filename is
issued to debug the file.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 6

DEBUGGER FUNCTIONS:

1. Debugger allows to look at the contents of registers and memory locations.


2. We can extend 8-bit register to 16-bit register which the help of extended register option.
3. Debugger allows to set breakpoints at any point with the program.
4. The debugger will run the program upto the instruction where the breakpoint is set and then
stop execution of program. At this point, we can examine registry and memory contents at
that point.
5. With the help of dump we can view register contents.
6. we can trace the program step by step with the help of F7.
7. We can execute the program completely at a time using F8.

DEBUGGER COMMANDS

ASSEMBLE: To write assembly language program from the given address.


A starting address <cr>
Eg: a 100 <cr>
Starts program at an offset of 100.

DUMP: To see the specified memory contents


D memory location first address last address
(While displays the set of values stored in the specified range, which is given above)
Eg: d 0100 0105 <cr>
Display the contents of memory locations from 100 to 105(including).

ENTER: To enter data into the specified memory locations(s).


E memory location data data data data data …<cr>
Eg: e 1200 10 20 30 40 ….
Enters the above values starting from memory locations 1200 to 1203, by loading 10 into
1200,20 into 1201 and soon.

GO: To execute the program


G: one instruction executes (address specified by IP)
G address <cr>: executes from current IP to the address specified
G first address last addresses <cr>: executes a set of instructions specified between the given
addresses.

MOVE: Moves a set of data from source location to destination location


M first address last address destination address
Eg: m100 104 200
Transfers block of data (from 100 to 104) to destination address 200.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 7

QUIT: To exit from the debugger.


Q <cr>

REGISTER: Shows the contents of Registers


R register name
Eg: r ax
Shows the contents of register.

TRACE: To trace the program instruction by instruction.


T = 0100 <cr>: traces only the current instruction. (Instruction specified by IP)
T = 0100 02 <cr>: Traces instructions from 100 to 101, here the second argument specifies the
number of instructions to be traced.

UNASSEMBLE: To unassembled the program.


Shows the opcodes along with the assembly language program.
U 100 <cr>: unassembled 32 instructions starting from 100th location.
U 0100 0109 <cr>: unassebles the lines from 100 to 104

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 8

Using Turbo – Assembler – Linker – Debugger


(TASM, TLINK, TD)

1. Open an MSDOS window.


2. Set the PATH so that the TASM programs are available
The TASM programs are on the C drive; set the path so that DOS can find them. This only
needs to be done once each time you open an MSDOS prompt. set PATH=%PATH%;C:\TASM\BIN
3. Use a Text Editor to Edit the .ASM File

Create your file using one of the following programs:


notepad proj.asm
wordpad proj.asm
edit proj.asm

4. Compile the source code to create an object module.


tasm/z/zi proj.asm
The /z switch causes TASM to display the lines that generate compilation errors. The /zi switch
enables information needed by the debugger to be included in the .OBJ file. Note that you should use
"real mode" assembler, TASM.EXE. Do not use the "protected mode" assembler TASM32.EXE for
the assignments that will be given in class

5. Run Linker TLINK.EXE- generate .EXE file from the .OBJ file
tlink/v proj

6. Run the Program


Your final program (if there were no errors in the previous step) will have an .EXE ending. To just
run it, type:
proj
If you want to use the debugger to examine the instructions, registers, etc., type:
td proj
This brings up the regular full-screen version of the Turbo debugger.

1. Tracing the Program's Execution


The Turbo debugger first starts, a Module Window which displays the . Executable lines of program
code, marked with a bullet in the left column of the window. You can set breakpoints or step to any
of these lines of code. An arrow in the first column of the window indicates the location of the
instruction pointer. This always points to the next statement to be executed. To execute just that
instruction use one of the two methods listed under the Run menu item:
o Trace into (can use F7 key): executes one instruction; traces "into" procedures.
o Step over (can use F8 key): executes one instruction; skips (does not trace into) procedures.
Hitting either of these executes the instruction, and moves the arrow to the next instruction. As each
instruction executes, the effects might be visible in the Registers Window and Watches Window

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 9

o Trace into (can use F7 key): executes one instruction; traces "into" procedures.
o Step over (can use F8 key): executes one instruction; skips (does not trace into) procedures.
Hitting either of these executes the instruction, and moves the arrow to the next instruction. As each
instruction executes, the effects might be visible in the Registers Window and Watches Window

2. Setting and Removing Breakpoints


To set a breakpoint, position the cursor on the desired line of source code and press F2. The line
containing the breakpoint will turn red. Pressing F2 again removes the breakpoint. To execute all
instructions from the current instruction pointer up to the next encountered breakpoint, choose Run
(can use F9 key) from the Run menu item.

3. Examining Registers
Another window, the Registers Window, can be opened to examine the current value of the CPU
registers and flags. The View menu can be used to open this Registers Window. The registers and
flags might change as each instruction is executed.

4. Examining Memory
To examine memory, you will need to open an Inspector window. An Inspector window shows the
contents of a data structure (or simple variable) in the program you are debugging. It also allows you
to modify the contents of the data structure or variable. To open an Inspector window, place the
cursor on what you want to inspect and press CTRL-I. After you've examined the data item, press the
ESC key to remove the Inspector window.

5. Viewing the Program's Output


Output written to the screen by a program is not immediately visible, since the main purpose of using
a debugger is to examine the internal operation of the program. To observe what the user would see,
press ALT-F5. The entire screen will change to a user-view showing the program's input and output
(and possibly that of previous programs as well). Press any key to return to the debugger screen.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 10

Introduction to the trainer & Instructions to user


INTRODUCTION
ESA 86/88 –2 is a powerful, general-purpose microcomputer system, which can be operated either
with 8086 CPU or with 8086CPU. It is generally supplied with 8086 CPU. To change it to 8088, user
has to just remove the 8086, insert 8088 into that socket and set a DIP switch.

The 8086 and 8088 are third generation CPU is from INTEL that differ primarily in their external
data paths. 8088 uses and 8-bit wide data bus while 8086 uses a 16-bit wide bus. ESA86/88-2 can be
operated with either CPU and the only possible difference would be in the speed of execution (with
8088 CPU, a small speed degradation occurs because of the 8-bit wide data bus). In either case, the
CPU is operated in the maximum mode.

Following are the system capabilities

• Examine and optionally modify the contents of memory (byte or word format)
• Examine and optionally modify the processor registers.
• Assemble and Disassemble 8086/8088 instructions (via line assembler, disassembler).
• Perform fast numerical computations using the optional 8087 Numeric data processor.
• Execute the user program at full speed.
• Debug user program through single step and Breakpoint facilities.
• Write or read data to or from I/O ports (byte or word format).
• Move a block of data or program within the memory
• Download user programs into ESA 86/88-2 from a host computer system.

SPECIFICATIONS:

Central processor
8086 CPU, operating at 8MHz in maximum mode. (Supplied with 8086 CPU). (Memory
cycles have zero wait states and I/O cycles have one wait state).

Co-Processor
On-board 8087 Numeric Data processor (optional)

Memory
EPROM: 4 JEDEC compatible slots offer the following options:
64K bytes using 27128s or,
128K bytes using 27256s or,
256K bytes using 27512s
(System firmware is supplied in 2x27256s. The other two sockets are for user expansion).

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 11

RAM: 4 JEDEC Compatible offer the following:

128K bytes using 6255s (64K bytes supplied using 2x62556s. The other two sockets are for
user expansion). RAM has battery backup facility.

Peripherals and Controllers


8251A: Programmable Communication Interface for serial communication supporting all
standard from 110-19,200 (Baud is selected through on-board Dipswitch).
8253-5: (2 Nos.) programmable peripheral Interface devices provide 48 Programmable I/O lines.
8259A: Programmable interrupt Controller provides interrupt vectors for 8 sources
8288: Bus controller used for generating control signals.

Interrupts
External: NMI for INTR Keyboard.
INTER controlled through 8259A, on-board Interrupt Controller: provides interrupt vectors
for eight sources. Complete flexibility in selecting off-board or on-board interrupt sources.

On-board interrupt sources

# 8251 (TxRDY and RxRDY)


# 8253-5 (OUT1 and OUT2)
# 8255A (PC0 and PC3 in handshake mode)
# 8087 (NDP INT)
Internal: Interrupt vectors 1(single step) and 3 (breakpoint) reserved for monitor.

Interface Signals

CPU Bus: Demultiplexed and fully buffered, TTL compatible, Address, Data & Control
signals are available on two 50-pin ribbon cable connectors.
Parallel I/O: 48 Programmable parallel I/O lines (TTL compatible) through two 26 pin
ribbon cable connectors. (Connector details compatible to our other microcomputer trainers).
Serial I/O: RS 232 C through on-board 9pin D-type female connector.
Power supply (optional): +5V @ 3.0Amp

CONFIGURATION AND INSTALLATION


Configuration ESA 86/88-2
ESA 86/88-2-microcomputer trainer is versatile and can be configured in a number of ways, as
determined by the setting of a DIPswitch and other jumpers. (Refer to the component layout
diagram in appendix C to locate the DIPswitch and the jumpers). This chapter describes all the
configuration options and the installation procedures.

Operational mode selection


ESA 86/88-2 can be operated either in the serial mode or in Hexadecimal keypad mode. In the
serial mode, the trainer is connected to a CRT terminal or to a host computer system (like PC
compatible) through an RS 232 C interface. In the keypad mode, the trainer is operated through
Hexadecimal keypad.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 12

SW4 of the DIP switch Operational mode


OFF Serial mode
ON Hexadecimal keypad mode*
(*Factory installed Option)

Printer Enable/Disable
ESA 86/88-2 firmware includes the driver program fro centronics compatible parallel printer
interface. This driver can be enabled/disabled as shown below:

SW5 of the DIP Switch Printer Driver


OFF Disabled*
ON Enabled

(*Factory installed Option)

Baud rate selection


In the serial mode of operation, ESA 86/88-2 configures an 8251A USART as follows:

ƒ Asynchronous mode
ƒ 8-bit character length
ƒ 2 stop bits
ƒ No parity
ƒ Baud rate factor of 16X
Timers 0 of an 8253 provide the Transmit and receive baud clocks for the USART. (Refer to
chapter 5 for a detailed discussion of the Hardware).This timer is initialized by the system firmware
to provide proper baud clock based on the settings of the DIP Switch as shown below.

DIP SWITCH
SW3 SW2 SW1 Baud rate
OFF OFF ON 9,600*

Memory selection:

ESA 86/88-2 has four sockets, labeled U9, U8, U7, U6 for RAM. These sockets are configured for
62256(32X 4) devices. Two of these sockets are populated (providing 64K Bytes of RAM) and two
are for user expansion.

DEVICE DIP SWITCH JUMPER


SW7 SW6
27256 ON OFF JP10 – 1-2

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 13

Hexadecimal keypad Legend Interpretation


Hexadecimal Acronym Name Acronym Name
0
EB/AX EB Examine Byte AX Accumulator

1
ER/BX ER Examine Register BX Base Register

2
GO/CX GO Go CX Count Register

3
ST/DX ST Single Step DX Data Register

4
IB/SP IB Input Byte SP Stack Pointer

5
OB/BP OB Output Byte BP Base Pointer

6
MV/SI MV Move SI Source Index

7
EW/DI EW Examine Word DI Destination index

8 Code Segment
IW/CS IW Input word CS

9 Data Segment
OW/DS OW Output Word DS

A Stack Segment
/SS None N/A SS

B Extra Segment
/ES None N/A ES

C Instruction Pointer
/IP None N/A IP
Flag Register
D
/FL None N/A FL N/A

E None N/A none N/A

F None N/A none

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 14

Function Key Operation

Function Key
Operation
RESET The RESET key allows you to terminate any present activity and to return your
ESA 86/88-2 to an initialize state. When pressed, the sign-on message appears in
the display and the monitor is ready for command entry.

KB INT The INTR (interrupt) key is used to generate an immediate non-maskable type 2
interrupt (NM). The NMI interrupt vector is initialized on power up or system
reset to point to a routine within the monitor which causes all of the 8086/8088’s
registers to be saved. Control is returned to the monitor for subsequent command
entry.

+ The + (plus) key allows you to add two hexadecimal values. This function
simplifies relative addressing by allowing you to readily calculate an address
location relative to a base address.

- The – (minus) key allows you to subtract one hexadecimal value from another.

The : (colon) key is used to separate an address to be entered into two parts; a
: segment value and an offset value.

REG The REG (register) key allows you to use the contents of any of the 8086/8088’s
registers as an address or data value.

NEXT The NEXT key is used to separate keypad entries and


(,) To increment the address field to the next consecutive memory location.

The PREV key is used to decrement the address field to previous memory
PREV location.

The dot key is the command terminator. When


EXEC Pressed, the current command is executed.
(.)

1) NEXT or, means the same operation


NOTE: 2) EXEC or, means the same operation

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 15

Summary of Monitor commands


Command Group Command Function/Format
Examine/modify Examine Byte Displays/modifies memory byte locations
EB <address>,[[<data>] NEXT or PREV].

Examine word Displays/modifies memory word locations


EW <address>,[[<data>],]NEXT of PREV].

Examine Register Displays/modifies processor register contents


ER<reg key>[[<data>] NEXT] [.]

Input/Output Input Byter Displays the data byte at the input port.
IB <port address> NEXT [NEXT].

Input word Displays the data word at the input port.


IW <port address> NEXT [NEXT].

Output byte outputs the data byte to the output port.


OB <port address>NEXT <data> [NEXT <data>]

Output word outputs the data word to the output port.


OW <port address>NEXT <data> [NEXT<data>].

Execution Step Executes one single instruction.


ST [<Start address>NEXT [[<start address>] NEXT]

Go Transfers control from monitor to user program


GO [<address>] [NEXT<breakpoint address>].

Block Move Move Moves block of data within memory


MV <start address> NEXT <end address> NEXT <destination
address>.

EXAMINE BYTE AND EXAMINE WORD COMMANDS


Function: The Examine byte (EB) and Examine Word (EW) commands are used to examine the
contents of selected memory locations. If the memory location can be modified (e.g. a location in
RAM), the contents optionally be modified.

Format
EB <address> NEXT [[<data>] PREV/NEXT].
EW <address> NEXT [[<data>] PREV/NEXT].

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 16

Operation
1. Both the commands operate in a similar fashion. To use these commands, press the EB key or
EW key when prompted for a command.
2. When either key is pressed, a dot appears at the right edge of the address field indicating that
an address entry is required.
3. Enter the memory address of the byte (for EB) of word (for EW) to be examined. (The entry
of address values is discussed in detail in section 3.2)
4. After entering the address value, press the “,” key. (i.e. the NEXT key).
5. The data byte of word contents of the addressed memory location will be displayed in the
data field and a decimal point (a dot) appears at the right edge of data field indicating that the
data can be updated. Note that when using the Examine word command, the byte contents of
the displayed updated memory location appear in the two least-significant digits of the field
and the byte contents of the next consecutive memory location (i.e. entered memory address
+ 1) appear in the two most significant digits of the data field.
6. If the contents of the memory location addressed are only to be examined, press the ‘’.’’ Key
to terminate the command, of press the ‘’,’’ (NEXT) key to examine the next consecutive
memory location (Examine Byte Command) or the next two consecutive memory locations
(Examine Word Command) or press the ‘’PREV’’ key to examine previous byte or word
location.
7. To modify the contents of an addressed memory location, enter the new data from the
hexadecimal keyboard (entering the data values is discussed in detail in section 3.2).
8. The data displayed is not updated in memory until either the ‘’,’’ or ‘’.’’ Key is pressed.

EXAMINE BYTE AND EXAMINE WORD COMMANDS


Function: The Examine Byte (EB) and Examine Word (EW) commands are used to examine the
contents of selected memory locations. If the memory location can be modified (e.g. a location in
RAM), the contents optionally be modified.

Format
EB <address> NEXT [[<data>] PREV/NEXT].

EW <address> NEXT [[<data>] PREV/NEXT].

EXAMINE REGISTER COMMAND


Function
The Examine Register (ER) command is used to examine and optionally modify the contends of nay
of the 8086/8088’s registers.
Format ER <reg key> [[<data>],] [.]

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 17

INPUT/OUTPUT COMMANDS
There are 4 commands available for Input/Output of Byte/Word data form/to a specified port. In
entering the port address (in any of these four commands), it should be noted that 8086/8088 I/O
addressing is limited to 64K (maximum address is FFFFH). Thus no segment value is permitted with
the port address.

INPUT BYTE AND INPUT WORD COMMANDS

Function
The Input Byte (IB) and Input Word (IW) commands are used to input (accept) an 8-bit byte or 16-
bit word from an input port.

Format
IB <port address > , [,].
IW <port address> , [,].

STEP COMMAND

Function
This command is used for single step execution of a program. In other words, this step (ST)
command permits program instructions in memory to be executed individually. With each instruction
executed, control is returned to the monitor from the program being executed,
Format
ST [< start address>], [[<start address>,.

GO COMMAND

Function
The GO command is used to transfer control of the 8086/8088 from the keyboard monitor program
to user’s program.

Format
GO [<address>] [, <breakpoint address>]

MOVE COMMAND

Function
This command (MV) can be used to move a block of data from one portion of the memory to another
potion of the memory.

Format
MV <Start address> NEXT <end address> NEXT <destination address>.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 18

PROGRAM: 8BIT ADDITION

.model tiny
.stack 32h
.code
org 2000h

start:
mov ax,cs
mov ds,ax
mov ax,00
mov al,num1
mov bl,num2
add al,bl
mov result,al
int 3
mov ah,4ch
int 21h

org 20f0h
num1 db 03
num2 db 08
result db 00

end start

Result: 03h
08h
0Bh

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 19

Exercise:

1. What is the significance of model tiny?

2. How many model assignment are the name them?

3. What is a directive?

4. What is a pseudo operation?

5. ORG 2000H implies what?

6. At register is used why not AX?

7. What is the purpose of INT3 in the program?

8. What is the purpose of MOV AH, 4CH, INT 21H in the program?.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 20

PROGRAM: 16BIT ADDITION

.model tiny
.stack 32h
.code
org 2000h

start:
mov ax,cs
mov ds,ax
mov ax,00
mov ax,num1
mov bx,num2
add ax,bx
mov result,ax
int 3
mov ah,4ch
int 21h

org 20f0h
num1 dw 0ffffh
num2 dw 0ffffh
result dw 00

end start

Result: 0FFFFh 1111 1111 1111 1111 1111


0FFFFh 1111 1111 1111 1111 1111
1FFFEh 1,1111 1111 1111 1111 1110

Carry

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 21

Exercise:

1. Stack 32 implies what?

2. Can ORG have other numbers instead of 2000h?

3. What is the purpose of MOV AX,CS?


MOV DS,AX?

4. Why AX register is used and not AL?

5. What is the purpose of DW?

6. What happens if the result is greater than 16bit when result is declared an DW.?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 22

PROGRAM: 8BIT SUBTRACTION

.model tiny
.stack 32h
.code
org 2000h

start:
mov ax,cs
mov ds,ax
mov ax,00
mov al,num1
mov bl,num2
sub al,bl
mov result,al
int 3
mov ah,4ch
int 21h

org 20f0h
num1 db 0ffh
num2 db 0aah
result db 00

end start

Result: 0ffh
0aah
055h

Exercise:

1. What AL has been used and not AX ?

2. What happens if num1 contains 0AAH and num2 contains 0FFH. ?

3. How do you account for the difference obtained in previous question?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 23

PROGRAM: 16BIT SUBTRACTION

.model tiny
.stack 32h
.code
org 2000h

start:
mov ax,cs
mov ds,ax
mov ax,00
mov ax,num1
mov bx,num2
sub ax,bx
mov result,ax
int 3
mov ah,4ch
int 21h

org 20f0h
num1 dw 0ffffh
num2 dw 0eabch
result dw 00

end start

Result: 0ffffh
0eabch
01543h

Exercise:

1. Why should AX be used not AL. ?

2. What happens if num1 and num2 values are interchanged?

3. If carry is set to 1 before subtraction what is the instruction to be used?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 24

PROGRAM: 8BIT MULTIPLICATION

.model tiny
.stack 32h
.code
org 2000h

start:
mov ax,cs
mov ds,ax
mov ax,00
mov al,num1
mov bl,num2
mul bl
mov result,al
mov result1,ah
int 3
mov ah,4ch

Org 20f0h
num1 db 0ffh
num2 db 0aah
result db 00
result1 db 00

end start

Result: 0ffh
0aah
a956h

Exercise:

1. What is an extended accumulator?

2. AL and BL are used for multiplying why not AX & BX?

3. Instead of using MOV BL is it not possible to MUL num2?

4. What is the instruction used for signed multiplication?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 25

PROGRAM: 16BIT MULTIPLICATION

.model tiny
.stack 32h
.code
org 2000h

start:
mov ax,cs
mov ds,ax
mov ax,00
mov ax,num1
mov bx,num2
mul bx
mov result,ax
mov result1,dx
int 3
mov ah,4ch
int 21h

org 20f0h
num1 dw 0ffffh
num2 dw 0ffffh
result dw 00
result1 dw 00

end start

Result: 0ffffh
0ffffh
fffe0001h

Exercise:

1. Why AL & BL are not used in this?

2. If result exceeds 32 bit where is it stored?

3. What is the name given to the register combination DX:AX?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 26

PROGRAM: 8BIT DIVISION

.model tiny
.stack 32h
.code
org 2000h

start:
mov ax,cs
mov ds,ax
mov ax,00
mov dx,00
mov al,num1
mov bl,num2
div bl
mov Quotient,al
mov remainder,ah
int 3
mov ah,4ch
int 21h

org 20f0h
num1 db 0ffh
num2 db 0aah
Quotient db 00
remainder db 00

end start

Result: 0ffh
0aah
5501h Quotient: 01h
Remainder r: 55h

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 27

Exercise:

1. Why is the registers DX & AX made zero in the above program?

2. The above program?

3. Where is the remainder in 8 bit division?

4. Where is the quotient in 8 bit division?

5. If AH contains a non-zero value, what will be the result of the division?

6. Which interrupt is used when a divide overflow error occurs?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 28

PROGRAM: 16BIT DIVISION

.model tiny
.stack 32h
.code
org 2000h
start:
mov ax,cs
mov ds,ax
mov ax,00
mov dx,00
mov ax,num1
mov bx,num2
div bx
mov Quotient,ax
mov remainder,dx
int 3
mov ah,4ch
int 21h

org 20f0h
num1 dw 0ffffh
num2 dw 0aaaah
Quotient dw 00
remainder dw 00

end start

Result: 0ffffh
0aaaah
55550001h Quotient: 0001h
Remainder: 5555h

Exercise:

1. What happens if DX register contains a nonzero value before DIV instruction?

2. What is the instruction used for signed division?

3. In the above program instead of DIV BX is it possible to use DIV num2?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 29

PROGRAM: MULTY BYTE ADDITION

.model tiny

data segment
dp1 dd 11223344h
dp2 dd 55667788h
res dd 00000000h
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov si,offset dp1
mov di,offset dp2
mov bx,offset res
mov cx,03
sub ax,ax
mov al,[si]
mov dl,[di]
add al,dl
mov [bx],al
back:
inc si
inc di
inc bx
mov al,[si]
mov dl,[di]
adc al,dl
mov [bx],al
loop back
nop
mov ah,4ch
int 21h
code ends
end start

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 30

EXERCISE:

1. Why is add with carry instruction adc is used in the loop?

2. what is the purpose served by BX register?

3. Why addition is done with AL register why not with AX?

4. What is the other instruction which can be used instead of MOV SI,offset dp1.?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 31

PROGRAM: MULTY BYTE SUBTRACTION


.model tiny

data segment
dp2 dd 55667788h
dp1 dd 11223344h
res dd 00000000h
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
mov si,offset dp2
mov di,offset dp1
mov bx,offset res
mov cx,03
sub ax,ax
mov al,[si]
mov dl,[di]
sub al,dl
mov [bx],al
back:
inc si
inc di
inc bx
mov al,[si]
mov dl,[di]
sbb al,dl
mov [bx],al
loop back
nop
mov ah,4ch
int 21h
code ends
end start

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 32

EXERCISE:

1. Why is subtract with carry instruction is used in the loop?

2. What is the purpose served by BX register?

3. Why subtraction is done with AL register why not with AX ?

4. What is the other instruction which can be used instead of


MOV DI, offset dp2. ?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 33

PROGRAM: SIGNED MULTIPLICATION

.model tiny

data segment
dp1 db 0a5h
dp2 db 20h
res dw 00h
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
sub ax,ax
mov al,dp1
mov bl,dp2
imul bl
mov res,ax
nop
mov ah,4ch
int 21h
code ends
end start

EXERCISE:

1. What is the difference between IMUL and MUL?

2. What is the use of instruction CBW?

3. What is the use of instruction CWD?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 34

PROGRAM: SIGNED DIVISION

.model tiny

data segment
dp1 db 0d5h
dp2 db 20h
quo db 0h
rem db 0h
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
xor ax,ax
mov al,dp1
cbw
mov bl,dp2
idiv bl
mov quo,al
mov rem,ah
nop
mov ah,4ch
int 21h
code ends
end start

EXERCISE:

1. What is the purpose of SUB AX,AX?

2. What is the difference between IDIV and DIV?

3. What is the use of instruction CBW & CWD?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 35

PROGRAM: ASCII ADDITION

.model tiny

data segment
ip1 db '9',0dh,0ah
ip2 db '6',0dh,0ah
res db 0
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
xor ax,ax
mov al,ip1
add al,ip2
aaa
mov res,al
mov ah,4ch
int 21h
code ends
end start

EXERCISE:

1. What is the purpose of ASCII addition?

2. What is the instruction used for ASCII addition?

3. Why do we make use of instruction ORL AX,3030H ?

4. Why is aaa after addition?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 36

PROGRAM: ASCII SUBTRACTION

.model tiny

data segment
ip1 db '9',0dh,0ah
ip2 db '6',0dh,0ah
res db 0
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
xor ax,ax
mov al,ip1
sub al,ip2
aas
mov res,al
mov ah,4ch
int 21h
code ends
end start

EXERCISE:

1. What is the purpose of ASCII subtraction?

2. What is the instruction used for ASCII subtraction?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 37

PROGRAM: ASCII MULTIPLICATION

.model tiny

data segment
ip1 db 4
ip2 db 6
res db 0
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
xor ax,ax
mov al,ip1
mul ip2
aam
mov res,al
mov ah,4ch
int 21h
code ends
end start

EXERCISE:

1. What is the purpose of XCHG instruction is ASCII adjust after multiplication. ?

2. Why is ASCII adjust after multiply cab be called as 1 byte binary to bcd
conversion?

3. What does AL & AH contains?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 38

PROGRAM: ASCII DIVISION

.model tiny

data segment
ip1 db 6
ip2 db 4
res db 0
data ends

code segment
assume cs:code,ds:data

start: mov ax,data


mov ds,ax
xor ax,ax
mov al,ip1
aad
div ip2
mov res,al
mov ah,4ch
int 21h
code ends
end start

EXERCISE:

1. What is the ASCII instruction, which is used before the arithmetic operation?

2. Why is ASCII adjust before division is done before actual division?

3. What does AL & AH contains?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 39

PROGRAM: PACKED TO UNPACKED BCD

.model tiny

data segment
bcdip db 56h
ubcdop dw 0
data ends

code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
xor ax,ax
mov al, bcdip
mov dl,al
and al,0f0h
mov cl,4
ror al,cl
mov bh,al
and dl,0fh
mov bl,dl
mov ubcdop,bx
mov ah,4ch
int 21h
code ends
end start

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 40

EXERCISE:

1. What is the purpose of the instruction ROR AL, CL?

2. What is the purpose of the instruction AND AL, 0FH & AND AL,0F0H in the
program.?

3. What is the expansion of UPBCD?

4. What is the use of DAA instruction?

5. What is the reason for packing unpacked BCD?

6. What is common between unpacked BCD and ASCII?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 41

PROGRAM: BCD to ASCII CONVERSION

.model tiny

data segment
bcdip db 56h
ubcdop dw 0
data ends

code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
xor ax,ax
mov al, bcdip
mov dl,al
and al,0f0h
mov cl,4
ror al,cl
mov bh,al
and dl,0fh
mov bl,dl
mov ubcdop,bx
add bx,3030h
mov ah,4ch
int 21h
code ends
end start

EXERCISE:

1. What is the difference between adding 30h and OR 30H to a BCD number to
conversion to ASCII?

2. Why unpacking is necessary during the conversion?

3. What is the ASCII character for symbol A?

4. What is the ASCII character for symbol zero ‘0’?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 42

PROGRAM: BLOCK TRANSFER

;.model tiny

data segment
srcdata db 'Empty vessels make much noise',24h
data ends

extra segment
dstdata db 12 dup(0)
extra ends

code segment
assume cs:code,ds:data,es:extra

start: mov ax,data


mov ds,ax
mov ax,extra
mov es,ax
mov si,offset srcdata
mov di,offset dstdata
cld
mov cx,29
rep movsb
nop
mov ah,4ch
int 21h
code ends
end start

EXERCISE:

1. If the DF=1, will the SI and DI register decremented?

2. The destination memory is pointed by which register combination?

3. The source is pointed to by which register combination?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 43

PROGRAM: STRING REVERSAL

.model tiny

data segment
string1 db 'Empty'
strlen equ ($-string1)
string2 db 5 dup(0)
data ends

code segment
assume cs:code,ds:data,es:data

start: mov ax,data


mov ds,ax
mov es,ax
mov bx,offset string1
mov si,bx
mov di,offset string2
add di,5
cld
mov cx,strlen
a1:
mov al,[si]
mov es:[di],al
inc si
dec di
loop a1
;rep movsb
;nop
mov ah,4ch
int 21h
code ends
end start

EXERCISE:
1. Why BX register is added with ‘5’?

2. Why MOVS instruction is not used?

3. What is the function of LODS and STOS instructions?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 44

PROGRAM: STRING INSERTION

.model tiny

data segment
string1 db 'Empty vessels more noise$'
strlen equ ($-string1)
data ends

extra segment
string2 db strlen+5 dup(0)
extra ends

code segment
assume cs:code,ds:data,es:extra

start: mov ax,data


mov ds,ax
mov si,offset string1
mov di,offset string2
cld
mov cx,14
rep movsb
mov dl,5
back: mov ah,01
int 21h
stos string2
dec dl
jnz back
mov cx,11
rep movsb
nop
mov ah,4ch
int 21h
code ends
end start
EXERCISE:
1. Why register ‘DI’ is loaded with 5?

2. What is the function of rep movsb?

3. What is the purpose of mov ah,01h / int 21h?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 45

PROGRAM: STRING DELETION

.model tiny

data segment
string1 db 'Empty vessels make more noise$'
strlen equ ($-string1)
data ends

extra segment
string2 db strlen-5 dup(0)
extra ends

code segment
assume cs:code,ds:data,es:extra

start: mov ax,data


mov ds,ax
mov ax,extra
mov es,ax
mov si,offset string1
mov di,offset string2
cld
mov cx,13
rep movsb
cld
mov si,18
mov cx,12
rep movsb
mov ah,4ch
int 21h
code ends
end start

EXERCISE:
1. What is the purpose of string length?

2. What does ‘equ’ stands for?

3. What is the purpose of label start after the end directive?

Lab incharge HOD


Exercise No:M.1.1 Page No: 46

PROGRAM: LENGTH OF THE STRING

.model tiny
data segment
string1 db 'Empty vessels make more noise$'
strlen equ ($-string1)
res db 0
cort db 'strlength found correct$'
incort db 'strlength found incorrect$'
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
sub cl,cl
mov bl,strlen
mov si,offset string1
back:lodsb
inc cl
cmp al,'$'
jnz back
mov res,cl
cmp cl,bl
jz correct
mov dx,offset incort
mov ah,09
int 21h
correct:mov dx,offset cort
mov ah,09
int 21h
mov ah,4ch
int 21h
code ends
end start

EXERCISE:
1. What is the operation performed by the instruction cmp al,$ ?

2. What is function 09h / int 21h performed?

3. Why SI is not been incremented is the program?

Lab incharge HOD


G.N.I.T.S-ECE DEPARTMENT:MPI LAB
Exercise No:M.1.1 Page No: 47

PROGRAM: STRING COMPARISION

.model tiny
data segment
string1 db 'Empty'
strlen equ ($-string1)
notsful db 'strings are unequal$'
sful db 'strings are equal$'
data ends
extra segment
string2 db 'Empty'
extra ends
code segment
assume cs:code,ds:data,es:extra
start: mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
mov si,offset string1
mov di,offset string2
cld
;mov cx,length string1
mov cx,strlen
rep cmpsb
jz forw
mov ah,09h
mov dx,offset notsful
int 21h
jmp exitp
forw:mov ah,09h
mov dx,offset sful
int 21h
exitp:
nop
mov ah,4ch
int 21h
code ends
end start

EXERCISE:
1. What is the significance of CLD?

2. How does CMPSB perform the comparison?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 48

Program design example (calculator)


EXTRN ADDER:near, MULT:near, DIVD:near, SUBB:near
.model tiny

printf macro string


mov ah,09h
mov dx, offset string
int 21h
endm
getch macro
mov ah,01
int 21h
endm
.stack 160
.data
menu db 0ah,0dh,' A Simple Calculator'
db 0ah,0dh,' 1. addition'
db 0ah,0dh,' 2. subtraction'
db 0ah,0dh,' 3. multiplication'
db 0ah,0dh,' 4. division'
db 0ah,0dh,' X. exit the program'
db 0ah,0dh,' input your choice ?$'
addproc db 0ah,0dh,' addition procedure?$'
subproc db 0ah,0dh,' subtraction procedure?$'
divproc db 0ah,0dh,' division procedure?$'
mulproc db 0ah,0dh,' multiplication procedure?$'
num1 dw 0
num2 dw 0

PRESSANYKEY DB 0AH,0DH,'PRESS ANY KEY $'

binnum dw 0 ;accessed by asc2bin


overflowdmsg db 0dh,0ah, 'overflow error $';
invalidmsg db 0dh,0ah, 'invalid error $';

enternum db 0dh,0ah, 'please type a number less than 32000 $';from


asciinum db '00000$';getnum
binout dw 0ffffh
RESULT DB 0AH,0DH,0DH,0AH,0AH,0DH,0DH,0AH,0AH,0DH,0DH,0AH,'THE
RESULT IS '
ascout db '00000',0AH,0DH,0DH,0AH,0AH,0DH,0DH,0AH,0AH,0DH,0DH,0AH,'$'

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 49

.code
.startup

begin:
mov ax,@data
mov ds,ax
menuagain:
printf menu
getch
cmp al,'1'
jne nxt1
call addition
jmp menuagain
nxt1:
cmp al,'2'
jne nxt2
call subtract
jmp menuagain
nxt2:
cmp al,'3'
jne nxt3
call multiply
jmp menuagain
nxt3:
cmp al,'4'
jne nxt4
call divide
jmp menuagain
nxt4:
cmp al,'X'
jne menuagain

.exit

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 50

asc2bin proc

mov cx,5 ;put number of digits in cx


mov di,10 ;put base 10 in di to multiply acc with
mov bh,'9' ;bh to check if number greater than 9
mov bl,'0' ;bl checks lower limit of number
mov si,offset asciinum
xor ax,ax ; make accumulator zero
A2Bagain:mul di
jc overflow
mov dx,ax ; save multiply accumulate reister AX
mov al,[si]
cmp al,bl
jl invalid
cmp al,bh
jg invalid
sub al,30h
cbw
add ax,dx
jc overflow
inc si
loop A2Bagain
over: mov binnum,ax
ret
invalid: PRINTF invalidmsg
PRINTF PRESSANYKEY
GETCH
jmp BEGIN
overflow: PRINTF overflowdmsg
PRINTF PRESSANYKEY
GETCH
jmp BEGIN
asc2bin endp

bin2asc proc
xor si,si
mov di,offset ascout
add di,4
mov ax,binOUT
mov dx,0
mov bx,10
mov cx,5
ba: div bx
add dl,30h
mov [di],dl
dec di
xor dx,dx
loop ba
ret
bin2asc endp
Lab incharge HOD
www.prsolutions.in
Exercise No:M.1.1 Page No: 51

getnum proc
mov ah,9
mov dx,offset enternum
int 21h
mov si,offset asciinum
mov cx,5
GNagain: mov ah,01
int 21h
mov [si],al
inc si
loop GNagain
ret
getnum endp
multiply proc
call getnum
call asc2bin
mov ax,binnum
push ax
call getnum
call asc2bin
mov ax,binnum
push ax
call mult
pop ax
pop bx
add ax,bx
mov binout,ax
call bin2asc
PRINTF RESULT
ret
multiply endp

subtract proc
call getnum
call asc2bin
mov ax,binnum
push ax
call getnum
call asc2bin
mov ax,binnum
push ax
call subb
pop ax
pop bx
add ax,bx
mov binout,ax
call bin2asc
PRINTF RESULT
ret
subtract endp

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 52

divide proc

call getnum
call asc2bin
mov ax,binnum
push ax
call getnum
call asc2bin
mov ax,binnum
push ax
call divd
pop ax
pop bx
add ax,bx
mov binout,ax
call bin2asc
PRINTF RESULT
ret
divide endp

addition proc
call getnum
call asc2bin
push binnum
call getnum
call asc2bin
push BINNUM
CALL ADDER
pop ax
pop bx
mov binout,ax
call bin2asc
PRINTF RESULT
ret
addition endp

END

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 53

public adder

.model tiny
.code
adder proc near
push bp
mov bp,sp
add bp,6
mov ax,[bp]
dec bp
dec bp
mov bx,[bp]
add ax,bx
mov [bp],ax
inc bp
inc bp
mov ax,0
mov [bp],ax
pop bp
ret
adder endp
end

public mult
.model tiny
.code
mult proc near
push bp
mov bp,sp
add bp,6
mov ax,[bp]
dec bp
dec bp
mov bx,[bp]
mul bx
mov [bp],ax
inc bp
inc bp
mov ax,0
mov [bp],ax
pop bp
ret
mult endp
end

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 54

public subb

.model tiny
.code
subb proc near
push bp
mov bp,sp
add bp,6
mov ax,[bp]
dec bp
dec bp
mov bx,[bp]
sub ax,bx
mov [bp],ax
inc bp
inc bp
mov ax,0
mov [bp],ax
pop bp
ret
subb endp
end

public divd
.model tiny
.code
divd proc near
push bp
mov bp,sp
add bp,6
mov ax,[bp]
dec bp
dec bp
mov bx,[bp]
mov dx,00
div bx
mov [bp],ax
inc bp
inc bp
mov ax,0
mov [bp],ax
pop bp
ret
divd endp
end

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 55

EXERCISE:

1. What is the difference between a macro and a procedure?

2. What is the purpose of having 0ah & 0dh in message statement?

3. What is the associated directive to the EXTRN directive?

4. The menu in the instruction printf menu represents what?

5. What is performed by the directive startup?

6. Convert one of the procedure into near procedure?

7. Convert another procedure into far procedure in ASCII to binary procedure, a


famous algorithm is used. What is the name of the algorithm [refer Gibbson’s
book] ?

8. What is the significance of public in the file named adder?

9. What is BP used for in the adder procedure?

10. If the variables are RXCD and passed by the adder is it been by done by the
value or reference?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 56

PROGRAM: DOS INTERRUPTS

.model tiny
data segment
msg1 db 0ah,0dh,'Enter the first number: $'
msg2 db 0ah,0dh,'Enter the second number: $'
msg3 db 0ah,0dh,'Result: $'
res db 00
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
lea dx,msg1
mov ah,09h
int 21h
mov ah,01h
int 21h
sub al,30h
mov bl,al
lea dx,msg2
mov ah,09h
int 21h
mov ah,01h
int 21h
sub al,30h
add al,bl
add al,30h
mov res,al
lea dx,msg3
mov ah,09h
int 21h
mov dl,res
mov ah,02h
int 21h
mov ah,4ch
int 21h
code ends
end start

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 57

EXERCISE:

1. After executing the instructions mov ah,01h / int 21h, what are contents of AL ?

2. What are the contents of AH for displaying a sting in the screen?

3. What are the contents of AH for accepting a number from keyboard?

4. Which register contains the address of the string to be displayed on screen?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 58

Programmable Keyboard/Display Interface – 8279

• A programmable keyboard and display interfacing chip.


o Scans and encodes up to a 64-key keyboard.
o Controls up to a 16-digit numerical display.

• Keyboard has a built-in FIFO 8 character buffer.

• The display is controlled from an internal 16x8 RAM that stores the coded
display information.

Pinout Definition 8279


• A0: Selects data (0) or control/status (1) for reads and writes between micro and 8279.
• BD: Output that blanks the displays.
• CLK: Used internally for timing. Max is 3 MHz.
• CN/ST: Control/strobe, connected to the control key on the keyboard.
• CS: Chip select that enables programming, reading the keyboard, etc.
• DB7-DB0: Consists of bidirectional pins that connect to data bus on micro.
• IRQ: Interrupt request, becomes 1 when a key is pressed, data is available.
• OUT A3-A0/B3-B0: Outputs that sends data to the most significant/least significant nibble of
display.
• RD(WR): Connects to micro's IORC or RD signal, reads data/status registers.
• RESET: Connects to system RESET.
• RL7-RL0: Return lines are inputs used to sense key depression in the keyboard matrix.
• Shift: Shift connects to Shift key on keyboard.
• SL3-SL0: Scan line outputs scan both the keyboard and displays.
Keyboard Interface of 8279
• The keyboard matrix can be any size from 2x2 to 8x8.

• Pins SL2-SL0 sequentially scan each column through a counting operation.


o The 74LS138 drives 0's on one line at a time.
o The 8279 scans RL pins synchronously with the scan.
o RL pins incorporate internal pull-ups, no need for
external resistor pull-ups.
ƒ Unlike the 82C55, the 8279 must be programmed first .
D7 D6 D5 Function Purpose
Selects the number of display positions,
0 0 0 Mode set
type of key scan...
Programs internal clk, sets scan and
0 0 1 Clock
debounce times.
0 1 0 Read FIFO Selects type of FIFO read and address of
Lab incharge HOD
www.prsolutions.in
Exercise No:M.1.1 Page No: 59

the read.
Selects type of display read and address of
0 1 1 Read Display
the read.
Selects type of write and the address of the
1 0 0 Write Display
write.
Display write
1 0 1 Allows half-bytes to be blanked.
inhibit
1 1 0 Clear Clears the display or FIFO
Clears the IRQ signal to the
1 1 1 End interrupt
microprocessor.
ƒ The first 3 bits of # sent to control port selects one of 8 control words.

ƒ First three bits given below select one of 8 control registers (opcode).

• 000DDMMM
o Mode set: Opcode 000.
ƒ DD sets displays mode.
ƒ MMM sets keyboard mode.

o DD field selects either:


• 8- or 16-digit display
• Whether new data are entered to the rightmost or leftmost display position.
DD Function
00 8-digit display with left entry
01 16-digit display with left entry
10 8-digit display with right entry
11 16-digit display with right entry

Keyboard Interface of 8279

MMM field:
MMM Function
ƒ
000 Encoded keyboard
ƒ with 2-key lockout
001 Decoded keyboard
ƒ with 2-key lockout
010 ƒ
Encoded keyboard with N-key rollover
011 ƒ
Decoded keyboard with N-key rollover
ƒ
100 Encoded sensor
ƒ
matrix
101 Decoded sensor
ƒ matrix
110 ƒ
Strobed keyboard, encoded display scan
111 ƒ
Strobed keyboard, decoded display scan
ƒ

ƒ Encoded: Sl outputs are active-high, follow binary bit pattern 0-7 or


0-15.
ƒ Decoded: SL outputs are active-low (only one low at any time).

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 60

ƒ Pattern output: 1110, 1101, 1011, 0111.


ƒ Strobed: An active high pulse on the CN/ST input pin strobes data
from the RL pins into an internal FIFO for reading by micro later.

o 2-key lockout/N-key rollover: Prevents 2 keys from being recognized


if pressed simultaneously/Accepts all keys pressed from 1st to last.

• 001PPPPP
o The clock command word programs the internal clock driver.
o The code PPPPP divides the clock input pin (CLK) to achieve the
desired operating frequency, e.g. 100KHz requires 01010 for a 1
MHz CLK input.

• 010Z0AAA
o The read FIFO control word selects the address (AAA) of a keystroke
from the FIFO buffer (000 to 111).
o Z selects auto-increment for the address.

• 011ZAAAA
o The display read control word selects the read address of one of the
display RAM positions for reading through the data port.

• 100ZAAAA
o Selects write address -- Z selects auto-increment so subsequent writes
go to subsequent display positions.

• 1010WWBB
o The display write inhibit control word inhibits writing to either the
leftmost 4 bits of the display (left W) or rightmost 4 bits.
o BB works similarly except that they blank (turn off) half of the output
pins.
• 1100CCFA
o The clear control word clears the display, FIFO or both
o Bit F clears FIFO and the display RAM status, and sets address
pointer to 000.
ƒ If CC are 00 or 01, all display RAM
locations become 00000000.
ƒ If CC is 10, --> 00100000, if CC is 11, -
-> 11111111.
• 1110E000
o End of Interrupt control word is issued to clear IRQ pin in sensor
matrix mode.

• 1) Clock must be programmed first. If 3.0 MHz drives CLK input, PPPPP is
programmed to 30 or 11110.
Lab incharge HOD
www.prsolutions.in
Exercise No:M.1.1 Page No: 61

• 2) Keyboard type is programmed next.


o The previous example illustrates an encoded keyboard,
external decoder used to drive matrix.

• 3) Program the FIFO.

• Once done, a procedure is needed to read data from the keyboard.


o To determine if a character has been typed, the FIFO status
register is checked.
o When this control port is addressed by the IN instruction, the
contents of the FIFO status word is copied into register AL:

• Data returned from 8279 contains raw data that need to be translated to ASCII:

o Row and column number are given the rightmost 6 bits (scan/return).

o This can be converted to ASCII using the XLAT instruction with an


ASCII code lookup table.

o The CT and SH indicate whether the control or shift keys were pressed.

The Strobed Keyboard code is just the state of the RLx bits at the time a 1 was `strobed' on the strobe
input pin.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 62

PROGRAM: KEYBOARD DISPLAY RIGHT ENTRY

cmdreg equ 0ffebh


datareg equ 0ffe9h

.8086
.model tiny
.stack 32
.data
.code

org 2000h

start:
mov ax,cs
mov ds,ax
mov al,0H ; ENCODED SCAN-8CHAR 8 BIT LEFT ENTRY
mov dx,cmdreg
out dx,al
mov al,090h ;WRITE RAM AUTO INCREMENT
out dx,al
mov cx,08

clear: mov al,00


MOV DX,datareg
out DX,al
loop clear

back: mov dx,cmdreg


in al,dx ; READ THE COMMAND R4EGISTER TO GET
; THE 8279 STATUS
and al,07 ; NUMBER OF KEYS PRESSED IS IN THE
; LOWER 3 BITS
; MASK THESE AND CHECK IF NOT ZERO. IF
; ZERO NO KEY PRESSED
jz back
mov bx,offset sscharlut
mov al,040h ; READ THE FIRST RAM ADDRESS OF FIFO
out dx,al
mov Dx,datareg
in al, dx
and al,01fh

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 63

xlat ; CONVERT THE KEY READ TO THE SS CODE


mov dx,datareg
out dx,al ; DISPLAY AT THE CURRENT DIGIT
; POSITION
jmp back

sscharlut:
SS0 DB 3FH ;0
SS1 DB 6H ;1
SS2 DB 5BH ;2
SS3 DB 4FH ;3
SS4 DB 66H ;4

SS5 DB 6DH ;5
SS6 DB 7DH ;6
SS7 DB 07H ;7
SS8 DB 7FH
SS9 DB 6FH
SSA DB 77H
SSB DB 7cH
SSC DB 39H
SSD DB 5eH
SSE DB 79H
SSF DB 71H

end start

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 64

PROGRAM: KEYBOARD DISPLAY LEFT ENTRY

cmdreg equ 0ffebh


datareg equ 0ffe9h
.8086
.model tiny
.stack 32
.data
.code
org 2000h
start:
mov ax,cs
mov ds,ax
mov al,10H ; ENCODED SCAN-8CHAR 8 BIT LEFT ENTRY
mov dx,cmdreg
out dx,al
mov al,090h ;WRITE RAM AUTO INCREMENT
out dx,al
mov cx,08
clear:
mov al,00
MOV DX,datareg
out DX,al
loop clear

back:
mov dx,cmdreg
in al,dx ; READ THE COMMAND R4EGISTER TO GET
; THE 8279 STATUS
and al,07 ; NUMBER OF KEYS PRESSED IS IN THE
; LOWER 3 BITS
; MASK THESE AND CHECK IF NOT ZERO. IF
; ZERO NO KEY PRESSED
jz back
mov bx,offset sscharlut
mov al,040h ; READ THE FIRST RAM ADDRESS OF FIFO
out dx,al
mov Dx,datareg;
in al, dx
and al,01fh
xlat ; CONVERT THE KEY READ TO THE SS CODE
mov dx,datareg
Lab incharge HOD
www.prsolutions.in
Exercise No:M.1.1 Page No: 65

out dx,al ; DISPLAY AT THE CURRENT DIGIT


; POSITION
jmp back
sscharlut:
SS0 DB 3FH ;0
SS1 DB 6H ;1
SS2 DB 5BH ;2
SS3 DB 4FH ;3
SS4 DB 66H ;4

SS5 DB 6DH ;5
SS6 DB 7DH ;6
SS7 DB 07H ;7
SS8 DB 7FH
SS9 DB 6FH
SSA DB 77H
SSB DB 7cH
SSC DB 39H
SSD DB 5eH
SSE DB 79H
SSF DB 71H

end start

EXERCISE:

1. How many puns does 8279 IC have?

2. How many scan lines are available on 8279?

3. How many row-sense pins are there on 8279?

4. How many registers are there in 8279?

5. What is the purpose of command & data registers?

6. What are the first 4 bits D7 – D4 in the command register used for?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 66

7. If 16 character 8 bit left entry LED display is to be programmed. What is the


command code?

8. What is the use of org 2000h? can the 2000h changed to another value?

9. What are the data values of ‘SSCHARLUT’ represent?

10. Explain the use of XLAT and what default registers it use?

11. Out dx,al the operand 1 is 16 bit and operand 2 is 16 bit. How does it work?

12. What is the interrupt used for inputting data from i/o port?

13. What is the states register address of 8279?

14. In 8279, if consists of lots of registers, how is it only 2 addresses are used?

15. How do you change the right entry to left entry mode is LED character display?

16. Explain the sensor mode of 8279?

17. Can the addressed RAM be automatically incremented, if so how it is done?

18. When the states register is read, the lower 32bits represents what?

19. How are the shift and ctrl keys are identified in 8279?

20. Write down the control word required for 16 characters 8bit left entry, 16 keys
N-key roll over?

21. What is the meaning N-key roll over?

22. What is 2-key lock out?

23. What is the circuit which processes the clock given to 8279 and steps it down
programmable to the required rate called?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 67

LEDS & SWITCH INTERFACE(8086)


This experimental board has been developed for the purpose of understanding the operation
of LEDS & SWITCH. This experiment makes use of programmable i/o port called programmable
peripheral interface (PPI) which is numbered as i8255 has three 8086 on the trainer kit. 8255 has
three i/o ports and they are grouped as group A & groupB. Group A contains port A & port B &
lower nibble of port C. The 8255 can be operated in three modes. Mode 0 is for simple I/O mode 1 is
for handshake i/o. Mode 2 is for bi-directional multiprocessor interfacing. The i/o ports of 8255 have
a fan in of 10 & fanout of 1 the operations of8255 are controlled by a control register which can be
programmed to set the mode & i/p o/p functions of ports. All the port pins are collectively
programmable & not individually programmable. For example 1 port A pins PA0 to PA7 have to be
all inputs or all outputs. They cannot be programmed as PA0 in & PA0 out individually as 2 four bit
ports which can be programmed as a group for i/p of o/p. PC0 to PC3 which are the lower nibble of
port C can be programmed as input or output while upper nibble of port C PC4 to PC7 can be
programmed as input or output.

The control word format is as follows.

D7 D6 D5 D4 D3 D2 D1 D0

Active/BSR Group A PA PCH GroupB PB PCL


Mode i/p of o/p Mode

D7- When set it is in the action operation where the i/o s can be programmed. If D7 is clear it is in bit
set reset mode. Which is used to set reset port C bits. This mode is not of great significance in the use
of 8255. D7 is one as 8255 is used in the active mode.
D6,D5 are the bits used far setting the mode of group A ports.

00 Mode 0
01 Mode 1
10 Mode 2
11 Mode 3

D4 sets the port A as input or output depending upon whether it is 1 or 0 respectively.


D3 sets the port C higher as input or output depending upon whether it is 1 of 0 respectively.
D2 this bit is for setting the mode of group B which has only 2 modes mode0 and mode1.
D1 sets the port B as i/p or o/p depending upon whether it is 1 or 0 respectively.
D0 sets the port C lower as i/p or o/p depending upon whether it is 1 or 0 respectively.

To program 8255 for lighting the LED lamps it is important for us to know the LED
specifications.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 68

Green Red

Forward voltage drop 1.9V 1.8V


Typical operating current 5ma 5ma
Max current 15ma 15ma
Dimensions 5mm φ 5mm φ

For further details refer website http:\\ crsarma.tripod.com.

A current of 10ma was passed through lamp for lighting. The output voltage, used to drive it
was form a TTL port. So the balance of voltage 3.4V has to be dropped across this resistor while
passing 10ma of current therefore resistor value is
5V-1.6V = 340 Ω is not available in the standard range of resistors.
10ma
So in the standard range which ever is close to 340 Ω is chosen. Port A was connected to four RED
& four GREEN LEDs arranged alternately.

SWITCHES

Port C was programmed for2 ports of nibble each. So the upper nibble (PCH
PC4….PC7) could be used for i/p or o/p subsequently. An i/p port papers in a tri-stated condition
which results in a floating voltage. So inputs have to be given a pull-up resistor which makes at
logic 1 level. A toggle switch is then connected to port pin with its other end connected to ground. If
the toggle switches open, the particular bit is at logic 1 otherwise logic 0. The switches are connected
to PC0 & PC1.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 69

PROGRAM: 8255(LED’S USING SWITCHES)

.8086
.model tiny
.stack 16
.code
org 2000h

start: mov ax,cs


mov ds,ax

mov dx,0ffe7h
mov al,81h
out dx,al
h1: mov dx,0ffe5h
in al,dx
test al,03
jnz nxt1
call alternet
jmp h1
nxt1: test al,01
jnz nxt2
call r2l
jmp h1
nxt2: test al,02
jnz h1
call l2r
jmp h1

alternet proc
mov dx,0ffe1h
BACK: mov al,0aah
out dx,al
call delay
mov al,055h
out dx,al
call delay
ret
alternet endp

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 70

l2r proc
mov cx,8
mov al,01h
mov dx,0ffe1h
BACK2: out dx,al
call delay
rol al,01h
loop back2
ret
l2r endp

delay proc
push cx
mov cx,0ffffh

s1: loop s1
pop cx
ret
delay endp

r2l proc
mov cx,8
mov al,80h
MOV DX,0FFE1H
BACK3: out dx,al
call delay
ror al,01h
loop back3
ret
r2l endp
end start

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 71

LED’S USING SWITCHES

Exercise:

1. What is the control word format for 8255?

2. How is the choice of resistor connected to the led made?

3. What is the forward drop of green leds?

4. What is the forward drop of red leds?

5. What is the current drown by LED’s(8)?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 72

MCS 51 DEVELOPMENT TOOLS


Using Command Line

1. Edit the program using ‘EDIT’ editor


2. Save as name .A51
3. Assemble using A51.EXE
C: A51 name .A51
Result: name .LST, name .OBJ
4. LINK & Convert to Hex format using OH51.EXE
C: OH51 name .OBJ
Result: name .HEX
5. Simulate Using SIM31.EXE

C: SIM31

Using Integrated Design Environment (IDE)


KEIL µVision – (Windows)
An Integrated design environment consists of all the tools needed for the development of
software for the MCS 51 family. These tools are linked together in one environment. The main
feature of IDE is the BUILD process. The BUILD ensures that the target file is current. In order
to keep modular development the PROJECT feature is provided.

1. Select START\PROGRAMS\KEIL <Left Click>


2. Create New project
Select PROJECT\NEW\<Left Click> “enter name’<Left Click>
Choose TARGET\INTEL\8051 <Left Click>
Choose BUILD OPTIONS
Check Box HEX <OK><Left Click>
3. Create File <ALT><F><N> ‘name of file .ASM’ <Left Click>
Edit File & Save
4. SELECT PROJECT WINDOW – ADD FILE – SELECT - <Left Click>
5. PROJECT\BUILD\ <Left Click>
If no errors goto 7 else 3
DEBUG\START\ <Left Click>

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 73

LEDS & SWITCH INTERFACE(8051)


This experimental board has been developed for the purpose of understanding the operation
of LEDS & SWITCH. This experiment makes use of programmable i/o port called programmable
peripheral interface (PPI) which is numbered as i8255 has three 8086 on the trainer kit. 8255 has
three i/o ports and they are grouped as group A & groupB. Group A contains port A & port B &
lower nibble of port C. The 8255 can be operated in three modes. Mode 0 is for simple I/O mode 1 is
for handshake i/o. Mode 2 is for bi-directional multiprocessor interfacing. The i/o ports of 8255 have
a fan in of 10 & fanout of 1 the operations of8255 are controlled by a control register which can be
programmed to set the mode & i/p o/p functions of ports. All the port pins are collectively
programmable & not individually programmable. For example 1 port A pins PA0 to PA7 have to be
all inputs or all outputs. They cannot be programmed as PA0 in & PA0 out individually as 2 four bit
ports which can be programmed as a group for i/p of o/p. PC0 to PC3 which are the lower nibble of
port C can be programmed as input or output while upper nibble of port C PC4 to PC7 can be
programmed as input or output.

The control word format is as follows.

D7 D6 D5 D4 D3 D2 D1 D0

Active/BSR Group A PA PCH GroupB PB PCL


Mode i/p of o/p Mode

D7- When set it is in the action operation where the i/o s can be programmed. If D7 is clear it is in bit
set reset mode. Which is used to set reset port C bits. This mode is not of great significance in the use
of 8255. D7 is one as 8255 is used in the active mode.
D6,D5 are the bits used far setting the mode of group A ports.

02 Mode 0
03 Mode 1
12 Mode 2
13 Mode 3

D4 sets the port A as input or output depending upon whether it is 1 or 0 respectively.


D3 sets the port C higher as input or output depending upon whether it is 1 of 0 respectively.
D2 this bit is for setting the mode of group B which has only 2 modes mode0 and mode1.
D1 sets the port B as i/p or o/p depending upon whether it is 1 or 0 respectively.
D0 sets the port C lower as i/p or o/p depending upon whether it is 1 or 0 respectively.

To program 8255 for lighting the LED lamps it is important for us to know the LED
specifications.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 74

Green Red

Forward voltage drop 1.9V 1.8V


Typical operating current 5ma 5ma
Max current 15ma 15ma
Dimensions 5mm φ 5mm φ

For further details refer website http:\\ crsarma.tripod.com.

A current of 10ma was passed through lamp for lighting. The output voltage, used to drive it
was form a TTL port. So the balance of voltage 3.4V has to be dropped across this resistor while
passing 10ma of current therefore resistor value is
5V-1.6V = 340 Ω is not available in the standard range of resistors.
10ma
So in the standard range which ever is close to 340 Ω is chosen. Port A was connected to four RED
& four GREEN LEDs arranged alternately.

SWITCHES

Port C was programmed for2 ports of nibble each. So the upper nibble (PCH PC4….PC7)
could be used for i/p or o/p subsequently. An i/p port papers in a tri-stated condition which results
in a floating voltage. So inputs have to be given a pull-up resistor which makes at logic 1 level. A
toggle switch is then connected to port pin with its other end connected to ground. If the toggle
switches open, the particular bit is at logic 1 otherwise logic 0. The switches are connected to PC0 &
PC1.

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 75

LED ROTATE RIGHT AND ROTATE LEFT PROGRAM


PORTA EQU 2808H
PB EQU 2809H
PORTC EQU 280AH
PCW EQU 280BH
DELAY EQU 0114H
FIRST EQU 170
SECOND EQU 85

ORG 6500H

MOV DPTR,#PCW ; DPTR HOLDS THE CONTROL REGISTER ADDRESS


MOV A,#080H
MOVX @DPTR,A
RIGHTLED: MOV A,#01
MOV DPTR,#PORTA
RIGHTLED1: MOVX @DPTR,A
MOV R2,#0FFH
MOV R1,#0FFH
LCALL DELAY
RR A
JMP RIGHTLED1
LEFTLED: MOV A,#01
MOV DPTR,#PORTA
LEFTLED1: MOVX @DPTR,A
MOV R2,#0FFH
MOV R1,#0FFH
LCALL DELAY
RL A
JMP LEFTLED1
AGAIN: MOV DPTR,#PORTA
MOV A,#FIRST
MOVX @DPTR,A
MOV R2,#0FFH
MOV R1,#0FFH
LCALL DELAY
MOV A,#SECOND
MOVX @DPTR,A
MOV R2,#0FFH
MOV R1,#0FFH
LCALL DELAY
JMP AGAIN
END

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 76

LED’S AND SWITCH INTERFACE

Exercise:

1. What is the control word format for 8255?

2. How is the choice of resistor connected to the led made?

3. What is the forward drop of green LED’s?

4. What is the forward drop of red LED’s?

5. What is the current drown by LED’s(8)?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 77

PROGRAM: Transferring a block of data from internal


ROM to internal RAM

org 0000h
ljmp start
org 000bh
reti
org 0013h
reti
org 001bh
reti
org 0023h
reti
org 0023h
reti
org 0026h
reti
org 200h
start: mov dptr,#message
mov r0,#20h
mov r7,#11
rep: mov a,#00h
movc a,@a+dptr
mov @r0,a
inc r0
inc dptr
djnz r7,rep

message: db "hello world"


end

Exercise:

1. What are the two registers in 8051, which are used for indirect addressing?

2. What are the 16 bit registers available in 8051?

3. Which register cannot be decremented?

4. 8051 is a ------- bit microcontroller?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 78

PROGRAM: (a). Internal ROM to external RAM

ORG 0000H

START: mov a,#00


mov sp,#07h
mov r3,#11
mov dptr,#200h
push dpl
push dph
rep: mov dptr,#message
mov r2,a
movc a,@a+dptr
pop dph
pop dpl
movx @dptr,a
inc dptr
push dpl
push dph
inc r2
mov a,r2
djnz r3,rep
message: db "hello word"
end

Exercise:

1. What does “djnz” instruction do?

2. What is DPTR relative addressing?

3. How many 8 bit registers are available in 8051?

4. What is the purpose of R2?

5. What is the purpose of R3?

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 79

PROGRAM: b). Internal ROM to external RAM

org 200h

start: mov r0,#40h


mov a,#30h
mov r6,#10

rep: mov @r0,a


inc a
inc r0
djnz r6,rep
mov r1,#40h
mov dptr,#400h
mov r7,#00h

rep1: mov a,@r0


movx @dptr,a
inc dptr
inc r1
inc r7
cjne r7,#10,rep1

end

Exercise:

6. What is DPTR relative addressing?

7. What is the purpose of R7?

8. What is the purpose of R0?

9. What does “cjne” instruction do?

6. The stack pointer of 8051 grows upwards or downwards

Lab incharge HOD


www.prsolutions.in
Exercise No:M.1.1 Page No: 80

PROGRAM: Understanding three memory areas of 00-FF

ORG 0000H
ljmp start

org 200h

start: mov a,#41h


mov 20h,a
mov a,#42h
mov r0,#20h
mov @r0,a
mov a,#43h
mov 80h,a
mov a,#44h
mov r0,#80h
mov @r0,a

end

Exercise:

1. What is the instruction used for loading accumulator from code memory?

2. What is the purpose of register R0?

3. What are the two registers in 8051 which are used for indirect addressing?

Lab incharge HOD

Das könnte Ihnen auch gefallen