LAB1
LAB1
LAB1
LAB # 01
LAB Name: introduction to 8086 trainer MDA Win8086
1.1 Objective:
To become familiar with the 8086 trainer MDA Win8086 trainer
1.2 Introduction:
MDA-8086 has high performance 64K-byte monitor program. It is designed for easy function.
After power is on, the monitor begins to work. In addition to all the key function the monitor
has a memory checking routine.
The following is a simple description of the key functions.
Figure: 1.1
Figure: 1.2
1
21395
Microcontroller and Microprocessor
2
21395
Microcontroller and Microprocessor
1.6 MDA-8086:
Figure: 1.3
3
21395
Microcontroller and Microprocessor
4
21395
Microcontroller and Microprocessor
1-introduction to 8086
Problem Number trainer
2-description of all parts
Working
Lab Performance
Viva
Instructor's Verification
5
21395
Microcontroller and Microprocessor
LAB#2
2.1 Objective:
To learn the basic machine codes or opcodes of Intel 8086
2.2 Pre-Lab Reading:
Intel Microprocessors: Architecture, Programming and Interfacing, 8th Edition, BARRY B.
BREY, Chapter 4, Topic 4.1
2.3 Equipment:
Instruments MDA-Win 8086 Trainer
Kit
2.4 Code:
2.4.1: Mov A, #80H
2.4.2: Push AX
2.4.3: POP BX
2.4.4: PUSHF
2.4.5: POPF
2.4.6: ADD AH, 5
2.4.7: INC BH
2.4.8: JO
2.4.9: NEG
2.4.10: SUB BL, AH
2.6 Output:
2.5.1: A=80H
2.5.2: AX=55H and Top of stack=55H
6
21395
Microcontroller and Microprocessor
7
21395
Microcontroller and Microprocessor
2.8 Notes:
When two operands are required for an instruction they are separated by comma. For
example:
REG, memory
AL, DL
DX, AX
Mov BX,AX
Mov BX,[BI+SI]
Working
Lab Performance
Viva
Instructor's Verification
8
21395
Microcontroller and Microprocessor
LAB#3
Lab – 3: Arithmetic Blocks
3.1 Objective:
To learn the basic Arithmetic Operations ( Addition, Subtraction, Multiplication and
Division)
3.2 Pre-Lab Reading:
Intel Microprocessors: Architecture, Programming and Interfacing, 8th Edition, BARRY B.
BREY, Chapter 5, Topic 5.1, 5.2
3.3 Equipment:
Instruments MDA-Win 8086 Trainer
Kit
3.4 Code:
3.4.1 Addition:
Algorithm: Operend1 = Operend1 + Operend2
Example:
MOV AL, 5
ADD AL, -3
RET
3.4.2 Subtraction:
Algorithm: Operend1 = Operend1 - Operend2
Example:
MOV AL, 5
ADD AL, 1
RET
3.4.3 Multiplication:
Algorithm: AX = AL * operand or DX AX = AX * operand
9
21395
Microcontroller and Microprocessor
Example:
MOV AL, 301
MOV BL, 6
MUL BL
RET
3.4.4 Division:
Algorithm: AL = AX / operand, AH = reminder or AX= (DX AX) / operand,
DX=reminder
Example:
MOV AL, 100
MOV BL, 3
DIV BL
RET
3.5 Output:
3.5.1: AL = 05H
AL = 02H
3.5.2: AL = 05H
AL = 04H
3.5.3: AL = 00C8H
BL = 04H
AX = 0320H (800)
3.5.4: AX = 00CBH
BL = 04H
AL= 50 (32h), AH = 3
3.7 Exercise:
10
21395
Microcontroller and Microprocessor
3.7.1 Addition:
Addition can be performed in the following way:
REG, Memory
Memory, REG
REG, REG
Memory, Immediate
REG, Immediate
3.7.2 Subtraction:
Subtraction can be performed in the following way
REG, Memory
Memory, REG
REG, REG
Memory, Immediate
REG, Immediate
3.7.3 Multiplication:
Multiplication can be performed in the following way
REG
Memory
3.7.4 Division:
Division can be performed in the following way
REG
Memory
2.8 Notes:
11
21395
Microcontroller and Microprocessor
When two operands are required for an instruction they are separated by comma. For
example:
REG, memory
AL, DL
DX, AX
Working
Lab Performance
Viva
Instructor's Verification
12
21395
Microcontroller and Microprocessor
LAB#4
LAB NAME: ADRESSING MODES
4.1 OBJECTIVE
To study and examine the NASM and addressing modes
Figure: 4.1
13
21395
Microcontroller and Microprocessor
Figure: 4.2
Figure: 4.3
14
21395
Microcontroller and Microprocessor
Figure: 4.4
Figure: 4.5
15
21395
Microcontroller and Microprocessor
IN DIRECT ADDRESING
Figure: 4.6
Figure: 4.7
16
21395
Microcontroller and Microprocessor
Figure: 4.8
Figure: 4.9
17
21395
Microcontroller and Microprocessor
Figure:4.10
4.7 Procedure
To work in NASM ,we should have following software which is easily download by
google
We must have cmd prompt, afd debugger,NASM and linker
Write the code in notepad and save it by .asm extension
Open the cmd prompt
Write the command as describe above in cmd
To load file write saved file name i-e u1.asm
And load object file and listing file by extention as .com and .lst respectively
Now to view listing file write edit u1.lst the listing file window will open which shows the
program list and steps
18
21395
Microcontroller and Microprocessor
Examine carefully so if any error occur then you can easily change it
Then to view object file write afd u1.com
By executing .com afd debugger will open which show the brief explanation
By executing each command the register status changing correspondingly
Also observe the IP status which is loading automatically
There are two memory windows in afd ,both showing the same value of register
Value can also be change in this window on typing in cmd line area.
4.8 NOTES:
Save the notepad file by .asm extention and then retrieve it in cmd by same extention
1-adressing modes
Problem Number
2-examine NASM
Working
Lab Performance
Viva
Instructor's Verification
19
21395
Microcontroller and Microprocessor
LAB#5
Lab NAME: Introduction to 8051 Microcontroller
5.1 OBJECTIVE :
To examine and use 8051 microcontroller, assembler and simulator
To learn “in system programming” (ISP) of microcontroller
5.2 PRE-LAB READING:
Chapter 1, 2, 8, Mazidi and McKinlay, “The 8051 Microcontroller and Embedded Systems”
5.3 EQUIPMENT REQUIRED
Instruments Oscilloscope
8051 ETK Trainer
Components Resistor 8.2k, 10k
Capacitors 10 uF, 30 uF, 30 uF
ICs 89C51RD2
20
21395
Microcontroller and Microprocessor
Figure: 5.1
21
21395
Microcontroller and Microprocessor
Do not at any point draw more than 26mA from the microcontroller.
5.7 ACTIVITIES AND EXERCISES
1. This task is designed to get you familiar with ASEM-51 assembler. Write a simple assembly language
code in which you move a value in register A. Then from register A, move this value to registers R0-R7.
Save this file as .asm and generate .hex file and simulate it. Write the code in following space. A
microcontroller simulator helps in viewing the inside of a microcontroller. Hex file of code is loaded in
the simulator which shows the code in ‘disassembled code window’. Values of different registers and data
in RAM is also shown and updated at each step of the code.
ORG 00H
Mov A, #0BH
MOV R0, A
MOV R2, A
MOV R3, A
MOV R4, A
MOV R5, A
MOV R6, A
MOV R7, A
END
2. Write an assembly language code in which a value is moved in register A. Then from register A, 06H is
added to this value and moved to register R0. Keep adding 06H and move the data from R1 to R7
registers. Now load the hex file of this code in the simulator and use the simulator to single step the
program. Examine and write down the values of registers (PC, ACC, and R0-R9) on each step and show
to your instructor.
ORG 00H
Mov A, #10H
ADD A, #06H
Mov R0, A
ADD A, #06H
Mov R1, A
ADD A, #06H
Mov R2, A
ADD A, #06H
22
21395
Microcontroller and Microprocessor
Mov R3, A
ADD A, #06H
Mov R4, A
ADD A, #06H
Mov R5, A
ADD A, #06H
Mov R6, A
ADD A, #06H
Mov R7, A
END
5.8 Assessment sheet:
CMS ID: 21395
DATE: 04-05-2015
1-introduction to 8051
Problem Number
2-description
Working
Lab Performance
Viva
Instructor's Verification
23
21395
Microcontroller and Microprocessor
Lab#06
Lab name: Led blinking by using 8051
6.1 Lab 0bjective:
To become familiar how to blink led in 8051 using assembly
6.2 Pre lab reading:
Book: the 8051 microcontroller and embedded systems, edition second, Author Muhammad Ali
mazidi, chapter 03, and topic: simple led blinking program
6.3 Equipment:
Proteus 8, power supply
6.4 components:
8051 microcontroller, led, wires,
6.5 circuit:
Figure: 6.1
6.6 code:
Org 00H
main:
here: setb p1.0
24
21395
Microcontroller and Microprocessor
CPL p1.0
SJMP here
End
6.7 Output:
Figure: 6.2
6.8 Exercise/procedure:
Open the software proteus 8 and go for the new project select the default schematic. Now select
the controller and write the code and check the errors if any then remove it. Select all the
components from library and connect all the components. Once the simulation is done then run it
and see the output.
6.9 Notes:
Here we will observe the led it will blink continuously
25
21395
Microcontroller and Microprocessor
1-led blinking
Problem Number
2-using 8051
Working
Lab Performance
Viva
Instructor's Verification
26
21395
Microcontroller and Microprocessor
Lab#07
LAB NAME: Led blinking by using delay.
7.1 Lab 0bjective:
To become familiar how to blink led in 8051 using delay
7.2 Pre lab reading:
Book: the 8051 microcontroller and embedded systems, Edition second, Author Muhammad Ali
mazidi, chapter 03, and topic: delay program
7.3 Equipment:
Proteus 8, power supply
7.4 Components
: 8051 microcontroller, led, wires,
7.5 Circuit:
Figure:7.1
7.6 Code:
ORG 00H
main:
here: SETB P1.0
27
21395
Microcontroller and Microprocessor
ACALL DELAY
CPL P1.0
ACALL DELAY
SJMP here
ORG 300H
DELAY: MOV R0, 0FFH
DJNZ R0, $
RET
End
7.7 Output:
Figure:7.2
7.8 Exercise/procedure:
Open proteus 8 select the new project and select default schematic. Select the controller and
write a program by using a call delay in assembly. Now check the errors if any then remove it
28
21395
Microcontroller and Microprocessor
and compile it. Select the component from library and connect all the components and run the
simulation see the result led will continuously blink with some delay
7.9 Notes:
Led will blink with some time delay
Working
Lab Performance
Viva
Instructor's Verification
29
21395
Microcontroller and Microprocessor
Lab#08
LAB NAME: Programming in Mode (0, 1, 2)
8.1 Lab 0bjective:
To become familiar how to use modes in assembly language
8.2 Pre lab reading:
Book: the 8051 microcontroller and embedded systems, edition second, Author Muhammad Ali
mazidi, chapter 09, and topic: delay program
8.3 Equipment:
Proteus 8, power supply
8.4 Components:
8051 microcontroller, led, wires,
8.5 Circuit:
Figure:8.1
8.6 Code:
FOR TIMER0 MOD0
ORG 00H
MAIN:
MOV TMOD, 00H
30
21395
Microcontroller and Microprocessor
31
21395
Microcontroller and Microprocessor
SETB TR0
JNB TF0, $
CLR TF0
SJMP HERE
End
8.7 Output:
Figure:8.2
8.8 Exercise/procedure:
Open the software for the simulation. Go for the new project and select the controller. Now write
the program for timer in assembly. 8051 has two timer (timer0.timer) but here we used timer0 for
our simulation. After completing the code and circuit now check the errors if any then fix it and
run it
Mod0 is of 13-bit and mod1 is of 16-bit and the mod2 is 8-bit auto reload.
Select the components from library and drag it on the screen and connect them together
Code the timer0 for mod0 run the simulation and observe the result. Repeat the procedure for
mod1 and mod2.
8.9 Notes:
8051 has two timers which are used for the timer and a counter. .
32
21395
Microcontroller and Microprocessor
1-programming mode
Problem Number 2-using timers for mode
0,1,2
Working
Lab Performance
Viva
Instructor's Verification
33
21395
Microcontroller and Microprocessor
Lab#09
LAB NAME: Counters In 8051
9.1 Lab 0bjective: To become familiar with counters how they are used in 8051
9.2 Pre lab reading:
Book: the 8051 microcontroller and embedded systems, edition second, author Muhammad Ali
mazidi, chapter 09, and topic: delay program
9.3 Equipment:
Proteus 8, power supply
9.4 Components:
8051 microcontroller, led, wires,
9.5 Circuit:
Figure:9.1
9.6 Code:
ORG 00H
main:
MOV TMOD, #60H
MOV TH1,#0H
SETB P3.5
AGAIN: SETB TR1
34
21395
Microcontroller and Microprocessor
9.7 Output:
Figure:9.2
9.8 Exercise/procedure:
Open the software for the simulation. Go for the new project and select the controller. Now write
the program for timer in assembly. 8051 has two timer (timer0.timer) but here we used timer0 for
our simulation. But here we have used counter instead of timer. Counter0 is used for the counter
operation. After completing the code and circuit now check the errors if any then fix it and run it
Mod0 is of 13-bit and mod1 is of 16-bit and the mod2 is 8-bit auto reload.
Code the counter0 for mod0 run the simulation and observe the result. Repeat the procedure for
mod1 and mod2.
9.9 Notes:
We can use timers 0 and 1 as event counters. A timer can be used as a counter if we provide
pulses from outside the chip instead of using the frequency of the crystal oscillator as the clock
35
21395
Microcontroller and Microprocessor
source. By feeding pulses to the TO (P3.4) and Tl (P3.5) pins, we turn Timer 0 and Timer 1 into
counter 0 and counter 1.
1-counters in 8051
Problem Number 2-using counter for event
count
Working
Lab Performance
Viva
Instructor's Verification
36
21395
Microcontroller and Microprocessor
Lab#10
Lab name: Serial port program receiver & transmitter
10.1 Lab 0bjective:
To learn microcontroller serial programing for receiving and sending data
10.2 Pre lab reading:
The 8051 Microcontroller and Embedded Systems
Edition: 2nd edition
Author: mazidi
Chapter 11
10.3 Equipment:
Pc, 8051 trainer, serial cable
10.4 Component:
Bread board, 8051 microcontroller, resister, connecting wires, computer, genius programmer,
usb cable, led, and oscillator
10.5 Circuit:
Figure :10.1
37
21395
Microcontroller and Microprocessor
10.6 Code:
ORG 00H
MAIN:
MOV TMOD, #20H
MOV SCON, #50H
MOV TH1, #-3D
SETB TR1
LOOP:
MOV A, #'D'
MOV SBUF, A
ACALL TRANSMIT
MOV A, #'D'
MOV SBUF, A
MOV A, #'A'
MOV SBUF, A
ACALL TRANSMIT
MOV A, #'N'
MOV SBUF, A
ACALL TRANSMIT
MOV A, #'I'
MOV SBUF, A
ACALL TRANSMIT
SJMP $
TRANSMIT:
38
21395
Microcontroller and Microprocessor
JNB TI, $
CLR TI
RET
END
10.7 Output:
Figure: 10.2
39
21395
Microcontroller and Microprocessor
10.9 Circuit:
Figure: 10.3
10.10 Code:
ORG 00H
MAIN:
MOV TMOD, #20H
MOV SCON, #50H
MOV TH1, #-3D
SETB TR1
MOV P2, #00H
LOOP:
JNB RI, $
CLR RI
MOV A, SBUF
MOV P2, A
SJMP LOOP
40
21395
Microcontroller and Microprocessor
END
10.12 Notes:
We have transmitted and received data serially and learnt the serial port programming
Working
Lab Performance
Viva
Instructor's Verification
41
21395
Microcontroller and Microprocessor
42
21395