Professional Documents
Culture Documents
M S ENGINEERING COLLEGE
Navarathna Agrahara, Sadahalli Post, Bangalore -562110
Prepared By:
SYLLABUS
Laboratory Code: 17CSL48 IA Marks 40
Laboratory Session-2: Write-up on Instruction group, Timing diagrams, etc. The same
information is also taught in theory class; this helps the students to understand better.
Note: These TWO Laboratory sessions are used to fill the gap between theory classes and
practical sessions. Both sessions are evaluated as lab experiments for 20 marks.
Experiments:
• Develop and execute the following programs using 8086 Assembly Language. Any
suitable assembler like MASM/TASM/8086 kit or any equivalent software may be used.
• Program should have suitable comments.
• The board layout and the circuit diagram of the interface are to be provided to the student
during the examination.
• Software Required: Open source ARM Development platform, KEIL IDE and Proteus
for simulation
Software Programs: Part A
1. Design and develop an assembly language program to search a key element “X” in a list of
‘n’ 16-bit numbers. Adopt Binary search algorithm in your program for searching.
2. Design and develop an assembly program to sort a given set of „n‟ 16-bit numbers in
ascending order. Adopt Bubble Sort algorithm to sort given elements.
3. Develop an assembly language program to reverse a given string and verify whether it is a
palindrome or not. Display the appropriate message.
4. Develop an assembly language program to compute nCr using recursive procedure. Assume
that n and r are non-negative integers.
5. Design and develop an assembly language program to read the current time and Date from
the system and display it in the standard format on the screen.
6. To write and simulate ARM assembly language programs for data transfer, arithmetic and
logical operations (Demonstrate with the help of a suitable program).
7. To write and simulate C Programs for ARM microprocessor using KEIL (Demonstrate with
the help of a suitable program)
Note: To use KEIL one may refer the book: Insider’s Guide to the ARM7 based
microcontrollers, Hitex Ltd.,1st edition, 2005
8. a. Design and develop an assembly program to demonstrate BCD Up-Down Counter (00-99)
on the Logic Controller Interface.
b. Design and develop an assembly program to read the status of two 8-bit inputs (X & Y)
from the Logic Controller Interface and display X*Y.
9. Design and develop an assembly program to display messages “FIRE” and “HELP”
alternately with flickering effects on a 7-segment display interface for a suitable period of
time. Ensure a flashing rate that makes it easy to read both the messages (Examiner does not
specify these delay values nor is it necessary for the student to compute these values).
10. Design and develop an assembly program to drive a Stepper Motor interface and rotate the
motor in specified direction (clockwise or counter-clockwise) by N steps (Direction and N
are specified by the examiner). Introduce suitable delay between successive steps. (Any
arbitrary value for the delay may be assumed by the student).
11. Design and develop an assembly language program to a. Generate the Sine Wave using
DAC interface (The output of the DAC is to be displayed on the CRO).
b. Generate a Half Rectified Sine waveform using the DAC interface. (The output of the
DAC is to be displayed on the CRO).
12. To interface LCD with ARM processor-- ARM7TDMI/LPC2148. Write and execute
programs in C language for displaying text messages and numbers on LCD
13. To interface Stepper motor with ARM processor-- ARM7TDMI/LPC2148. Write a program
to rotate stepper motor
Study Experiments:
1. Interfacing of temperature sensor with ARM freedom board (or any other ARM
microprocessor board) and display temperature on LCD
2. To design ARM cortex based automatic number plate recognition system
3. To design ARM based power saving system
Course Outcomes: after studying this course, Students will be able to
Learn 80x86 instruction sets and gins the knowledge of how assembly language works.
Design and implement programs written in 80x86 assembly language
Know functioning of hardware devices and interfacing them to x86 family
Choose processors for various kinds of applications
Graduate Attributes
1. Engineering Knowledge
2. Problem Analysis
3. Modern Tool Usage
4. Conduct Investigations of Complex Problems
5. Design/Development of Solutions
It’s system software (program) which allows users to create a file containing assembly
instructions and statements. Ex: WordStar, DOS Editor, Norton Editor
Using the editor, you can also edit/delete/modify already existing files. o While saving, you
must give the file extension as “.asm”.
Follow the AL syntax while typing the programs
Editor stores the ASCII codes for the letters and numbers keyed in. o Any statement beginning
with semicolon is treated as comment.
When you typed your entire program, you have to save the file on the disk. This file is called
“source” file, having an ‘.asm’ extension. The next step is to convert this source file into a
machine executable ‘.obj’ file.
2. ASSEMBLER:
3. LINKER:
It’s a program used to join several object files into one large object file. For large programs,
usually several modules are written and each module is tested and debugged. When all the
modules work, their object modules can be linked together to form a complete functioning
program.
The LINK program must be run on “.obj” file.
The 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 linker assigns only relative addresses starting from zero, so that this can be put anywhere
in physical primary memory later (by another program called ‘locator’ or ‘loader’). Therefore,
this file is called reloadable. The linker produces link files with“.exe” extension.
Object modules of useful programs (like square root, factorial etc.) can be kept in a “library”,
and linked to other programs when needed.
4. LOADER:
It’s a program used to assign absolute physical addresses to the segments in the “.exe” file, in
the memory. IBM PC DOS environment comes with EXE2BIN loader program.
The “.exe” file is converted into “.bin” file.
The physical addresses are assigned at run time by the loader. So, assembler does not know
about the segment starting addresses at the time program being assembled.
5. DEBUGGER:
If your program requires no external hardware, you can use a program called debugger to load
and run the “.exe” file.
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot or debug it. The debugger also allows you to
look at the contents of registers and memory locations after you run your program.
The debugger allows you to change the contents of registers & memory locations and rerun
the program. Also, if facilitates to set up “breakpoints” in your program, single step feature,
and other easy-to-use features.
If you are using a prototype SDK 86 board, the debugger is usually called “monitor program”.
We would be using the development tool MASM 5.0 or higher version from
Microsoft Inc. MASM stands for Microsoft Macro Assembler. Another assembler
TASM (Turbo Assembler) from Borland Inc., is also available.
Steps to be followed:
1. Type EDIT at the command prompt (C :\> \MASM\). A window will be opened with all the
options like File, Edit etc., In the workspace, type your program according to the assembly
language syntax and save the file with a “.asm” extension. (say test.asm)
2. Exit the Editor using File menu or pressing ALT + F + X.
3. At the prompt, type the command MASM followed by filename.asm (say, test.asm). Press
Enter key 2 or 3 times. The assembler checks the syntax of your program and creates “.obj”
file, if there are no errors. Otherwise, it indicates the error with line numbers. You have to
correct the errors by opening your file with EDIT command and changing your instructions.
Come back to DOS prompt and again assemble your program using MASM command. This
has to continue until MASM displays “0 Severe Errors”. There may still be “Warning Errors”.
Try to correct them also.
4. Once you get the “.obj” file from step 3, you have to create the“.exe” file. At the prompt, type
the command LINK followed by “filename.obj” (say, test.obj) and press Enter key. (Note that
you have to give the extension now as “.obj” and not as “.asm”). If there are no linker errors,
linker will create “.exe” file of your program. Now, your program is ready to run.
5. There are two ways to run your program.
a) If your program accepts user inputs thro’ keyboard and displays the result on the screen, then
you can type the name of the file at the prompt and press Enter key. Appropriate messages will
be displayed.
b) If your program works with memory data and if you really want to know the contents of
registers, flags, memory locations assigned, opcodes etc., then type CV test (file name) at the
prompt. Another window will be opened with your program, machine codes, register contents
etc., Now, you also get a prompt > sign within CV window. Here you can use “d” command to
display memory contents, “E” command to enter data into memory and “g” command to
execute your program. Also, you can single step through your program using the menu options.
In many ways, CV (Code View) is like Turbo C environment.
Once you are familiar with the architecture and basics of assembly language tools, you can start
typing and executing your program.
Interrupt:
Service Description
numbers
01h To read a character and store it in AL register
02h To print a character present in DL register
0Ah To read a string and load the effective address(LEA) into DX register
09h To print the string
2Ch To read the system time
3Ch To create a new file
41h To delete the existing file
4Ch To terminate the program
Port A: (PA0-PA7) - is a 8-bit bidirectional I/O pins are used to send data to o utp ut device and to
receive data from input device. It functions as an 8-bit data output buffer, when used in output mode
and an 8-bit data input buffer, when used in input mode.
Port B: (PB0-PB7) - is a 8-bit bidirectional I/O pins are used to send data to output device and to
receive data from input device. It functions as an 8-bit data output buffer, when used in output mode
and an 8-bit data input buffer, when used in input mode.
Port C: (PC0-PC7) - The 8-bit bi-directional I/O pins are divided into two groups PCL (PC3- PC0)
and PCU (PC7-PC4). These groups individually can transfer data in or out when programmed for
simple I/O and used as handshake signals when programmed for handshake or bi-directional modes.
Control Word Formats: When RESET pin in 8255 goes HIGH all 24 lines of the three 8-bit ports
will be in input mode. The ports of the 8255 are then programmed for any other mode by writing a
single control word into the control register when required.
DAC Interface
Port A – Output Mode
Port B – Output Mode
Port C – I/O
Hence Control Word is 80H
Keyboard Interface
Port A – Input Port
Port B – I/O Mode Port
Port C – Output
Hence Control Word is 90H
Initialization of DS
Note: The instructions which initialize the DS register for
an exe-format program with
Simplified segment directives are:
MOV AX, @DATA
MOV DS, AX
At load time, @DATA is replaced with the 16-bit base
address of the data segment.
Comments:
A semicolon starts a comment. A comment may follow a
statement or it may be on a separate Line. Multiple-line
comments can be written by using the COMMENT
directive.
Numbers:
A binary number is suffixed by b or B.
e.g., 11010111B
A decimal number is suffixed by an optional d or D.
e.g., 42d -22D 3578
A hexadecimal number must begin with a decimal digit
and it is suffixed by h or H
e.g., 20H 0bF2Ah
Characters:
A character is enclosed in a pair of single quotes or in a
pair of double quotes.
e.g., ‘x’ “B”
Strings:
A string is enclosed in a pair of single quotes or in a pair
of double quotes.
e.g., ‘Enter Your Name: ’
“The Maximum Value Is”
The DUP operator can be used to generate multiple bytes or words with known as well as
uninitialized values.
The EQU (equate) directive assigns a name to a constant expression
Syntax is: name EQU constant expression
Note: No memory is allocated for EQU names
List of Experiments
SL.NO CONTENT
MASM Commands
Design and develop an assembly language program to search a key
1) element “X” in a list of ‘n’ 16-bit numbers. Adopt Binary search
algorithm in your program for searching.
Design and develop an assembly program to sort a given set of ‘n’ 16-
2) bit numbers in ascending order. Adopt Bubble Sort algorithm to sort
given elements.
Develop an assembly language program to reverse a given string and
3) verify whether it is a palindrome or not. Display the appropriate
message.
Develop an assembly language program to compute nCr using
4) recursive procedure. Assume that ‘n’ and ‘r’ are non-negative
integers.
Design and develop an assembly language program to read the current
5) time and Date from the system and display it in the standard format on
the screen.
To write and simulate ARM assembly language programs for data
6) transfer, arithmetic and logical operations (Demonstrate with the help
of a suitable program).
To write and simulate C Programs for ARM Mp using
7) KEIL (Demonstrate with the help of a suitable program)
MASM COMMANDS:
C :/>cd masm
C:/masm>edit filename.asm
After this command executed in command prompt an editor window will open.
Program should be typed in this window and saved. The program structure is given below.
Structure of Program:
.model small
.data
…….initialization of data
.code
……………….body of code
……………..
End
After verifying the program for correct syntax and the generated object files should be
linked together. For this the above link command should be executed and it will give an EXE
file if the model directive is small as discuss above.
C:/masm>Td filename.exe
After generating EXE file by the assembler it’s the time to check the output. For this the
above command is used and the execution of the program can be done in different ways.
1) Press F8,to see the execution step by step
2) Press F9,to see final output
C:/masm>debug filename.exe
After generating EXE file by the assembler it’s the time to check the output. For this
the above command is used and the execution of the program can be done in different ways. It
is as shown below:
__ g ; complete execution of program in single step.
__ t ; Stepwise execution.
PART-A
Aim: Design and develop an assembly language program to search a key element “X” in a list of
‘n’ 16-bit numbers. Adopt Binary search algorithm in your program for searching.
Algorithm:
Step 1: Declare the array
Step 2: Input the array elements in the sorted order
Step 3: Input the search element
Step 4: Assign left as 0 and right as n-1(count-1)
Step 5: Find mid index = (left+right)/2
Step 6: Compare mid element with search element
Step 7: If search element <mid element assign right as mid-1
Step 8: If search element >mid element, assign left as mid+1
Step 9: If search element = mid element, the search is successful so display the location of the
search element, go to step -12
Step 10: Repeat step 5 to 9until the search is successful
Step 11: If search element is not available, display “element not available”
Step 12: Terminate the program
Program:
.model small
.data
numbers dw 1234h,5678h,6252h,7617h,8213h
count equ 5
key dw 1234h
msg1 db 10,13,"Key is found$"
msg2 db 10,13,"Key is not found$"
.code
mov ax,@data
mov ds,ax
mov ax,key
mov cx,0
mov dx,count-1
back: cmp cx,dx
ja notfound
mov bx,cx
add bx,dx
shr bx,1
mov si,bx
add si,si
cmp ax,numbers[si]
je found
ja above
mov dx,bx
dec dx
jmp back
above: mov cx,bx
inc cx
jmp back
found: lea dx,msg1
jmp print
notfound:lea dx,msg2
print: mov ah,09h
int 21h
mov ah,04ch
int 21h
end
Conclusion:
This program performs a search for a key element in an array. If the search element is found it
will display a message ‘found’. As the search element (key element in program) is not present in
the given array it will display a message ‘not found’.
Aim: Design and develop an assembly program to sort a given set of ‘n’ 16-bit numbers in
ascending order. Adopt Bubble Sort algorithm to sort given elements.
Algorithm:
Step1: Declare the array with the numbers that need to be sorted.
Step2: Initialize iteration count (n-1)
Step3: Initialize comparison counter
Step4: Compare num1 and num2
Step5: Num1<=num2 do not exchange
Step6: Num1>=num2 then exchange the number positions
Step7: Decrement iteration counter, comparison counter
Step8: Terminate the program
Program:
.model small
.data
numbers dw 0ffffh,5555h,3333h,7777h
count dw 03h
.code
mov ax,@data
mov ds,ax
mov bx,count
dec bx
lea si,n1
add si,02
cmp ax,[si]
jc repeat
xchg ax,[si]
mov [si-2],ax
repeat:dec cx
jnz reverse
dec bx
jnz back
mov ah,04ch
int 21h
end
Conclusion:
This program will sort the given numbers in ascending order. The sorted numbers will be stored
Experiment-3: Writ an ALP to reverse a given string and verify whether it is a palindrome or not
Aim: Develop an assembly language program to reverse a given string and verify whether it is a
palindrome or not. Display the appropriate message.
Algorithm:
Step 1 : Create display macro to display the message
Step 2 : Declare the string
Step 3 : Declare the message to display
Step 4 : Find the reverse of string and store in string1
Step 5 : Is string=string1,display it is a palindrome
Step 6 : Else if display not a palindrome
Step 7 : Terminate the program
Program:
.model small
.data
str db "GADAG"
length equ ($-str)
rstr db 20 dup(0)
msg1 db 10,13,"word is palindrome $"
msg2 db 10,13,"word is not palindrome $"
.code
mov ax,@data
mov ds,ax
mov es,ax
mov si,offset str
mov di,offset rstr
add di,length-1
mov cx,length
back:mov al,[si]
mov [di],al
inc si
dec di
dec cx
jnz back
mov si,offset str
mov di,offset rstr
mov cx,length
cld
repe cmpsb
jne down
lea dx,msg1
jmp down1
down:lea dx,mes2
down1:mov ah,09h
int 21h
mov ah,04ch
int 21h
end
Manual calculations:
String = GADAG
str1 = [si] = [0000] = G
[0001]= A
[0002]= D
[0003]= A
[0004]= G
str2+len-1: [di] = [0005]+5-1= [0009]
[0005]= G
[0006]= A
[0007]= D
[0008]= A
di: [0009]= G
Output:
1. Input = GADAG
Output = The string is a palindrome
2. Input = Loril
Output = The string is not a palindrome
Conclusion: This program reverse the string provided in data segment by keeping the original
string as it is and compares both the strings. It will check each and every character. If all the
characters are same then the given string is said to be as palindrome and it will display a message
“palindrome” on screen otherwise the given string is not palindrome and it will display a message
“not palindrome” on screen.
MSEC CSE Dept, Prepared By Nagayya S Hiremath Page 20
Mp and Mc Lab(17CSL48)
je get1
cmp bl,1
je get3
dec al
cmp bl,al
je get2
push ax
push bx
call ncr ;call ncr recursive
pop bx
pop ax
dec bl
push ax
push bx
call ncr ;call ncr recursive
pop bx
pop ax
ret
get1: inc res
ret
get2:inc res
get3:add res,al
ret
ncr endp
end
Result: For the value N=5, R=2 the result is =0AH
Input Output
N=5 R=2(nCr) 0AH
Conclusion: This program performs nCr using recursive procedure. Output is stored in data
segment. To observe the output in data segment we have to search for our given ‘n’ and ‘r’ values
as program is written to store the result after the given data in data segment. The NcR Value for 8
and 5 is 56, But the output will be shown as 38 which is the Hex value of 56.
Experiment-5: Design and develop an assembly language program to read the current time and
Date from the system and display it in the standard format on the screen.
Aim: Design and develop an assembly language program to read the current time and Date from
the system and display it in the standard format on the screen.
Algorithm:
Step2 : Create dis macro for displaying two digits after converting to ASCII.
Step 5 : Use INT 21H function 02ch to get the system time.
Program:
.model small
.data
msg1 db 10,13,”The current time is:”
hour db 2 dup (0),’:’
min db 2 dup (0),’:’
sec db 2 dup (0),’$’
msg2 db 10,13,”The current date is:”
day db 2 dup (0),’:’
month db 2 dup (0),’:’
year db 2 dup (0),’$’
.code
mov ax,@data
mov ds,ax
;.........code for current time............
mov ah,02ch ;service number to read system time
int 21h
mov al,ch
aam
add ax,3030h
mov hour,ah
mov hour+1,al
mov al,cl
aam
add ax,3030h
mov min,ah
mov min+1,al
mov al,dh
aam
add ax,3030h
mov sec,ah
mov sec+1,al
mov ah,09h
lea dx,msg1
int 21h
;.........code for Todays date............
mov ah,2ah ;service number to read system date
int 21h
mov al,dl
aam
add ax,3030h
mov day,ah
mov day+1,al
mov al,dh
aam
add ax,3030h
mov month,ah
mov month+1,al
add cx,0f830h
mov al,cl
aam
add ax,3030h
mov year,ah
mov year+1,al
mov ah,09h
lea dx,msg2
int 21h
mov ah,04ch
int 21h
end
Result:
Current System Time is 00:01:01
Current Date is 01:01:2019
Conclusion:
The current time and date from the system is displayed in the standard format on the screen.
Experiment-6: To write and simulate ARM assembly language programs for data transfer,
arithmetic and logical operations (Demonstrate with the help of a suitable program).
Experiment-7: To write and simulate C Programs for ARM microprocessor using KEIL
(Demonstrate with the help of a suitable program).
AIM: To writes and simulates C Programs for ARM microprocessor using KEIL (Demonstrate
with the help of a suitable program).
PART B
Experiment-8A: BCD Up-Down Counter (0-9) on the Logic Controller Interface.
Aim: Design and develop an assembly program to demonstrate BCD Up-Down Counter (0-9) on
the Logic Controller Interface.
Algorithm:
Step 3: Send the initial value 0 to the logic controller interface, sense a key from the keyboard.
Step 5: Increment the value and send it to output until it reaches a value greater than 9
Step 7: Decrement the value to be sent to the output until it reaches the value 0.
Program:
.model small
.data
ctrl equ 0d883h
pa equ 0d880h
.code
mov ax,@data
mov ds,ax
mov dx,ctrl
mov al,82h ; select input and output port
out dx,al
mov al,00h
mov dx, pa
repeat: out dx,al
call delay
inc al
cmp al, 09 ; count till 9
jne repeat
mov dx, pa
back: out dx,al
call delay
dec al
cmp al,-1 ; decrement count till 0
jne back
mov ah, 04ch
int 21h
;…….Delay Program……….
delay proc near
mov bx,9999
up2:mov cx,9999h
up1:dec cx
jnz up1
dec bx
jnz up2
ret
delay endp
end
Experiment: 8b
Aim: Design and develop an assembly program to read the status of two 8-bit inputs (X & Y)
from the Logic Controller Interface and display X*Y.
Algorithm:
Step 1: Give the input value of X from the interface
Step 2: Read the input from the logic controller
Step 3: Repeat step1 and step2 for y value
Step 4: Multiply X*Y
Step 5: The result is shown on the LED of the interface
Program:
;…………....Display code………….
display macro msg
lea dx,msg
mov ah,09h
int 21h
endm
;…………..few seconds wait code………….
wait1 macro
mov ah,01
int 21h
endm
;…………….main program………….
.model small
.data
ctrl equ 0d883h
pa equ 0d880h
pb equ 0d881h
msg1 db 10,13,"Enter first value :$"
msg2 db 10,13,"Enter second value:$"
.code
mov ax,@data
mov ds,ax
mov dx,ctrl
mov al,82h
display msg1
wait1
mov ah,08h
int 21h
mov dx,pb
in al,dx ; Take the value into al
mov bl,al ; move the contents from al to bl
display msg2
wait1
mov ah,08h
int 21h
mov dx,pb
in al,dx ; Take the value into al
mov ah,00
mul bl ; The multiplied contents stored in AX
push ax
pop ax
mov dx,pa
out dx,al
mov bl,ah
wait1
mov dx,pa
mov al,bl
out dx,al
mov ah,04ch
int 21h
end
Conclusion: The program performs the multiplication between two bytes and gives the result.
First byte is read from the port B of logic controller (user has to provide) and waits for enter key
to be pressed and once enter key is and it reads the Second byte and multiplies and displays the
result through Port A.
Algorithm:
Step 1: Create delay macro; initialize count to display no of times and the number of characters.
Step 2: Declare the 7 segment codes of the characters that is to be displayed (FIRE-BLANK
HELP)
Interfacing Diagram:
Program:
.model small
.data
pa equ 0d880h
pc equ 0d882h
fire db 71h,06h,77h,79h,00h,00h
blank db 0,0,0,0,0,0
help db 76h,79h,38h,73h,00h,00h
.code
mov ax,@data
mov ds,ax
mov al,80h
out dx,al
repeat:mov di,100
call display
dec di
jnz fire1
mov di,100
call display
dec di
jnz blank1
mov di,100
call display
dec di
jnz help1
mov di,100
call display
dec di
jnz blank2
mov ah,01h
int 16h
je repeat
mov ah,04ch
int 21h
;………display program…….
mov bl,05
nextchar:mov al,bl
out dx,al
mov al,[si]
mov dx,pa
out dx,al
call delay
cmp bl,-1
jne nextchar
ret
display endp
;…….Delay program…………
push bx
push cx
mov bx,0010h
up2:mov cx,0ffffh
up1:dec cx
jnz up1
dec bx
jnz up2
pop cx
pop bx
ret
delay endp
end
Conclusion: This program displays “FIRE” and “HELP” on seven segment display interface
recursively one after the other with some delay. It’s not going to read any data from interface
device. The data which has to be displayed is provided in the program itself.
Aim: Design and develop an assembly program to drive a Stepper Motor interface and rotate the
motor in specified direction (clockwise or counter-clockwise) by N steps (Direction and N are
specified by the examiner). Introduce suitable delay between successive steps. (Any arbitrary
value for the delay may be assumed by the student).
Algorithm:
Step 2:Initialize the steps in which the stepper motor should rotate.
Interfacing Diagram:
Program:
.model small
.data
ctrl equ 0d883h
pc equ 0d882h
.code
mov ax,@data
mov ds,ax
mov al,80h
mov dx,ctrl
out dx,al
mov si,100
mov dx,pc
mov al,88h
back:out dx,al
call delay
dec si
jnz back
mov al,88h
back1:out dx,al
call delay
dec si
jnz back1
mov ah,04ch
int 21h
;……Delay program………….
mov cx,1000h
up2: dec bx
jnz up2
loop up1
ret
delay endp
end
Conclusion: This program drives a stepper motor interface to rotate by steps in anti-clockwise
and clockwise direction. After each rotation a delay is introduced to observe the rotation. After
completing the rotations the execution will get stopped.
Program:
.model small
.data
ctrl equ 0d883h
pa equ 0d880h
table db 127,140,153,166,178,190,201,212,221,229,236,243,247,251,253,
db 254,253,251,247,236,229,221,212,201,190,178,166,153,140,127
.code
mov ax,@data
mov ds,ax
mov al,80h
mov dx,ctrl
out dx,al
mov dx,pa
nextcycle:lea si,table
mov cx,31d
positivecycle:mov al,[si]
out dx,al
inc si
dec cx
jnz positivecycle
mov dx,pa
lea si,table
mov cx,31d
negativecycle:mov al,[si]
not al
out dx,al
inc si
dec cx
jnz negativecycle
jmp nextcycle
mov ah,04ch
int 21h
end
Aim: Generate a Half Rectified Sine waveform using the DAC interface. (The output of the DAC
is to be displayed on the CRO).
Algorithm:
Step1: Initialize the values for generating Half Rectified Sine Wave.
Program:
.model small
.data
ctrl equ 0d883h
pa equ 0d880h
table db 127,140,153,166,178,190,201,212,221,229,236,243,247,251, 253,
db 254,253,251,247,236,229,221,212,201,190,178,166,153,140,127
.code
mov ax,@data
mov ds,ax
mov al,80h
mov dx,ctrl
out dx,al
mov dx,pa
nextcycle:lea si,table
mov cx,31d
positivecycle:mov al,[si]
out dx,al
inc si
dec cx
jnz positivecycle
mov dx,pa
mov cx,31d
mov al,0
back:out dx,al
dec cx
jnz back
jmp nextcycle
mov ah,04ch
int 21h
end
12. To interface LCD with ARM processor-- ARM7TDMI/LPC2148. Write and execute programs in
C language for displaying text messages and numbers on LCD
// LCD INTERFACING
//----------------------------------------------------------------
// CONTROLLER : LPC-2148
//----------------------------------------------------------------
//----------------------------------------------------------------
// predefined data will be displayed on LCD
//----------------------------------------------------------------
#include<lpc214x.h>
#include<stdio.h> //Function prototypes
void lcd_init(void);
void wr_cn(void);
void clr_disp(void);
void delay(unsigned int);
void lcd_com(void);
void wr_dn(void); void
lcd_data(void); unsigned
char temp1; unsigned long
int temp,r=0;
int main()
{
PINSEL0 = 0X00000000; // configure P0.0 TO P0.15 as GPIO
IO0DIR = 0x000000FC; //configure o/p lines for lcd [P0.2-P0.7]
lcd_init(); //lcd intialisation
while(*ptr!='\0')
{
temp1 = *ptr;
void lcd_init(void)
{
temp = 0x30; //command to test LCD voltage level
wr_cn();
delay(3200);
temp = 0x30; //command to test LCD voltage level
wr_cn();
delay(3200);
temp = 0x30; //command to test LCD voltage level
wr_cn();
delay(3200);
temp = 0x20; // change to 4 bit mode from default 8 bit mode
wr_cn();
delay(3200);
temp1 = 0x28; // load command for lcd function setting with lcd in 4 bit mode,
lcd_com(); // 2 line and 5x7 matrix display
delay(3200);
temp1 = 0x0C; // load a command for display on, cursor on and blinking off
lcd_com();
delay(800);
temp1 = 0x06; // command for cursor increment after data dump
lcd_com();
delay(800);
temp1 = 0x80; // set the cursor to beginning of line 1
lcd_com();
delay(800);
}
void lcd_com(void)
{
temp = temp1 & 0xf0; //masking higher nibble first
wr_cn();
temp = temp1 & 0x0f; //masking lower nibble
temp = temp << 4;
wr_cn();
delay(500); // some delay
}
13.To interface Stepper motor with ARM processor-- ARM7TDMI/LPC2148. Write a program to
rotate stepper motor
//--------------------------------------------------------------
// CONTROLLER : LPC-2148
//-------------------------------------------------------------------
//-------------------------------------------------------------------
#include <LPC21xx.h>
void clock_wise(void) ;
void anti_clock_wise(void) ;
int main(void)
{
while(1)
} // End of main
void clock_wise(void)
{
var1 <<= 1 ;
IO1CLR =0x00F00000 ; //clearing all 4 bits
void anti_clock_wise(void)
{
var1 = 0x00800000 ;
IO1CLR =0x00F00000 ;
IO1SET = var1 ;
IO1CLR =0x00F00000 ;
IO1SET = var1 ;
3. What are the functional units in 8086? ANS: 8086 has two independent functional units
because of that the processor speed is more. The Bus interface unit and Execution unit are the two
functional units.
15. Which Flags can be set or reset by the programmer and also used to control the operation of
the processor?
ANS: Trace Flag, Interrupt Flag, Direction Flag.
16. In how many modes 8086 can be operated and how?
ANS: 8086 can be operated in 2 modes. They are Minimum mode if MN/MX pin is active high
and maximum mode if MN/MX pin is ground.
17. What is the difference between min mode and max mode of 8086?
ANS: Minimum mode operation is the least expensive way to operate the 8086 microprocessor
because all the control signals for the memory and I/O are generated by the microprocessor. In
Maximum mode some of the control signals must be externally generated. This requires the
addition of an external bus controller. It used only when the system contains external coprocessors
such as 8087 arithmetic coprocessor.
22. What is the position of the Stack Pointer after the POP instruction?
ANS: The address line is 02 greater than the earlier value.
23. What is interrupt?
ANS: Interrupt is a signal send by external device to the processor so as to request the processor
to perform a particular work.
24. What are the various interrupts in 8086?
ANS: Maskable interrupts, Non-Mask able interrupts.
25. What is meant by Maskable interrupts?
ANS: An interrupt that can be turned off by the programmer is known as Maskable interrupt.
26. What is Non-Mask able interrupts?
ANS: An interrupt which can be never being turned off (ie.disabled) is known as Non Maskable
interrupt.
27. Which interrupts are generally used for critical events?
ANS: Non-Maskable interrupts are used in critical events. Such as Power failure, Emergency,
Shut off etc.,
28. Give example for Non-Maskable interrupts?
ANS: Trap is known as Non-Maskable interrupts, which is used in emergency condition.
29. Give examples for Maskable interrupts?
ANS: RST 7.5, RST6.5, RST5.5 are Maskable interrupts. When RST5.5 interrupt is received the
processor saves the contents of the PC register into stack and branches to 2Ch (hexadecimal)
address. When RST6.5 interrupt is received the processor saves the contents of the PC register
into stack and branches to 34h (hexadecimal) address. When RST7.5 interrupt is received the
processor saves the contents of the PC register into stack and branches to 3Ch (hexadecimal)
address.