8086 Masm Manual
February 22, 2017 | Author: sri_baba09 | Category: N/A
Short Description
Download 8086 Masm Manual...
Description
Exp no: 1 Program for 16-bit Addition & Subtraction in 8086 Microprocessor kit Aim: To write an Assembly Language Program for 16-bit Addition & Subtraction in 8086 Microprocessor kit Apparatus Required: 8086 Microprocessor Trainer Kit with Power Supply. Addition: Algorithm: 1. Start the Program 2. Initialize the contents of memory locations in AX & BX registers 3. Initialize the value 00 for CL register. 4. Add the value of AX and BX by using ADD Mnemonics and store the result in a memory location. 5. If there is carry Increment the value of CL register by 1, else move the content of AX to a location for result. 6. Move the value of CL to a location for output. 7. Stop the Program Program: Start: Mov AX,[2000H] Mov BX,[2002H] Mov CL,00 ADD AX,BX JNC L1 INC CL L1:
Mov [2006H],AX Mov [2008H],CL
End:
HLT
Subtraction: Algorithm: 1. Start the Program 2. Initialize the contents of memory locations in AX & BX registers 3. Initialize the value 00 for CL register. 4. Subtract the value of AX and BX by using SUB Mnemonics and store the result in a memory location. 5. If there is carry Increment the value of CL register by 1, else move the content of AX to a location for result. 6. Move the value of CL to a location for output. 7. Stop the Program
Program: Strat: Mov AX,[2000H] Mov BX,[2002H] Mov CL,00H SUB AX,BX JNC L1 INC CL L1:
Mov [2006H],AX Mov [2008H],CL
End:
HLT
Result: Thus the ALP to add and subtract 16 bit number using 8086 Microprocessor Kit was written and executed successfully.
Exp no: 2 Program for 16-bit Division & Multiplication in 8086 Microprocessor kit. Aim: To write an Assembly Language Program for 16-bit Division & Multiplication in 8086 Microprocessor kit.
Apparatus Required: 8086 Microprocessor Trainer Kit with Power Supply. Multiplication: Algorithm: 1. start the program 2. initialize the contents for AX and BX from memory locations 3. Multiple the AX and BX value using MUL Mnemonics and store the result in a memory location. 4. move the content of AX and DX to memory locations to check the result. 5. stop the program Program: Start: mov AX,[2000H] mov BX,[2002H] MUL BX mov [2006H],AX mov [2008H],DX end:
HLT
Division: Algorithm: 1. start the program
2. initialize the contents for AX and BX from memory locations 3. Multiple the AX and BX value using MUL Mnemonics and store the result in a memory location. 4. move the content of AX and DX to memory locations to check the result. 5. stop the program Program: Start: mov AX,[2000H] mov BX,[2002H] DIV BX mov [2006H],AX mov [2008H],DX end:
HLT
Result: Thus the ALP to multiple and divide 16 bit number using 8086 Microprocessor Kit was written and executed successfully.
Exp no: 3 Program for Ascending order and Descending order in 8086 Microprocessor kit. Aim: To write an Assembly Language Program for Ascending order and Descending order in 8086 using MASM software. Apparatus Required: MASM Software Ascending order: Algorithm: 1. Start the program 2. Declare the set of elements in list and initialize the count value in the data segment. 3. In code segment(CS), move the data segment values to data segment register. 4. Initialize the starting address of list to BX and count values to CX register. 5. Get the succesive elements in source index(BX) and sort the elements in ascending order. 6. Termination interrupt is performed to terminate the program. 7. Stop the program. Program:
Start:
Assume CS:code,DS:Data Data Segment List dw 05h,07h,06h,02h Count equ 04h Data ends Code segment Mov AX,data
#Open the data segment #Declare the set of values to list #Assign the control values #end of data segment #Open code segment #Assign the value of data to DS through an
Mov DS,AX Mov DX,count-1 L3 Mov CX,DX Mov BX,offset list L2 Mov AX,[BX] Cmp AX,[BX+2] JL L1 XCHG [BX+02],AX XCHG [BX],AX L1 Add BX,02h Loop L2 Dec DX JNZ L3 Mov AH,4Ch Int 21h Code ends End start
accumulator #Iniatilize AX value to DS #Initialize the count register #Initialize the DX value to CX #Assign the first address of list to bx #Move the first value to AX #Compare AX with successive element #Jump if AX < [BX+2] the goto L1 #excahnge the values of [BX],AX #excahnge the values of [BX],AX #increment the value BX value #goto L2 #Decrement by the value Dx #if DX is No Zere, goto L3 #interrupt signal # interrupt signal #end the code segment #end of start
Descending order: Algorithm: 1. Start the program 2. Declare the set of elements in list and initialize the count value in the data segment. 3. In code segment(CS), move the data segment values to data segment register. 4. Initialize the starting address of list to BX and count values to CX register. 5. Get the succesive elements in source index(BX) and sort the elements in descending order. 6. Termination interrupt is performed to terminate the program. 7. Stop the program.
Program: Assume CS:code,DS:Data Data Segment #Open the data segment List dw 05h,07h,06h,02h #Declare the set of values to list
Start:
Count equ 04h Data ends Code segment Mov AX,data
Mov DS,AX Mov DX,count-1 L3 Mov CX,DX Mov BX,offset list L2 Mov AX,[BX] Cmp AX,[BX+2] JG L1 XCHG [BX+02],AX XCHG [BX],AX L1 Add BX,02h Loop L2 Dec DX JNZ L3 Mov AH,4Ch Int 21h Code ends End start
#Assign the control values #end of data segment #Open code segment #Assign the value of data to DS through an accumulator #Iniatilize AX value to DS #Initialize the count register #Initialize the DX value to CX #Assign the first address of list to bx #Move the first value to AX #Compare AX with successive element #Jump if AX > [BX+2] the goto L1 #excahnge the values of [BX],AX #excahnge the values of [BX],AX #increment the value BX value #goto L2 #Decrement by the value Dx #if DX is No Zere, goto L3 #interrupt signal # interrupt signal #end the code segment #end of start
Result: Thus , the Assembly language program for sort the elements in ascending and descending order was written , executed successfully and the output was verified.
Exp no:4 Program for String copy. Aim: To write an Assembly Language Program for String Copy in 8086 using MASM software.
Apparatus Required: MASM Software
Algorithm: 1. Start the program 2. In the data segment initialize the elements in array (source), initialize the destination address to des and counter value. 3. In code segment(CS), move the data segment value to data segment register. 4. Initialize the starting address of source to SI and move the des, count value to DI,CX. 5. Swap the elements to specified address with the use of cld rep MOVSW command. 6. Use interrupt to terminate the program. 7. Stop the program.
Program: Assume CS:code,DS:Data
Data segment Source dw 01h,05h,06h Des equ 3000h Count equ 03h Data ends Cod segment Mov AX, data Mov ds, AX Mov SI, offset source Mov d1,des CLD Rep movsw Mov ab,4ch Int 21h Code ends End start
Start:
End:
Result: Thus, the ALP for string copy using 8086 was executed successfully and the output was verified.
Exp no: 5 Program for Reverse the String. Aim: To write an Assembly Language Program for Reverse the String in 8086 using MASM software. Apparatus Required: MASM Software Algorithm: 1. Start the program 2. In the data segment, initialize the elements in array named as src, initialize the empty array size as ds and the count value. 3. In code segment (CS), move the data segment value to data segment register. 4. Move the count value (count +1) to count register and define the offset address of des to di and move the 06h to dx. 5. Define the offset address of src to s1 then move the s1 to bx then bx to dx. 6. Decrement the destination index then subtract the source index value. 7. Decrement the CX if nonzero goto step 5. 8. Stop the program. Program: Assume cs: code, ds: data Data segment src dw 09h,08h,07h des dw 10h
count equ 03h data ends code segment start: mov ax, data mov ds, ax mov cx,count+1 mov di, offset des mov dx, 06h mov si, offset src add si, dx loop: mov bx, [si] mov [di], bx add di, 02h dec cx jnz loop mov ah, 4ch int 21h code ends end start. RESULT: Thus the ALP for reverse the string in 8086 was written and executed successfully and the output was verified.
Exp no:6 Program for Searching an Element. Aim: To write an Assembly Language Program for Searching the given element in 8086 using MASM software. Apparatus Required: MASM Software Algorithm: 1. Start the program. 2. Initialize all the elements of array and named them. 3. Define the messages in disp1 and disp2. 4. Initialize the counter value in data segment. 5. If counter reaches 0, goto step6, else do the following steps Ø Load the list to accumulator and then load the counter value to counter register Ø Compare the accumulator with given element, if it is present display the message as “data is present” else jump to loop. Ø If it is not present , display the message as “Data is not present” 6. Stop the program.
Program: Assume cs: code, ds: data Data segment List dw 05h, 06h, 07h, 08h, 09h Disp1 db “Data is present”,”&” Disp2 db “Data is not present”,”&” Count equ 05h Data ends Code segment Org 1000h Start: mov ax, data mov ds, dx mov si, offset list mov cx, count loop: mov ax, [si] cmp ax, 05h jz loop1 add si, 02h dec cx jnz loop jmp loop2 loop1: mov dx, offset disp1 jmp loop3 loop2: mov dx, offset disp2 jmp loop3 loop3: mov ah, 09h int 21h mov ah, 4ch int 21h code ends end Result: Thus, the ALP for searching an element was written and executed successfully and the output was verified.
Exp no:7 Program for File Manipulation in 8086. Aim: To write an Assembly Language Program for File Manipulation in 8086 using MASM software. Apparatus Required: MASM Software Algorithm: 1. Start the program 2. In the data segment define byte for filename and named as FN 3. In code segment, move the data segment values to ds register 4. Initialize the address of FN to DX register. 5. Interrupt command (3ch) is used to pen a file. 6. Perform the termination using terminate interrupt for program. 7. Stop the program. Program: Assume cs: code, ds: data Data segment FN DB “siva.txt”,”$” Data ends Code segment
Start: mov ax, data mov ds, ax mov dx, offset FN mov cx, 00h mov ah,3ch int 21h code ends end start Result: Thus the ALP for file manipulation in 8086 using MASM software was written and executed successfully and the output was verified.
Exp no: 8 Interfacing of Stepper Motor controller using 8086 Microprocessor kit. Aim: To write an Assembly Language Program for run Stepper Motor in clockwise and anticlockwise direction using 8086 Microprocessor kit. Apparatus Required: Microprocessor kit, Power cable, stepper motor kit and Data cable. Algorithm: 1. Start the program 2. Initialize a memory location to DI 3. Initialize the counter value as 04 4. Move the content of DI to AL 5. Write the AL value as 00h to port 6. Move the content of memory location to DX. 7. Decrement the DX value and if it is no zero call delay program. 8. Increment the DI value and goto step 4 9. Goto step 2. 10. Stop the program
Clockwise direction values: - 09h, 05h, 06h , 0Ah, 09h Anticlockwise direction values: - 09h , 0Ah, 06h, 05h, 09h
Program: L2:
MOV DI, [1018h] MOV CL, 04
L1:
MOV AL, [DI] OUT 00, AL MOV DX, [1010h]
delay:
DEC DX JNZ delay INC DI LOOP L1 JUMP L2 HLT
Clockwise direction values: - 09h, 05h, 06h, 0Ah, 09h Anticlockwise direction values: - 09h, 0Ah, 06h, 05h, 09h
Result: Thus, the assembly language program in 8086 for stepper motor in clockwise and anticlockwise was written and executed successfully and the output was verified.
Exp no:9 Interfacing of Keyboard / Display (8279) using Microprocessor kit. Aim: To write an Assembly Language Program for Interfacing of Keyboard / Display (8279) in 8086 Microprocessor kit for displaying character „A‟ and rolling display.
Apparatus Required: Microprocessor kit, Power cable, 8279 keyboard/display kit and Data cable. Algorithm for Character Display of „A‟:
1. Start the program 2. Initialize the AL as 00h and write the AL value to port. 3. Enter the value for Character “A” as 88h 4. Write the value to output port 5. Goto step 4. 6. Stop the program.
Program for Character Display of „A‟
MOV AL,00h OUT C2,AL MOV AL, CCh OUT C2,AL MOV AL,90h OUT
C2,AL
MOV AL,88h OUT C0,AL MOV AL,FFh OUT C2,AL MOV CX,0006h L1: OUT C0,AL LOOP L1 HLT
Algorithm for Rolling Display:
1. Start the program 2. Set the counter value for number of characters to roll and write the value port. 3. Move the 10h, CCh, 90h value for number of characters to roll and write the value port. 4. Move the roll character values to source index(SI) and write into port. 5. Move the value 0A0Fh to the register DX 6. Decrement it till reach 00h. 7. If DX is no zero goto step 6 and increment Source index to accept next value 8. Goto step 4. 9. Stop the program.
Program for Rolling Display:
START: MOV SI,[2000h] MOV CX, 000Fh MOV AL, 10h OUT C2, AL MOV AL, CCh OUT C2,AL MOV AL,90h OUT C2,AL L1: MOV AL,[SI] OUT C0,AL MOV DX,0A0Fh L2: DEC DX JNZ L2 INC SI LOOP L1 JMP START Result: Thus, the assembly language program in 8086 to display the character „A‟ and roll the display was written and executed successfully and the output was verified.
Exp no:10 Interfacing of ADC with 8086 Microprocessor kit. Aim : To write an Assembly Language Program for Interfacing ADC in 8086 Microprocessor kit.
Apparatus Required: Microprocessor kit, Power cable, ADC kit and Data cable Algorithm for ADC: 1. Start the program. 2. Move the control register values to AL register and write those values to ports. 3. Move the initial value 00yh to AL and write the value to port. 4. Accept the analog value from ADC kit and store it in AL. 5. Compare the AL with 01h, if it true and no zero goto step 4.
6.
Accept the analog value from port and store it in AL.
7. Move the value in AL to a memory Location [1500h]. 8. Stop the program. Program for ADC: MOV AL,10h OUT
C8,AL
MOV AL,18h OUT
C8,AL
MOV AL,01h OUT D0,AL MOV AL,00h MOV AL,00h MOV AL,00h MOV AL,00h OUT D0,AL L1:
IN
AL,D8
AND
AL,01h
CMP
AL,01h
JNZ L1 IN
AL,C0
MOV BX,1500h MOV [BX],AL HLT
Result : Thus, the assembly language program in 8086 to convert the analog value to digital using ADC convertor was written and executed successfully and the output was verified.
Exp no:11 Interfacing of DAC with 8086 Microprocessor kit. Aim : To write an Assembly Language Program for Interfacing of DAC with 8086 Microprocessor kit for generating waveforms such as sine wave, triangular wave, saw tooth wave and square wave.
Apparatus Required: Microprocessor kit, Power cable, DAC kit and Data cable. Algorithm: SAW TOOTH WAVE: 1. Start the program 2. Initialize the register AL as 00h 3. Write the initial value in port 4. Increment the AL value and check if no zero goto step 3.
5. Stop the program
TRIANGULAR WAVE: 1. Start the program 2. Initialize the BL register as 00h 3. Move the contents of BL to AL 4. Write the AL value in Port 5. Increment the BL value and check if it is no zero goto step 2 6. Initialize the BL register as FFh 7. Move the contents of BL to AL 8. Write the AL value in Port 9. Decrement the BL register and check if it is zero goto step 6 10. Goto step 1 11. Stop the program
SQUARE WAVE: 1. Start the program 2. Initialize the AL as 00h 3. Write the port value of AL register and goto step 4. Initialize as AL as highest value and write the AL value to port and call step 6. 5. Goto step 2 6. Move the contents of 05FFh to CX and goto step 5 7. Stop the program
SINE WAVE : 1. Start the program
2. Initialize the look up table in a memory location 3. Initialize the value 46h 4. Move the contents of BX to AL 5. Increment the BX value 6. Write the AL value to ports goto step 4 7. Goto step 2 8. Stop the program
Program: SAW TOOTH WAVE: START : MOV AL,00h L1 : OUT C0,AL INC AL JNZ L1 JMP START TRIANGULAR WAVE: L3: MOV BL,00h L1: MOV AL,BL OUT C8,AL INC BL JNZ L1 MOV BL,FFh L2: MOV AL,BL OUT C8,AL DEC BL JNZ L2 JMP L3 SQUARE WAVE: START: MOV AL,00h OUT C8,AL CALL ROUTINE MOV AL,FFh OUT C8,AL CALL ROUTINE JMP START ROUTINE : MOV CX,05FFh
L3 : LOOP L3 RET SINE WAVE GENERATION: START: MOV BX,1100h MOV CL,46h L1: MOV AL,[BX] OUT C0,AL INC BX LOOP L1 JMP START
Result : Thus, the assembly language program in 8086 to convert the digital values to analog using DAC convertor for generating waveforms such as sine wave, triangular wave, saw tooth wave and square wave was written and executed successfully and the output was verified.
Exp no:12 Interfacing of Timer with 8086 Microprocessor kit. Aim: To write an Assembly Language Program for Interfacing of Timer with 8086 Microprocessor kit.
Apparatus Required: Microprocessor kit, Power cable, Timer kit and Data cable.
Algorithm:
1. Start the program. 2. Move the counter value to AL either it may be even or odd and write the AL value to output port. 3. Move the highest value (10h) to AL either it may be even or odd and write the AL value to output port. 4. Move the initial value (00h) to AL either it may be even or odd and write the AL value to output port. 5. Stop the program.
Program: Mov AL, 36h Out C8, AL Mov AL, 10h Out C8, AL Mov AL, 00h Out C8, AL HLT.
Result: Thus, the assembly language program in 8086 microprocessor interface with timer was written and executed successfully and the output was verified.
View more...
Comments