Академический Документы
Профессиональный Документы
Культура Документы
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.
.model small
.stack
.data
arr dw 0111h,0112h,0113h,0114h,0115h
len dw ($-arr)/2
key equ 0116h
msg1 db key element is found $
msg2 db key element is not found $
.code
mov ax,@data
mov ds,ax
mov bx,00h
mov dx,len
mov cx,key
dec ax
mov dx,ax
jmp again
big: je found
inc ax
mov bx,ax
jmp again
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.
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.
.model small
.stack
.data
array db 13h,21h,12h,15h,10h
len db ($-array)
.code
mov ax,@data
mov ds,ax
mov dl,len
dec dl
l1: inc si
loop again
dec dl
jnz back
mov ah,4ch
int 21h
end
Conclusion:
This program will sort the given numbers in ascending order. The sorted numbers will be
stored directly in the data Segment. To view the data segment the following code must be used.
-d ds: 0
3. Develop an assembly language program to reverse a given string and verify whether it is
a palindrome or not. Display the appropriate message.
.model small
.data
.stack
str1 db alam
slen equ ($-str1)
str2 db 40 dup(0)
msg1 db string is palindrome $
msg2 db string is not palindrome $
.code
start: mov ax,@data
mov ds,ax
mov es,ax
mov cx,slen
lea si,str1
add si,slen-1
lea di,str2
repe cmpsb
jne down
lea dx,msg1
mov ah,09h
int 21h
jmp down1
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.
.model small
.data
n.dw 03h
r dw 02h
ncr dw ?
.code
mov ax,@data
mov ds,ax
mov ncr,00h
mov ax,n
mov bx,r
call ncrproc
mov dx,ncr
mov ah,4ch
int 21h
ncproc proc
cmp ax,bx
je res1
cmp bx,00h
je res1
cmp bx,01h
je resn
dec ax
cmp ax,bx
je res2
push ax
push bx
call ncrproc
pop bx
pop ax
dec bx
push ax
push bx
call ncrproc
pop bx
pop ax
ret
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.
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.
.model small
.stack
.data
msg db the date is :
days db ?,?,:
months db ?,?,:
years db ?,?,(dd:mm:yy),10,13,$
.code
Start: mov ax,@dara
mov ds,ax
mov ah,2ah
int 21h
mov al,dl
aam
add ax,3030h
mov days,ah
mov days+1,al
mov al,dh
aam
add dx,3030h
mov months,ah
mov months+1,al
add cx,0f830h
mov al,cl
aam
add ax,3030h
mov years,ah
mov years+1,al
lea dx,msg
mov ah,09h
int 21h
mov ah,2ch
int 21h
mov al,ch
aam
add ax,3030h
mov hrs,ah
mov hrs+1,al
mov al,cl
aam
add ax,3030h
mov mins,ah
mov mins+1,al
mov al,dh
aam
add ax,3030h
mov secs,ah
mov secs+1,al
lea dx,msg1
mov ah,09h
int 21h
mov ah,4ch
int 21h
end start
Conclusion: this program displays the present system time and date.
6. To write and simulate ARM assembly language programs for data transfer, arithmetic
and logical operations (Demonstrate with the help of a suitable program).
1. ADDITION PROGRAM
ADD32
LDR R0,=0X8234E640 ; Load R0= 0X8234E640
LDR R1,=0X13210010 ; Load R1= 0X13210010
LDR R2,=0X12348900 ; Load R2= 0X12348900
LDR R3,=0X43212102 ; Load R3= 0X43212102
ADD R4,R0,R1 ; R4=R0+R1
ADC R5,R2,R3 ; R5=R2+R3
BX LR
END
OUTPUT:
R4=0X9555E650
R5=0X5555AA02
2. SUBTRACTION PROGRAM
BX LR
END
OUTPUT:
R4=0x01001110
R5=0x30EC9801
3. MULTIPLICATION PROGRAM
BX LR
END
OUTPUT:
R2=0X31D14EB2
4. DIVISION PROGRAM
AREA DIVISION , CODE , READONLY
EXPORT DIV
DIV
LDR R0,=0X0002 ; Load R0=0X0002 (Divisor)
LDR R1,=0X0008 ; Load R1=0X0008 (Dividend)
L1 SUB R1, R1,R0 ; R1=R1-R0
ADD R2,#1 ; R2=+1
CMP R1,R0 ;IF R1>R0 Jump to label L1 else end
BGE L1 ; Remainder in R1, Quotient in R2.
END
OUTPUT:
R1=0X00000000 (REMAINDER)
R2=0X00000004 (QUOTIENT)
5. DATATRANSFER PROGRAM
OUTPUT:
memory window1
type 0x40000000
0X40000000: AA 54 00 AB
OUTPUT:
R2=0XFFFFEDCB ;NOT operation result
R3=0X00000024 ;AND operation result
R4=0X00005777 ;OR operation result
R5=0X00005753 ;XOR operation result
7. To write and simulate C Programs for ARM microprocessor using KEIL (Demonstrate
with the help of a suitable program)
#include<lpc21xx.h> #include<lpc21xx.h>
OUTPUT:
OUTPUT:
R1=0x00000006 ;a value in R1
R1=0x00000006 ;a value in R1
R2=0x00000002 ;b value in R2
R2=0x00000002 ;b value in R2
R3=0X00000002 ;AND operation
R3=0X00000008 ;Sum value in R3 result
R12=0X00000004 ; Sub value in R12 R4=0X00000004 ;XOR operation
R4=0X0000000C ;mul value in R4 result
R5=0XFFFFFFF9 ;NOT operation result
R12=0X00000006 ;OR operation result
8. a. Design and develop an assembly program to demonstrate BCD Up-Down Counter (00-99)
on the Logic Controller Interface.
.model small
.stack
.data
mov al,80h
mov dx,1103h
out dx,al
mov al,00h
mov cx,0ffffh
b2: mov ax,0ffffh
b1: dec ax
jnz b1
loop b2
pop cx
pop ax
ret
delay endp
end
Allowio 0x1100h
Masm/zi updown;
Link/co updown;
updown
PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 BCD equivalent
0 0 0 0 0 0 0 0 00
0 0 0 0 0 0 0 1 01
0 0 0 0 0 0 1 0 02
0 0 0 0 0 0 1 1 03 up counter (00-99)
|
|
1 0 0 1 1 0 0 1 99
8. 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.
.model small
.stack
.data
.code
mov ax,@data
mov ds,ax
mov dx,1103h
mov al,8ah
out dx,al
display m1
mov ah,08h
int 21h
mov dx,1101h
in al,dx
mov bl,al
display m2
mov ah,08h
int 21h
mov dx,1101h
in al,dx
mul bl
mov dx,1100h
out dx,al
call delay
mov al,ah
mov dx,1100h
out dx,al
mov ah,4ch
int 21h
delay proc
mov si,0ffffh
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).
.model small
.stack
.data
F db 00h,00h,79h,77h,06h,71h
H db 73h,38h,79h,76h,00h,00h
.code
mov ax,@data
mov ds,ax
mov al,80h
mov dx,1103h
out dx,al
mov bp,0ah
Z: mov bx,0fffh
R: mov si,00h
mov cl,00h
A: mov di,00h
mov cl,00h
B: mov al,cl
mov dx,1102h
out dx,al
mov al,H[di]
mov dx,1100h
out dx,al
call delay
inc cl
inc di
cmp di 06h
jnz B
dec bx
jnz A
dec bp
jnz Z
mov ah,4ch
int 21h
delay procnear
push cx
push dx
mov cx,0ffh
Output:
Interface used multiplexed seven segment display
Allowio 0x1100h
Masm/zi fire;
Link/co fire;
Fire
In seven segment display the messages FIRE and HELP will be displayed alternately with
flickering effects.
h g f e d c b a
0 1 1 1 0 0 0 1 (71h=F)
0 0 0 0 0 1 1 0 (06h=I)
0 1 1 1 0 1 1 1 (77h=R)
0 1 1 1 1 0 0 1 (79h=E)
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).
.model small
.stack
.code
mov al,80h
mov dx,1103h
out dx,al
mov cx,32h
mov al,33h
b) Anticlockwise rotation
.model small
.stack
.code
mov al,80h
mov dx,1103h
out dx,al
mov cx,32h
mov al,33h
Output:
Allowio 0x1100h
Masm/zi stepper;
Link/co stepper;
Stepper
.model small
.stack
.data
Code1 db 80h,96h,0ach,0c0h,0d2h,0e2h,0e0h
db 0e2h,0f8h,0feh,0f3h,0f8h,0efh,0e2h
db 0d2h,0c0h,0ach,96h,80h,69h,54h,40h,02fh
db 0eh,11h,08h,02h,00h,02h,05h,04h,1eh,2ch
db 40h,54h,6ah,80h
.code
mov ax,@data
mov ds,ax
mov al,80h
mov dx,1103h
out dx,al
out dx,al
inc si
loop l1
jmp l2
mov ah,4ch
int 21h
end
output:
Allowio 0x1100h
Masm/zi sinw;
Link/co sinw;
Sinw
b. Generate a Half Rectified Sine waveform using the DAC interface. (The output of
the DAC is to be displayed on the CRO).
.model small
.stack
.data
Code1 db 80h,96h,0ach,0c0h,0d2h,0e2h,0e0h
db 0f8h,0feh,0ffh,0fch,0f8h,0efh,0e2h
db 0d2h,0c0h,0ach,96h,80h,80h,80h,80h,80h
db 80h,80h,80h,80h,80h,80h,80h,80h,80h,80h
db 80h,80h,80h,80h,80h,80h
.code
mov ax,@data
mov ds,ax
mov al,80h
mov dx,1103h
out dx,al
out dx,al
inc si
loop l1
jmp l2
mov ah,4ch
int 21h
end
output:
Allowio 0x1100h
Masm/zi halfr;
Link/co halfr;
halfr