Upload
narayananmeera07
View
268
Download
2
Embed Size (px)
Citation preview
7/29/2019 Masm Procedure
1/23
PC PROGRAMMING WITH ASSEMBLY LANGUAGE USING
MASM
Procedure:
1. Open command window (click: start->run->type cmd )
2. Paste the 8086 or MASM software in any drive
7/29/2019 Masm Procedure
2/23
3. In that window change the directry
7/29/2019 Masm Procedure
3/23
4.In the command window type the directory name after that change thedirectory to 8086(masm) after that type edit
7/29/2019 Masm Procedure
4/23
5.After changing directory type edit then you get one window in that
window you can write a program
7/29/2019 Masm Procedure
5/23
6.After writing a program click: file->save->exit [again we enter the
commond window]
7.Type : masm filename,,; [this will display the error report]
7/29/2019 Masm Procedure
6/23
8.Type: link filename,,; [This will create a list file you can see thisinside the masm(8086)software]
Note : Here we no need to use stack segment so no need to worry about
stack error
7/29/2019 Masm Procedure
7/23
8.Type : debug filename.exe [to create exe file]
7/29/2019 Masm Procedure
8/23
9.type: n filename.bin[to create a bin file]
7/29/2019 Masm Procedure
9/23
10.type : wcs:1000 [writing code segment]
7/29/2019 Masm Procedure
10/23
11.type:g =1000[to execute a program]
7/29/2019 Masm Procedure
11/23
12.type: u 1000[to see opcode]
7/29/2019 Masm Procedure
12/23
13.type : e 1200[see output in corresponding address] use space bar to see
next output value
7/29/2019 Masm Procedure
13/23
15.type: q [terminate a line]
7/29/2019 Masm Procedure
14/23
16. down loading procedure
Note: dont use these command while down loading
Mov ah, 4ch [These commands are used to see the results system itself]Int 21h
( bin file is used to down loading )
Type: dc then you can get the following window
7/29/2019 Masm Procedure
15/23
17. press f1 key and set the portsetings
7/29/2019 Masm Procedure
16/23
18.press esc key to abort
19.now in micro 86 kit select receiving mode(ie) type si 1000(starting
address) then press enter key. Then the kit is ready to receive data and
press any in the host to start transmission. During transmisson the
message display as ,
transmission progress.
Press esc to abort.
Now binary files are downloaded to kit.
7/29/2019 Masm Procedure
17/23
Write an alp to display a string in the monitor
Code segment
Assume cs: code, ds: code
Org 1000hMov ah, 09h
Mov dx, 1200h
Int 21h
Mov ah, 4ch
Int 21h
Org 1200h
Db VI micro$
Code ends
End------------------------------------------------------------------------------------------------------------------
Write an alp to read scan code and character code from a keyboard
Code segment
Assume cs: code, ds: code
Org 1000h
Mov ah, 0h
Int 16h
Mov si, 1200h
Mov [si], al
Inc si
Mov [si], ah
Mov ah, 4ch
Int 21h
Code ends
End
-----------------------------------------------------------------------------------------
7/29/2019 Masm Procedure
18/23
File manipulation:
File creation
code segment
assume cs:code,ds:code
org 1000hmov 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 'vi.asm'
data ends
end
Create a file in a different directory:
code segment
assume cs:code,ds:code
org 1000hmov ax,data
mov ds,ax
mov ah,5bh
mov dx,1200h
mov cx,0
int 21h
mov ah,4ch
int 21h
code ends
data segment
org 1200h
db 'e:\man\v.asm'
data ends
end
7/29/2019 Masm Procedure
19/23
File rename[Find and replace]
code segment
assume cs:code,ds:data,es:data
org 1000h
mov ax,datamov ds,ax
mov es,ax
mov dx,1300h
mov [di],1500h
lea dx,oldname
lea di,newname
mov ah,56h
int 21h
mov ah,4ch
int 21h
code ends
data segment
org 1300h
oldname db 'vi.txt'
org 1500h
newname db 'service.txt'
data ends
end
File deletion
code segment
assume cs:code,ds:code
org 1000h
mov ax,data
mov ds,ax
mov ah,41h
mov dx,1200h
int 21h
mov ah,4ch
int 21h
code ends
data segment
org 1200h
7/29/2019 Masm Procedure
20/23
db 'vi.asm'
data ends
end
---------------------------------------------------------------------------------------------------------
Write an alp to writing datas to a file
code segment
assume cs:code,ds:data
org 1000h
mov ax,data
mov ds,ax
mov ah,3dh
mov al,01h
lea dx,filename
int 21h
mov si,1500h
mov [si],ax
mov ah,40h
lea dx,buffer
mov cx,0050h
mov bx,[si]
int 21hmov ah,3eh
int 21h
mov ah,4ch
int 21h
code ends
data segment
org 1300h
filename db 'vi.txt'
org 1400h
buffer db 'vimicro systems'
data ends
end
7/29/2019 Masm Procedure
21/23
Write an alp to send an 8 bit data to serial port
code segment
assume cs:code,ds:code
org 1000hmov ah,00h
mov dx,0
mov al,0e2h
int 14h
mov ah,01h
mov al,"A"
mov dx,0
int 14h
mov ah,4chint 21h
code ends
end
The baud rate is 9600 bps
The number of the port is defined in register DX
Print a character using Pc's parallel port with dos calls
code segment
assume cs:code,ds:code
org 1000h
mov ah,00h
mov dx,0mov al,"A"
int 17h
mov ah,4ch
int 21h
code ends
7/29/2019 Masm Procedure
22/23
end
Write an alp to read the CMOS time using dos calls
code segment
assume cs:code,ds:code
org 1000hmov ah,02h
int 1ah
mov si,1200h
mov [si],ch
inc si
mov [si],cl
inc si
mov [si],dh
mov ah,4ch
int 21h
code ends
end
Write an alp to create a directory using dos calls
code segment
assume cs:code,ds:data
org 1000h
mov ax,data
mov ds,ax
mov ah,39h
mov dx,1200h
int 21h
mov ah,4ch
int 21h
code ends
data segment
org 1200h
db 'man'
data ends
end
7/29/2019 Masm Procedure
23/23
Write an alp to show the mouse pointer in the dos window screen
code segment
assume cs:code,ds:data
org 1000h
mov ax,1
int 33h
mov ah,4ch
int 21h
code ends
end
Addition: code segment
assume cs:code,ds:code
org 1000h
mov ax,1234h
mov bx,1234h
add ax,bx
mov si,1200h
mov [si],ax
mov ah,4ch
int 21h
code ends
end
Result:
e 1200=68 24