Categories
- 4th semester (27)
- 5th semester (3)
- ADA (13)
- Assembly Level Language (12)
- BE (45)
- C Language Programming (5)
- C language (20)
- C++ Language (5)
- CCP Lab programing (3)
- Computer Programming Lab (3)
- DAA Lab Programming (13)
- Data Structure and C++ laboratory Program (6)
- Data Structure and C++ labotary Program (5)
- Design and Analysis of algorithm (14)
- First Year (5)
- MASM (12)
- Microprocessor (12)
- Microprocessor lab program (12)
- System Software & OS Laboratory (5)
- Unix program (4)
- bachelor of engineering (30)
- basic (1)
- basic mathematics (2)
- beginners (10)
- c++ program (9)
- calculations (7)
- computer science (30)
- downloadable (5)
- engineering syllabus (4)
- simple program (6)
Trend Posts
Blogger news
Author
Followers
Showing posts with label Microprocessor lab program. Show all posts
Showing posts with label Microprocessor lab program. Show all posts
Friday, February 21, 2014
ASSUME DS: DATA, CS: CODE
DATA SEGMENT
FILEC DB 'D:\MPLAB\SEM4.TXT$', 0 ;FILEC array is
declared to create a file SEM4.txt in D
; directory under MPLAB folder.
FILED DB 'D:\MPLAB\123.TXT$', 0 ;FILED array is declared to delete a file123.txt
which is
;already
created in D directory under MPLAB
folder.
MSG1 DB 0AH, 0DH, 'FILE IS CREATED', '$'
MSG2 DB 0AH, 0DH, 'FILE IS NOT CREATED', '$'
MSG3 DB 0AH, 0DH,'FILE IS DELETED', '$'
MSG4 DB 0AH, 0DH,'FILE IS NOT DELETED', '$'
MSG5 DB 0AH, 0DH,'CREATED FILE IS : ', '$'
MSG6 DB 0AH, 0DH,'DELETED FILE IS : ', '$'
DATA ENDS ; end of data
segment
DISP MACRO MSG ; DISP macro definition starts
MOV DX, OFFSET MSG ; display the message whose offset is in
DX
MOV AH, 09H ; using 09H with DOS 21H interrupt.
INT 21H
ENDM ; end of macro
definition
CODE SEGMENT
START: MOV AX, DATA ; data segment
initialization
MOV DS, AX
MOV DX, OFFSET FILEC ; DX: offset address of
FILEC array containing the drive,
;directory path and filename to be
created.
MOV CX, 00 ; CX
is cleared indicating no attributes for the file. (read only)
MOV AH, 3CH ; service no. to create file with DOS 21H
interrupt
INT 21H ; file is created
JC NOTCRE ; if carry flag is set to 1, it
indicates that file is not created,
;
then jump to
label NOTCRE
DISP MSG1 ; otherwise invoke the macro to display MSG1 (created)
DISP MSG5 ; invoke the macro to display MSG5
(created file is)
DISP FILEC ;invoke the macro
to display FILEC
array contents.
JMP NEXT ;
jump
to label NEXT to delete the file.
NOTCRE: DISP
MSG2 ; invoke
the macro to display MSG2 (file is not created)
NEXT:
MOV DX, OFFSET FILED ;DX: offset address of FILED array containing the drive,
; directory path and filename to be
deleted.
MOV AH, 41H ; service
number to delete a file with DOS 21 H interrupt
INT 21H ; file is deleted
JC NOTDEL ; if carry flag is set to 1, it
indicates that file is not deleted,
;
jump to label NOTDEL
DISP MSG3 ; invoke the macro to display MSG3
(file is deleted)
DISP MSG6 ; invoke the macro to display MSG6
(deleted file is)
DISP FILED ;invoke the macro to display FILED array contents.
NOTDEL:DISP MSG4 ;
invoke
the macro to display MSG4 (file is
not deleted)
EXIT: MOV AH, 4CH ; terminate the program
INT 21H
CODE ENDS ; end
of code segment
END START ; end
of program
Output:
D:\MASM>
Masm 12a.asm;
D:\MASM>
Link 12a.obj;
ASSUME DS: DATA, CS: CODE
DATA SEGMENT ; data segment starts
MSG2 DB 0AH, 0DH, "ENTER COLUMN NO.:
","$"
ROW DB ? ; variable is
declared to store the row value
COL DB ? ; to store the column value
DATA ENDS
DISPLAY MACRO MSG ; Display macro definition
MOV DX, OFFSET MSG
MOV AH, 09H ; display the message using 09H with 21h
DOS interrupt
INT 21H
ENDM ; end of macro
definition
CODE SEGMENT
START
:
MOV AX, DATA
MOV DS, AX ;
data segment initialization
DISPLAY MSG1 ; invoke the macro to display MSG1
CALL READ ; call read procedure to read 2 digit BCD
number (Row no.)
MOV ROW, AL ;
store the 2 digit row number in ROW
variable
DISPLAY MSG2 ; invoke the macro to display MSG2
CALL
READ ; call read procedure to read 2 digit BCD
number (column no.)
MOV COL, AL ; store the 2 digit column number in COL
variable
MOV
AH, 07H ; BIOS
service number to clear the screen
MOV AL, 00H ; Number of lines to scroll; 00 blank screen.
MOV BH, 0FH ; attribute of character; 0F white and 00 black
MOV CX, 00H ; CH=00 Y coordinate of upper left corner and CL=00
X
; coordinate of upper right corner
MOV DH, 35H ; Number of rows; Lower right row
MOV DL, 79H ; Number of rows; Lower right row
INT
10H ; BIOS interrupt to clear the screen is
invoked
MOV
AH, 02H ;BIOS service number
to set the cursor
MOV BH, 00H ; set video Page number to 0
MOV DH, ROW ; store
row number in DH (Y coordinate)
MOV DL, COL ; store
the column number (X) in DL register
INT
10H ; BIOS interrupt to set the cursor is
invoked
CALL
DELAY ; call delay
procedure to set the cursor at specified location.
MOV AH, 4CH ; terminate the program
INT 21H
READ
PROC NEAR ; start of READ procedure
MOV AH, 01H ; read a character
from keyboard using 01H service no with
INT 21H ; DOS 21H interrupt.
SUB AL, 30H ; subtract 30H
from AL (ASCII
code of user entered 1st character)
MOV BL, 10 ; store the
decimal number 10 in BL
MUL BL ; multiply BL content with AL and the result is stored in AL
MOV BL, AL ; copy the result
in AL to BL.
MOV AH, 01H
INT 21H ; read
the next character from keyboard using 01H with DOS 21H
SUB AL, 30H ; subtract 30H
from AL (ASCII
code of user entered 2nd character)
ADD AL, BL ; add AL and BL content to get the actual 2 digit number in AL.
RET ; return to calling program
READ ENDP ; end of procedure
DELAY PROC NEAR ; DELAY procedure starts
MOV DX, 0FFFFH
B2: MOV CX, 0FFFFH ; outer and inner
loop counter values stored in DX and CX
B1: LOOP B1
DEC DX
JNZ B2
RET
DELAY ENDP ; end
of delay procedure.
CODE ENDS ; end of code segment
END
START ; end of program
Output:
D:\MASM>
Masm 11a.asm;
D:\MASM>
Link 11a.obj;
D:\MASM>
11a.exe
Subscribe to:
Posts (Atom)