Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
LIST OF PROGRAMMS
Name of the Lab : MICROPROCESSORS AND INTERFACING LAB
Class
Regulation
: R 07
EXPERIMENT NO. 1
INTRODUCTION MASM / TASM
INTRODUCTION TO MASM/TASM
Assembler:
An assembler program is used to translate the assembly language
mnemonics for instruction to corresponding binary codes called Object
code, when you run the assembler, it reads the source file of your
program called Assembly Program. Where saved it after editing on the
first pass through the same program the assembler determines offset of
labels and pairs this information in a symbol table, on the second pass
through the source program, the assembler produce the binary code for
each instruction and inserts the offset etc., that is calculated during the
first pass. The assembler generates one file. The file is called Object file,
is given the extension .obj. The object file contains the binary codes for
the instruction and information about the address of the instructions. The
model of assembler is sown in the below figure.
Assembler Directives
An assembler is used to convert the assembly language to machine
code language and to find out some syntax errors. The logical errors and
proportional errors are not found out by the assembler. For completing all
these tasks, the programmer should give some hints in the program to
assembler, in clearly understanding the program.
Assembler directives are predefined Alphabetical strings which give
hints to assembler, to clearly understand the program in preparing the
code well.
They are also called as pseudo instructions during assembling
operation, no machine codes are generated for assembler directives.
VERSION OF ASSEMBLER: Microsoft Macro Assembler6.11
1 .586
Model Type
Tiny
Small
Medium
Large
Description
All data & codes must be fit in to one segment 64kB
One data segment 64kB & one code segment 64kB
One data segment 64kB & more than one code segment
More than one data segment & more than one code
segment
Only available to 6.11 version. It uses one segment of
512kB to store data & codes
Flat
3 .data
9 End
10 Proc
11 Endp
12 Endm
Procedure:
Dept. of Electronics & Communication Engineering
20 .code
21 End
22 Proc
23 Endp
24 Macro
25 Endm
Procedure:
Step1: Switch on the system.
Step2: Go to START button.
Step3: Go to RUN & press ENTER.
Step4: Type CMD & press ENTER. This will open command prompt.
Step5: Type command cd masm\pentium\<your directory>
Step6: Open the new file with .ASM extension.
Step7: Write the program, save it.
Step8: Copy few batch files using copy c:\masm\pentium\*.bat.
Then three batch files get copied.
Step9: Execute the written program using following commands
C:\masm\pentium\>ml <file name>
C:\masm\pentium\>wl32 <file name>
C:\masm\pentium\>cwd <file name>
Step10: The above command will open a debugger window, press F8
keys to execute the program in steps.
Repeat the same procedure for every program, except coping of Batch
files is done for once.
EXPERIMENT NO. 2
ARITHMETIC OPERATIONS
BX=2222
O/P: ES:DI
0000:3000 77}
0000:3001 77 } Add(AX)
0000:3002 33}
Dept. of Electronics & Communication Engineering
0000:3003
0000:3004
0000:3005
0000:3006
0000:3007
33} Sub(AX)
4A}
9F} AX
60}
0B } DX MUL(AX,DX)
0000:3008 02}
0000:3009 00} AX Quotient}
0000:300A 11}
0000:300B 11} DX Reminder } DIV
Flow chart:
Start
Get the first number
Get the second number
ADD the two numbers
Carry=0
Is
carry
flag
set
Carry=1
Stop
BX=5678
O/P: SW 5000
0000:5000 -35E5
0000:5002 -2520
2. System-1
3. RS 232 Serial cable.
4.+5v Supply
5.86/88e Driver Software.
Program:-
L1:
L2:
L3:
XOR AX,AX
MOV CL,06
DEC CL
MOV DL,CL
MOV SI,5000
MOV CL,DL
MOV AL,[SI]
CMP AL,[SI]01
JL L3
XCHG AL,[SI]01
MOV [SI],AL
INC SI
LOOP L2
DEC DL
JNZ L1
INT 03
I/P: 0000:5000-7E
01-34
02-4B
03-2F
04-5C
05-1D
Result: O/p:
0000:5000-1D
5001-2F
5002-34
5003-4B
5004-5C
5005-7E
AX=001D
FL= F046
start
yes
Larg
er
Is it
0
yes
Sto
p[
SWA
P
Flag(
1)
DESCENDING ORDER.
L1:
L2:
L3:
XOR AX,AX
MOV CL,06
DEC CL
MOV DL,CL
MOV SI,5000
MOV CL,DL
MOV AL,[SI]
CMP AL,[SI]01
JG L3
XCHG AL,[SI]01
MOV [SI],AL
INC SI
LOOP L2
DEC DL
JNZ L1
INT 03
Result: O/p:
0000:5000-7E
5001-5C
5002-4B
5003-34
5004-2F
5005-1D
AX=007E
FL= F047
4) WRITE 8086 ALP TO PICK THE MEDIAN FROM THE GIVEN ARRAY
OF NUMBERS
MOV AL,[SI]
RET
I/P: 0000:3000-02
01-01
02-05
03-04
04-03
05-08
06-07
07-06
O/P : (EVEN OUTPUT) 0000:3000-01
01-02
02-03
03-04
04-05
05-06
06-07
07-08
BL=08
AX= 0104
FL=F097
CF=1
XOR AX,AX
XOR BX,BX
XOR CX,CX
MOV DS,AX
MOV SI,3000
L1: MOV AL,[SI]
CMP AL,00
JE L
INC BX
INC SI
JMP L1
INT 03
I/P: 0000:3000-01
01-02
02-03
03-04
04-05
05-06
06-07
07-00
O/P: BX=0007
FL=F046
CF=0(No carry)
XOR AX,AX
XOR BX,BX
XOR CX,CX
XOR DX,DX
MOV SI,3000
MOV DI,4000
MOV DS,AX
MOV ES,AX
L: MOV AL,[SI]
MOV [DI],AL
INC SI
DEC DI
LOOP L
MOV DI,4000
MOV SI,3000
MOV CX,08
REP
CMPSB
INT 03
I/P: 0000:3000-01
01-02
02-03
03-04
04-05
05-06
06-07
07-00
O/P: 0000:4000-00
FL=F046
ZF=1 (Given string is
PALINDROME STRING)
02-02
03-03
CF=0 (No carry)
PF =1(Even no.of 1s)
04-03
05-02
06-01
07-00
star
t
Get string address
Get the string length
Get the string last char address
Get CHAR
Display
Decrement address
Decrement length
Is
it
zer
o
stop
03-12
04-A1
I/P 3:2000:1100-56(V)
01-41(A)
02-4C(L)
03-49(I)
04-44(D)
05-03
I/P 4:2000:1200-49(I)
01-4E(N)
02-56(V)
03-41(A)
04-4C(L)
05-49(I)
06-44(D)
07-03
O/P: WAIT
VALID
COMMAND.
LEA DI,STRING
MOV CX,LEN
MOV AL,CHAR
CLD
REPNE SCASB
JNZ EXIT
MOV SI,DI
DEC DI
REP MOVSB
EXIT:MOVBYTE PTR[DI], $
LEA DX,STRING
MOV AH,09
INT 21H
INT 03
star
t
Get string address
Get the string length
Clear DF
Scan the string
Char
found
zero
stop
2. System-1
3. seven segment kit.
4.bus
5.serial cable
Program:-
LOOP4:
LOOP3:
LOOP2:
LOOP1:
DELAY:
MOVW AX,0000
MOVW CX,AX
MOVW DX,AX
MOVW DX,0FFE6
MOVB AL,80
OUTB DX,AL
MOVW SI,2100
MOVB CL,05
MOVB CH,04
MOVB BL,08
MOVB AL,[SI]
INCW SI
ROLB AL,01
MOVW DX,0FFE2
OUTB DX,AL
MOVB AH,AL
MOVB AL,01
MOVW DX,0FFE4
OUTB DX,AL
DECB AL
OUTB DX,AL
MOVB AL,AH
DECB BL
JNZ LOOP1
DECB CH
JNZ LOOP2
CALL DELAY
DECB CL
JNZ LOOP3
JNZ LOOP4
PUSH CX
MOVW CX,0FFFF
LOOP $
MOVW CX,0FFFF
LOOP $
POP CX
RET
ORG 2100
DB 0FF,0FF, 0FF, 0FF
DB 0C6,086,0C7,086
DB 0BF,0C0,0DE,087
DB 0BF,092,091,092
Dept. of Electronics & Communication Engineering
DB 092,0C8,086,087
L1:
DELAY:
L2:
MOVB AL,80
OUTB AL,DX
MOVB DX,0FFE0
MOVB AL,88
OUTB AL,DX
CALL DELAY
XCHGW AX, AX
XCHGW AX, AX
RORB AL,01
JMP L1
INT 03
MOVW AX,0000
LOOP L2
RET
CALLA 0FB00:0031
MOV DX,0FFE6
MOV AL,82
OUT DX,AL
JMP 4026
OR 4944
INC DI
DEC CX
PUSH SP
INC CX
DEC SP
AND [BP]41,DL
DEC SP
PUSH BP
INC BP
AND [DI],BH
AND [BX][SI],AL
CALLS FB00:0135
CS
LEA DX,@2015
MOV AX,DX
CALL FB00:0013
MOV AL,02
MOV DX,0FFE0
OUT AL,DX
XCHG AX,AX
XCHG AX,AX
XCHG AX,AX
XCHG AX,AX
XCHG AX,AX
MOV AX,0001
OUT AL,DX
MOV CX,1000
LOOP 4049
MOV AL,04
OUT AL,DX
MOV DX,OFFE2
IN AL,DX
AND AL,01
JE 405F
INC BL
JMP 4053
MOV AL,BL
CALLS FB00:0052
MOV AL,02
MOV DX,OFFE0
OUT AL,DX
MOV BX,0003
MOV CX,FFFF
Dept. of Electronics & Communication Engineering
LOOP 4072
DEC BX
JNE 406F
JMP 4079
ANDB[BX][SI],AL
PUSH ES
AIM: To generate a ramp wave form by interfacing 8255 PPI with 8086 microprocessor.
APPARATUS:
1.
2.
3.
4.
5.
PROGRAM CODE:
MOV AL,80
MOV DX,8807
OUT DX,AL
Repeat
MOV AL,00
MOV DX,8801
Next
OUT DX,AL
INC AL
CMP AL,FF
JB
Next
JMP
Repeat
INT A5
RESULT: 8255 PPI is interfaced with 8086in mode 0 with Port A as output port.
8255 address
PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Program:2
AIM: To generate a triangular wave form by interfacing 8255 PPI with 8086 microprocessor.
APPARATUS:
1.
2.
3.
4.
5.
PROGRAM CODE:
MOV AL,80
MOV DX,8807
OUT DX,AL
Repeat
MOV AL,00
MOV DX,8801
Next
OUT DX,AL
INC AL
CMP AL,FF
JB
Again
Next
OUT DX,AL
DEC AL
CMP AL,00
JA
JMP
INT A5
Again
Repeat
RESULT: 8255 PPI is interfaced with 8086in mode 0 with Port A as output port.
8255 address
PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Port A is connected to CRO to verify the program output.
Output: Triangular waveform is generated on CRO and the wave form is plotted on graph.
Peak to peak Voltage :
Time period
:
Program:3
AIM: To generate a square wave form by interfacing 8255 PPI with 8086 microprocessor.
APPARATUS:
1.
2.
3.
4.
5.
PROGRAM CODE:
MOV AL,80
MOV DX,8807
OUT DX,AL
Repeat
MOV AL,FF
MOV DX,8801
OUT DX,AL
CALL
Delay
MOV AL,00
OUT DX,AL
CALL
Delay
JMP
Repeat
DELAY PROGRAM
MOV CX,6D
Back
NOP
NOP
LOOP
Back
RET
RESULT: 8255 PPI is interfaced with 8086in mode 0 with Port A as output port.
8255 address
PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Port A is connected to CRO to verify the program output.
Output: Square waveform is generated on CRO and the wave form is plotted on graph.
Peak to peak Voltage :
Time period
ON period
OFF period
Program:4
AIM: To generate a rectangular wave form by interfacing 8255 PPI with 8086
microprocessor.
APPARATUS:
1.
2.
3.
4.
5.
PROGRAM CODE:
MOV AL,80
MOV DX,8807
OUT DX,AL
Repeat
MOV AL,FF
MOV DX,8801
OUT DX,AL
CALL
Delay1
MOV AL,00
OUT DX,AL
CALL
Delay2
JMP
Repeat
DELAY PROGRAM
Delay1
MOV CX,6D
Back1
NOP
NOP
LOOP
Back1
RET
RESULT: 8255 PPI is interfaced with 8086in mode 0 with Port A as output port.
8255 address
PORT A
8801
PORT B
8803
PORT C
8805
CWR
8807
Port A is connected to CRO to verify the program output.
Output: Recatangular waveform is generated on CRO and the wave form is plotted on graph.
Peak to peak Voltage :
Time period
ON period
OFF period