how to work in 8086 -...
TRANSCRIPT
![Page 1: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/1.jpg)
1
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
Year & Sem : II & III
Name of the Subject: MC-9238 Microprocessor Lab Branch : MCA
HOW TO WORK IN 8086:
Press asm twice.
Type sg 0000
Press enter
Type da starting address (4000)
Press enter
Press new(n)
Give one space and type the mnemonic.
Press enter once and new(n) twice.
After completing the program, press shift + 1 (!)
To give input value: press exam byte(e) for 8 bit data. Give the location, type the data and
press next.
Press exam word (w) fro 16 bit data. Give the location, type the data and press next.
To execute the program : press go(g).
Give the starting address of the main program.
Press enter.
To view the result : press exam byte(e) for 8 bit data. Enter the location of the output.
![Page 2: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/2.jpg)
2
Press exam word (w) for 16 bit data. Enter the location of the output.
Press e and r, to view the value stored in the register.
To display the program : press asm and type di space starting address space ending
address. Press enter.
To edit the program : press asm and give the corresponding address of the mnemonics to be
modified. Type the mnemonic and press enter.
8086 PROGRAMS
ARITHMETIC OPERATION
ADDITION PROGRAM:
MOV CX, 0000
MOV AX, [4200]
MOV BX, [4202]
ADD AX, BX
JNC LI
INC CX
LI: MOV [4206], CX
MOV [4204], AX
INT 0003
![Page 3: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/3.jpg)
3
SUBTRACTION PROGRAM:
MOV CX, 0000
MOV AX, [4200]
MOV BX, [4202]
SUB AX, BX
JNC LI
INC CX
LI: MOV [4206], CX
MOV [4204], AX
INT 0003
DIVISON PROGRAM:
MOV AX, [4200]
MOV BX, [4202]
DIV BX
MOV [4206], AX
MOV AX, DX
MOV [4208], AX
INT 0003
![Page 4: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/4.jpg)
4
MULTIPLICATION PROGRAM:
MOV AX, [4200]
MOV BX, [4202]
MUL BX
MOV [4206], AX
MOV AX, DX
MOV [4208], AX
INT 0003
LOGICAL OPERATION:
AND
MOV AX, [4100]
MOV BX, [4102]
AND AX, BX
MOV [4500], AX
INT 0003
OR
MOV AX, [4100]
MOV BX, [4102]
OR AX, BX
MOV [4500], AX
INT 0003
![Page 5: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/5.jpg)
5
NOT
MOV AX, [4100]
NOT AX
MOV [4500], AX
INT 0003
SUBROUTINE - PROGRAM:
MOV AX, 3231
CALL ADDITION
PUSH AX
MOV CX, AX
INT 3
ADDITION: ADD AX, 4135
PUSH AX
MOV BX, 5314
POP AX
ADD AX, BX
RET
Observation:
Output: Register A
![Page 6: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/6.jpg)
6
PROGRAM TO ACCESS STACK:
MOV AX, 3231
ADD AX, 4135
PUSH AX
MOV BX, 5314
POP AX
ADD AX, BX
MOV CX, BX
PUSH CX
INT 3
Observation: Output: Register A
PROGRAM TO FIND THE FACTORIAL OF A NUMBER:
MOV SI, 5000
MOV DI, 7000
MOV CX, [SI]
MOV AX, CX
DEC CX
AGAIN: MUL CX
DEC CX
JNZ AGAIN
MOV [DI], AX
INT 3
Observation: Input: at 5000 Output : at 7000
![Page 7: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/7.jpg)
7
PROGRAM TO FIND SQUARE ROOT OF A PROGRAM:
MOV SI, 5000
MOV DI, 7000
MOV CX, 0001
MOV BX, 0000
MOV AL, [SI]
UP: SUB AL, CL
JL STORE
INC BL
ADD CL, 02
JMP UP
STORE: MOV [DI], BL
INT 3
Observation:
Input : at 5000
Output : at 7000
![Page 8: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/8.jpg)
8
PROGRAM TO SORT THE NUMBERS IN DESCENDING ORDER:
MOV AH, O8H
DEC AH
LOOP3: MOC CL, AH
MOV BX, 4100H
LOOP2: MOV AL, [BX]
INC BX
CMP AL, [BX]
JNC LOOP1
MOV DL, [BX]
MOV [BX], AL
DEC BX
MOV [BX], DL
INX BX
LOOP1: DEC CL
JNZ LOOP2
DEC AH
JNZ LOOP3
INT 3
Observation:
Input : From 4100 to 4107
Output : From 4100 to 4107
![Page 9: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/9.jpg)
9
PROGRAM TO SORT THE NUMBERS IN ASCENDING ORDER:
MOV AH, O8H
DEC AH
LOOP3: MOC CL, AH
MOV BX, 4100H
LOOP2: MOV AL, [BX]
INC BX
CMP AL, [BX]
JC LOOP1
MOV DL, [BX]
MOV [BX], AL
DEC BX
MOV [BX], DL
INX BX
LOOP1: DEC CL
JNZ LOOP2
DEC AH
JNZ LOOP3
INT 3
Observation:
Input : From 4100 to 4107
Output : From 4100 to 4107
![Page 10: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/10.jpg)
10
STRING OERATION (copy string):
MOV SI, 4200
MOV DI, 4300
MOV CX, 0004
CLD
L1: MOVSB
LOOP L1
INT 0003
Observation:
Input : 4200
Output : 4300
![Page 11: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/11.jpg)
11
SEARCHING A STRING OERATION:
MOV SI, 4200
MOV DI, 4300
MOV CX, 0006
CLD
MOV AL, 0008
L1: SCASB
LOOP L1
DEC DI
MOV BL, [DI]
MOV [SI], BL
INT 0003
Observation:
Input : 4200
Output : 4300
![Page 12: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/12.jpg)
12
HOW TO WORK IN 8085:
Press ASM.
Enter the starting address (8000).
Press next (,).
Type the mnemonic.
Press enter twice.
After completing the program, press esc.
To give input data : press memory(m).
Type the location. Enter data.
Press next for each data to save.
Press esc.
To execute the program : press go (g).
Enter the starting address of the main program.
Press enter.
To view the output: press memory (m).
Give the location of the result.
Press next to see the subsequent output.
To view the program : press disp(z).
Give the starting and the ending address of the program.
Press next.
To edit the program : Press Asm and enter the corresponding address of the mnemonic to
be modified.
![Page 13: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/13.jpg)
13
TRAFFIC LIGHT DESIGN USING 8255:
START: MVI A, 80H ADDRESS:
OUT 33
CALL DELAY
MVI A, 07H
OUT 30
MVI A, 08H
OUT 31
CALL DELAY
MVI A, 0BH
OUT 30
MVI A, 04H
OUT 31
CALL DELAY
MVI A, 0DH
OUT 30
MVI A, 02H
OUT 31
CALL DELAY
MVI A, 0EH
OUT 30H
MVI A, 01H
OUT 31
CALL DELAY
N-TO S 07,08
E-TO-W 0B,04
W-TO-E 0D,02
S-T0-N 0E,01
![Page 14: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/14.jpg)
14
JMP START
DELAY: LXI D, FFFFH
LOOP : DCX D
MOV A, E
ORA D
JNZ LOOP
RET
Interfacing connection : Through P6.
STEPPER MOTOR INTERFACING USING 8255(8086 KIT):
MOV AL, 80H
MOV DX, 0FFC6
OUT DX, AL
START: MOV AL, 09H
MOV DX, OFFC4
OUT DX, AL
CALL DELAY
MOV AL, 0CH
MOV DX, 0FFC4
OUT DX, AL
CALL DELAY
MOV AL, 06H
MOV DX, 0FFC4
PORT A=0FFCOH
PORT B=0FFC2H
PORT C=0FFC4H
CONT.REG=0FFC6H
CLOCKWISE ANTI-CLOCKWISE
O9 O3
OC 06
06 0C
03 09
![Page 15: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/15.jpg)
15
OUT DX, AL
CALL DELAY
MOV AL, 03H
MOV DX, 0FFC4
OUT DX, AL
CALL DELAY
JMP START
DELAY: MOV DI, 02H
LOOP 1: MOV CX, 0FFFFH
LOOP 2: LOOP LOO2
DEC DI
JNZ LOOP 1
RET
Interfacing connection: Through P3.
8253 INTERFACING WITH 8085:
MVI A, 36H (Counter0, mode3) ADDRESS:
OUT 33
MVI A, 00H
OUT 30
MVI A, 3C
OUT 30
RST 1
COUNTER 0 : 30H
COUNTER1 : 31H
COUNTER2 : 32H
CONTROL REG : 33H
![Page 16: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/16.jpg)
16
Interfacing Connection:
Through P6.
Output:
In TCON1: Pin 1 :: + ve
Pin 4 :: - ve
DAC INTERFACING WITH 8085(SAWTHOOTH WAVE FORM):
MVI A, 80H
OUT DBH
MVI A, 00
LOOP: INR A
OUT D8
JNZ LOOP
Interfacing connection:
Through P3.
OUTPUT:
In JP4, out1 :: + ve
Gnd :: Gnd
PORT A : D8H
PORT B : D9H
PORTC : DAH
Control Reg : DBH
![Page 17: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/17.jpg)
17
ADC PROGRAMMING:
;NIFC07A WITH 85MEL. ADC POLLED MODE
ORG E000H ADDRESS:
LXI H, CHANNEL
MOV A, M
STA TEMP
MVI H, 00
MOV L, A
SHLD FFF7H
MVI A, 87H
AD00: MVI A, 90H
OUT CTL_PORT
LDA TEMP
OUT PORTC
MVI A, 0FH
OUT CTL_PORT
LXI D, 0AH
CALL DELAY
MVI A, 0EH
OUT CTL_PORT
MVI A, 0CH
OUT CTL_PORT
AD01: IN PORTA
ANI 80H
CPI 80H
JNZ AD01
MVI A, 0DH
OUT CTL_PORT
IN PORTA
PORTA : D8H
PORT B : D9H
PORT C : DAH
CTRL_PORT : DBH
UPDDT : 07D1H
CLR_DSP : 14A9H
LBL5 : 0042H
TEMP : F202H
CHANNEL : E100H
![Page 18: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/18.jpg)
18
STA FFF9H
MVI A, C7H
STA FFC2H
CALL UPDDT
CALL DELAY
JMP AD00
DELAY: LXI D, 1FFFH
BLOOP: DCX D
MOV A, D
ORA E
JNZ BLOOP
RET
RST 1
Interfacing Connection:
Through P3.
Input:
At E100 : give channel number as 07 to choose channel 8.
Output:
In IC0809, Pin 13 :: Gnd
Pin 12 :: VRef
Pin 5 :: VAin
![Page 19: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/19.jpg)
19
DC MOTOR SPEED CONTROLLER USNG 8085:
MEMORY
ADDRESS
OPCODE PROGRAM
8100 21 00 82 LXI H,8200
8103 3E 36 MVI A,36H
8105 D3 0B OUT 0BH
8107 7E MOV A, M
8108 D3 08 OUT O8H
810A 23 INX H
810B 7E MOV A, M
810C D3 08 OUT 08H
810E 76 HLT
MODE OF OPERATION:
8200=20H
8201=20H
FAST
8200=AAH
8201=AAH
SLOW
![Page 20: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/20.jpg)
20
8279 INTERFACING WITH 8085(KEYBOARD/DISPLAY):
MVI A, 00H (if left entry 00 ; if right entry means 10)
OUT 31
MVI A, 31H
OUT 31
L2: MVI A, D0H
OUT 31
CALL DELAY
MVI A, 90H
OUT 31
LXI H, 8800
MVI C, 08H
L1: MOV A, M
OUT 30
CALL DELAY
INX H
DCR C
JNZ L1
CALL DELAY
JMP L2
RST 1
DELAY: MVI B, FFH
HERE2: MVI D, FFH
HERE1: DCR D
![Page 21: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/21.jpg)
21
JNZ HERE1
DCR B
JNZ HERE2
RET
Interfacing connection:
Through P6.
Input: From 8800 to 8807
![Page 22: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/22.jpg)
22
MASM SOFTWARE PROGRAMS
FILE MANIPULATION
FILE CREATION PROGRAM:
code segment
Assume cs:code,ds:code
org 1000h
mov ax,data
mov ds,ax
mov ah,3ch
mov cx,0000h
mov dx,1200h
INT 21h
mov ah,4ch
INT 21h
code ends
data segment
org 1200h
db'file.asm'
data ends
end
FILE DELATION PROGRAM:
code segment
Assume cs:code,ds:code
org 1000h
mov ax,data
mov ds,dx
mopv ah,41h
mov dx,1200h
int 21h
code ends
data segment
org 1200h
db'v1.asm '
data ends
end
![Page 23: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/23.jpg)
23
FILE RENAME PROGRAM:
code segment
Assume cs:code,ds:data,es:data
org 1000h
mov ax,data
mov dx,ax
mov es,ax
mov dx,1300h
mov[di],1500
lea dx,oldname
lea di.newname
mov ah,56h
int 21h
mov ah,4ch
int 21h
code ends
data segment
org 1300h
oldname db'file.txt'
newname db'file1.txt'
data ends
end
FILE MANIPULATION (writing into a file):
code segment
Assume cs:code,ds:data
org 1000h
mov dx,data
mov ds,ax
mov ah,3dh
mov a1,01h
lea dx,filename
int 21h
mov s1,1500h
mov s1,1500h
mov[s1],ax
mov ah,40h
lea dx,buffer
![Page 24: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/24.jpg)
24
mov ex,0050h
mov bx,[s1]
int 21h
mov ah,3ch
int 21h
mov ah,4ch
int 21h
code ends
data segment
org 1300h
filename db'vi.txt'
org 1400h
buffer db'vimicrosystems' data ends
end
![Page 25: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/25.jpg)
25
TERMINATE AND STAY RESIDENT (TSR) PROGRAM:
display EQU xxxxh
Screen EQU 0600h
delay1 EQU 10
.code
main PROC
in ax, Screen ; get screen status
push ax ; save status
mov dx,184Fh ;lower right corner (24,79)
mov bh,7 ; normalattribute
int 10h ; callBIOS
mov ah,2 ; locate cursor at0,0
mov bh, 0x7920 ; ASCII write green asforeground
L2: out display, ax ; create a delay loop
mov cx,delay1;
L3: push cx
L3a: loop L3a
pop cx
loop l3
sub al,1 ;raise time 1 sec
jnz L2
pop ax
exit
main ENDP
END main
![Page 26: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/26.jpg)
26
ASSEMBLY LANGUAGE PROGRAMS USING ‘C’
The program prompts the user to enter the name of the subdirectory to be created. This name is
stored in the variable newdir. DX is loaded with address of newdir. Thus DX points to the
subdirectory name. Then DOS function call 39H is invoked to create the subdirectory.
If the carry flag is 0, it means that an error occurred during the creation of the subdirectory. In
such a case, a suitable error message is displayed on the CRT. If the carry flag is 0, it means that
the creation of the subdirectory was successful. In such a case, an appropriate success message
is displayed on the CRT.
PROGRAM:
#include <dos.h>
union REGS inregs,outregs;
char newdir[10];
void main()
{
printf("enter directory name \n");
scanf("%s",newdir);
inregs.x.dx=(int) &newdir;
inregs.h.ah=0x39;
intdos(&inregs,&outregs);
if(outregs.x.cflag!=0)
printf("ERROR!!.directory %s not created\n",newdir);
else
printf("Directory %s created in current directory\n",newdir);
}
OUTPUT:
Enter directory name : Sha
Directory Sha created in current directory.
![Page 27: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/27.jpg)
27
String Replace
data segment
str db 'heffo$'
find db 'f'
repl db 'l'
count db 05h
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov es,ax
k:mov cl,count
mov al,find
mov di,offset str
cld
repne scasb
mov al,repl
jz loop1
mov dx,offset str
mov ah,09h
int 21h
jmp e
loop1:dec di
stosb
jmp k
mov dx,offset str
mov ah,09h
int 21h
e: mov ah,4ch
int 21h
code ends
end start
![Page 28: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/28.jpg)
28
String Copy
data segment
source db 'a','b','c'
des db 'g','h','i'
count db 03h
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov es,ax
mov si,offset source
mov di,offset des
mov cl,count
cld
rep movsb
hlt
code ends
end start
String Length
data segment
src db 'preethi'
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov di,offset src
mov al,00h
a:mov bl,[si]
cmp bl,00h
je h
jmp b
b:inc al
inc si
jmp a
![Page 29: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/29.jpg)
29
h:hlt
code ends
end start
FILE MANIPULATION – CREATE A FILE
assume cs:code,ds:data
data segment
fn db 'new.asm','$'
data ends
code segment
org 1000h
mov ax,data
mov dx,ax
mov dx,offset fn
mov cx,00h
mov ah,3ch
int 21h
mov ah,4ch
int 21h
code ends
end
![Page 30: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/30.jpg)
30
FILE MANIPULATION – WRITE A FILE
assume cs:code,ds:data
data segment
dabk db '1','2','3','4'
fn db 'new.asm'
data ends
code segment
org 1000h
mov ax,data
mov ds,ax
mov dx,offset fn
mov ah,3ch
int 21h
mov bx,ax
mov cx,10h
mov dx,offset dabk
mov ah,40h
int 21h
mov ah,4ch
int 21h
code ends
end
![Page 31: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/31.jpg)
31
LINEAR SEARCH:
Code segment
Assume cs:code,ds:data
Mov bx,1100h
Mov si,1102h
Mov cx,[si]
Add si,02h
Mov di,3000h
L2: mov ax,[si]
Cmp [bx],ax
Jz L1
Add si,02h
Loop L2
Jmp L3
L1: mov ax,1111h
Jmp L4
L3: mov ax,0000h
L4: mov [di],ax
Mov ah,4ch
Int 21h
Code ends
End
![Page 32: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/32.jpg)
32
OUTPUT:
-e 1100
: 1100 00.89
-e 1102
:1102 00.15 00.65 00.63 00.89 00.56
-g
Program terminated normally.
-e 3000
:3000 11.11
SORTING:
Code segment
Assume cs:code,ds:data
CLC
L2: mov bx,0000h
Mov si,2001h
Mov cx,[si]
Dec cx
Add si,02h
L1: mov ax,[si]
Cmp ax,[si+02]
Jc L
Xchg ax,[si+02]
Mov [si],ax
Mov bx,0001h
![Page 33: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/33.jpg)
33
L: add si,02h
Loop L1
Dec bx
Jz L2
Mov ah,4ch
Int 21h
Code ends
OUTPUT:
-e 2001
:2001 00.05 00.00
-e 2003 .05 .00 .04 .00 .03 .00 .02 .00 .01 .00
-g
Program terminated normally
-e 2003
:2003 01. 00. 02. 00. 03.
:2008 00. 04. 00. 05.
MATRIX MULTIPLICATION:
code segment
assume cs:code
start: mov si,1000h
mov di,2000h
mov bp,3000h
a: mov al,[si]
mov bl,[di]
mul bl
mov bh, al
mov al,[si+1]
mov bl,[di+2]
![Page 34: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/34.jpg)
34
mul bl
add al, bh
mov [bp],al
inc di
inc bp
mov al,[si]
mov bl,[di]
mul bl
mov bh, al
mov al,[si+1]
mov bl,[di+2]
mul bl
add al,bh
mov [bp],al
inc bp
inc si
inc si
dec di
loop a
int 3h
code ends
end start
OUTPUT:
-u
-e ds : 1000
01 01 01 01
-e ds : 2000
01 01 01 01
-g = cs:0000 0049
-d ss:3000
02 02 02 02
![Page 35: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/35.jpg)
35
TSR Program:
#include"dos.h"
#include<conio.h>
#include<stdio.h>
//interrupt declarations
void interrupt (*prevtimer)();
void interrupt mytimer();
void writechar(char ch,int rows, int cols, int attr);
//a far pointer that will decrease video memory
char far *scr;
int a,b;
//our real program goes from here
void main()
{
scr=(char far*)0xb8000000;
prevtimer=getvect(8);
setvect(8,mytimer);
keep (0,1000);
}
//timer function
void interrupt mytimer()
{
a=random(25);
b=random(80);
writechar(' ',a,b,0);
(*prevtimer)();
}
//function that writes picked up character
void writechar(char ch,int row, int col, int attr)
{
*(scr+row*160+col*2)=ch;
*(scr+row*160+col*2+1)=attr;
}
![Page 36: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/36.jpg)
36
Study of BIOS and DOS function calls for keyboard & Display interfacing
KEY BOARD BIOS assume cs:code,ds:data
data segment
msg db "Welcome to keyboard program",0ah,"$"
data ends
code segment
start: mov ax,data
mov ds,ax
mov dx,offset msg
mov ah,09h
int 21h
wait: mov ah,01h
int 16h
jz wait
mov ah,00h
int 16h
mov ah,0eh
int 10h
cmp al,1bh
je exit
jmp wait
exit: mov ax,4c00h
int 21h
ret
code ends
end start
![Page 37: HOW TO WORK IN 8086 - chettinadtech.ac.inchettinadtech.ac.in/storage/12-10-26/12-10-26-15-41-59-1476... · how to work in 8086: press asm twice. type sg 0000 ... program to find square](https://reader034.vdocuments.site/reader034/viewer/2022051307/5aba86ab7f8b9a76038b98a3/html5/thumbnails/37.jpg)
37
DISPLAY BIOS
assume cs:code,ds:data
data segment
msg db "AaddsfDSs",0
data ends
code segment
start: mov ax,data
mov ds,ax
mov bx,offset msg
next: mov al,[bx]
cmp al,0
je stop
mov ah,0eh
int 10h
inc bx
jmp next
stop: mov ax,4c00h
int 21h
code ends
end start
*****ALL THE BEST*****