Beruflich Dokumente
Kultur Dokumente
1. a) Search a key element in a list of n 16-bit numbers using the Binary search algorithm.
Algorithm Step 1: Initialize the data segment Step 2: Set low and high pointer Step 3: find the mid value Step 4: mid=(low+high)/2 Step 5: Make it even Step 6: Compare a[mid] with the key Step 7: if it is equal display msg1 else msg2 Step 8: stop
Program: data segment a dw 19,10,23,25,24h n dw 5h msg1 db 'successful$' key dw 29h msg2 db 'unsuccessful$' data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov si,0
Dept of CSE Page 1
Dept of CSE
Page 3
Dept of CSE
Page 5
Program: data segment a db 66h,77h,22h,33h,44h,99h,11h,55h,88h s dw $-a data ends code segment assume cs:code, ds:data start: mov ax,data mov ds,ax mov bx,s dec bx outloop: mov cx,bx
Dept of CSE Page 6
Dept of CSE
Page 7
Program: data segment ascii db 2 dup(?) data ends code segment assume cs:code, ds:data start: mov ax,data mov ds,ax mov ah,00h mov al,02h int 10h mov ah,01h int 21h
Dept of CSE
Page 8
Dept of CSE
Page 10
Dept of CSE
Page 11
Dept of CSE
Page 12
Dept of CSE
Page 13
Output: Input: Enter First String: Oxford Enter the Second String: Oxford
Dept of CSE
Page 17
Algorithm: Step1: Initialize msg in Data segment Step2: Initialize data segment Step3: Read name from keyboard Step4: Press enter key to go for next line & display the msg Step5: Call procedure to clear the screen Step6: call procedure to set the cursor & display msg Step7: Stop
program:
data segment myname db 20 dup(0,'$') enter db 10,13,'enter the name:$' msg db 10,13,' data ends your name is:$'
code segment assume cs:code, ds:data start: mov ax,data mov ds,ax
Dept of CSE Page 18
Dept of CSE
Page 20
program: data segment n dw 5 r dw 4 ncr dw 0 data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov ax,n mov bx,r
Dept of CSE Page 21
Output: A
Dept of CSE
Page 23
Program: data segment msg db 10,13,'press any key to quit:$' data ends code segment assume cs:code, ds:data start:mov ax,data mov ds,ax lea dx,msg mov ah,09h int 21h mov ah,00 mov al,00 next_num: push ax
Dept of CSE Page 26
Dept of CSE
Page 28
Program: data segment msg1 db 10,13,'enter the row no(min:00 & max:24):$' msg2 db 10,13,'enter the col no(min:00 & max:77):$' msg3 db 10,13,'press any key to quit:$' row db ? col db ? data ends
output: enter the row no(min:00 & max:24):24:12 enter the col no(min:00 & max:77):40
Dept of CSE
Page 31
Program: .MODEL SMALL DISPLAY MACRO MSG LEA DX, MSG MOV AH, 09H INT 21H ENDM .DATA MSG1 DB 0DH, 0AH, "ENTER THE FILE NAME :: $"
MSG2 DB 0DH, 0AH, "FILE CREATED SUCCESSFULLY $" MSG3 DB 0DH, 0AH, "CREATION FAILED.$" MSG4 DB 0DH, 0AH, "ENTER THE FILE NAME TO DELETE :: $" MSG5 DB 0DH, 0AH, "DELETED SUCCESSFULLY $" MSG6 DB 0DH, 0AH, "DELETION FAILED $" FNAME DB 40H DUP (?)
Dept of CSE
Page 32
output: Input: Enter the fail name to create: Enter the fail name to delete: output: Fail created successfully
Dept of CSE
Page 34
Microprocessor Lab Manual(10CSL48) Hardware Interfacing Programs 1b) Read the status of eight input bits from the Logic Controller Interface and display FF if it is the parity of the input read is even; otherwise display 00.
Program
data segment pa equ 0b400h pb equ 0b401h cr equ 0b403h cw db 83h msg db'no of 1s:$' data ends initds macro mov ax,data mov ds,ax endm init8255 macro mov al,cw mov dx,cr out dx,al endm inpb macro mov dx,pb in al,dx endm outpa macro mov dx,pa out dx,al endm exit macro mov ah,4ch
Dept of CSE Page 35
Dept of CSE
Page 37
Microprocessor Lab Manual(10CSL48) 2b) Implement a BCD Up-Down Counter on the Logic Controller Interface. Program:
data segment pa equ 0b400h pb equ 0b401h cw db 82h cr equ 0b403h msg1 db 10,13,"1.BCD up down counter","2.Ring Counter" msg2 db 10,13, "Enter your choice$" msg3 db 10,13, "Press any key to quit$" msg4 db 10,13, "Invalid choice$" data ends initds macro mov ax,data mov ds,ax endm init_8255 macro mov al,cw mov dx,cr out dx,al
Dept of CSE Page 38
3b) Read the status of two 8-bit inputs (X & Y) from the Logic Controller Interface and display X*Y. Program
data segment pa equ 0b400h pb equ 0b401h cw db 82h cr equ 0b403h
Dept of CSE Page 42
4 b) Display messages FIRE and HELP alternately with flickering effects on a 7segment 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). Program
data segment pc equ 0b402h pb equ 0b401h cw db 80h cr equ 0b403h m1 db 10,13,"Press any key to quit$" msg1 db 86h,88h,0cfh,8eh msg2 db 8ch,0c7h,86h,89h data ends initds macro mov ax,data mov ds,ax endm init_8255 macro mov al,cw mov dx,cr out dx,al endm outpb macro mov dx,pb out dx,al endm
Dept of CSE Page 45
Dept of CSE
Page 47
Microprocessor Lab Manual(10CSL48) 5b) Assume any suitable message of 12 characters length and display it in the rolling fashion 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). Program
data segment pb equ 0b401h pc equ 0b402h cr equ 0b403h cw db 80h m1 db 10,13,"press any key to exit$" ssc db 80h,0c0h,80h,92h,0ffh,0cfh,88h,92h,80h,0c0h,80h,82h data ends initds macro mov ax,data mov ds,ax endm init8255 macro mov al,cw mov dx,cr out dx,al endm outpb macro mov dx,pb out dx,al endm outpc macro
Dept of CSE Page 48
Dept of CSE
Page 50
Microprocessor Lab Manual(10CSL48) 6 b) Convert a 16-bit binary value (assumed to be an unsigned integer) to BCD and display it from left to right and right to left for specified number of times on a 7-segment display interface. Program
data segment pb equ 0b401h pc equ 0b402h cr equ 0b403h cw db 80h m1 db 10,13,"press any key to exit$" msg db 0ffh,0ffh,0ffh,0ffh,?,?,?,?,0ffh,0ffh,0ffh,0ffh table db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,98h bcd db 5 dup(?) num dw 00ffh data ends initds macro mov ax,data mov ds,ax endm init8255 macro mov al,cw mov dx,cr out dx,al endm outpb macro mov dx,pb out dx,al endm outpc macro mov dx,pc
Dept of CSE Page 51
mov bl,8
mov al,[si]
7b) Scan a 8 x 3 keypad for key closure and to store the code of the key pressed in a memory location or display on screen. Also display row and column numbers of the key pressed. Program
data segment pa equ 0b400h pb equ 0b401h pc equ 0b402h cr equ 0b403h m1 db 10,13,10,13,"enter key is:$" m2 db 10,13,10,13,"row number is:$" m3 db 10,13,10,13,"column number is:$" m4 db 10,13,10,13,"press 'C'from system keyboard to continue$" m5 db 10,13,10,13,"press any key from KB_INTERFACE$" row db ? col db ? cw db 90h data ends initds macro mov ax,data
Dept of CSE Page 55
Dept of CSE
Page 58
Microprocessor Lab Manual(10CSL48) 8b) Drive a Stepper Motor interface to 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). Program
data segment pa equ 0b400h cr equ 0b403h step_size db 90h cw db 80h data ends initds macro mov ax,data mov ds,ax endm init8255 macro mov al,cw mov dx,cr out dx,al endm outpa macro mov dx,pa out dx,al endm code segment assume cs:code,ds:data start: initds init8255 mov bl,step_size
Dept of CSE Page 59
Dept of CSE
Page 60
Microprocessor Lab Manual(10CSL48) 9b) Generate the Sine Wave using DAC interface (The output of the DAC is to be displayed on the CRO). Program
data segment pa equ 0b400h pb equ 0b401h cr equ 0b403h cw db 80h table db 80h,96h,0abh,0c0h,0d2h,0e2h,0eeh,0f8h,0feh,0ffh db 0feh,0f8h,0eeh,0e2h,0d2h,0c0h,0abh,96h,80h db 69h,54h,40h,2dh,1dh,11h,07h,01h,00h db 01h,07h,11h,1dh,2dh,40h,54h,69h,80h msg db 10,13,"press any key to exit$" data ends initds macro mov ax,data mov ds,ax endm init8255 macro mov al,cw mov dx,cr out dx,al
Dept of CSE Page 61
Dept of CSE
Page 63
Microprocessor Lab Manual(10CSL48) 10b) Generate a Half Rectified Sine wave form using the DAC interface. (The output of the DAC is to be displayed on the CRO). Program
data segment pa equ 0b400h cr equ 0b403h cw db 80h table db 96h,0abh,0c0h,0d2h,0e2h,0eeh,0f8h,0feh,0ffh db 0feh,0f8h,0eeh,0e2h,0d2h,0c0h,0abh,96h,80h msg db 10,13,'preee any key to exit$' data ends initds macro mov ax,data mov ds,ax endm init8255 macro mov al,cw mov dx,cr out dx,al endm outpa macro mov dx,pa out dx,al endm code segment assume cs:code ,ds:data start: initds init8255
Dept of CSE Page 64
Dept of CSE
Page 65
Microprocessor Lab Manual(10CSL48) 11b) Generate a Fully Rectified Sine waveform using the DAC interface. (The output of the DAC is to be displayed on the CRO). Program
data segment pa equ 0b400h cr equ 0b403h cw db 80h table db 96h,0abh,0c0h,0d2h,0e2h,0eeh,0f8h,0feh,0ffh db 0feh,0f8h,0eeh,0e2h,0d2h,0c0h,0abh,96h,80h msg db 10,13,'preee any key to exit$' data ends initds macro mov ax,data mov ds,ax endm init8255 macro mov al,cw mov dx,cr out dx,al endm outpa macro mov dx,pa out dx,al endm code segment assume cs:code ,ds:data start:initds init8255 lea dx,msg mov ah,09h int 21h
Dept of CSE Page 66
Dept of CSE
Page 67
Microprocessor Lab Manual(10CSL48) 12 b) Drive an elevator interface in the following way: i. Initially the elevator should be in the ground floor, with all requests in OFF state. ii. When a request is made from a floor, the elevator should move to that floor, wait there for a couple of seconds (approximately), and then come down to ground floor and stop. If some requests occur during going up or coming down they should be ignored. Program
data segment pa equ 0b400h pb equ 0b401h cr equ 0b403h msg db 10,13,"press any key to exit$" floor db 00h,03h,06h,09h,0e0h,0d3h,0b6h,79h cw db 82h data ends initds macro mov ax,data mov ds,ax endm init8255 macro mov al,cw mov dx,cr out dx,al endm disp_msg macro msg lea dx,msg mov ah,09h int 21h endm outpa macro mov dx,pa
Dept of CSE Page 68
Dept of CSE
Page 71