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
Blog Archive
-
▼
2014
(37)
-
▼
February
(12)
- a program to create a file (input file) and to del...
- Read a pair of input co-ordinates in BCD and move ...
- Write a program to simulate a Decimal Up-counter t...
- Read the current time from the system and display ...
- Compute nCr using recursive procedure. Assume that...
- Read your name from the keyboard and display it at...
- Read two strings, store them in locations STR1 and...
- Reverse a given string and check whether it is a p...
- Read an alphanumeric character and display its equ...
- Sort a given set of ‘n’ numbers in ascending order...
- Write two ALP modules stored in two different file...
- Search a key element in a list of ‘n’ 16-bit numbe...
-
▼
February
(12)
Friday, February 21, 2014
File 1: A file which contains Macro definition to
read a character from keyboard. (give the file name as Read.asm)
INPUT MACRO ;
macro definition
starts, with name of the macro as Input
MOV
AH, 01H ;
Service number
(function no.) to read a character from the
INT
21H ;
Key board using DOS interrupt (21H)
ENDM ;
terminate
the macro definition.
File 2: A file which contains Macro definition to
display a character on the monitor. (give the file name as display.asm)
PRINT MACRO ; macro definition starts, with name of
the macro as Print
MOV
AH, 02H ;
Service number
(function no.) to display a character on
INT
21H ; the
monitor using DOS interrupt (21H)
ENDM ;
terminate
the macro definition.
File 3: A file which include the above 2 files
created, in code segment and contains the macro expansion statements and other
instructions to read string of characters until the carriage return is pressed
and also display the string on the monitor.
(give the file name as 2a.asm)
ASSUME
DS: DATA,
CS: CODE
DATA
SEGMENT ; start of data segment
STR
DB 100 DUP (' '), '$' ; To store input (user entered)
string in array STR
MSG1
DB
'ENTER
A SENTENCE : ‘, '$'
;
store
the message enter a sentence in array
MSG1
MSG2
DB 0DH, 0AH, 'ENTERED SENTENCE
IS: ',
'$' ;
store
the message in array MSG2.
DATA
ENDS ;
End
of data segment
CODE
SEGMENT ; start of code segment
INCLUDE READ.ASM ; including
external file (read.asm)
INCLUDE
DISPLAY.ASM ;
including
external file (display.asm)
START: MOV
AX, DATA
MOV
DS, AX ;
initializing data segment
XOR
AX, AX ; clear AX
register content
MOV
SI, OFFSET STR ;
store the offset
address of memory STR in SI register
MOV
DX, OFFSET MSG1 ; store the offset address of
memory MSG1 in DX
MOV
AH, 09H ;
display the message stored in array memory MSG1
INT 21H ; using service
no.09H, in DOS interrupt (21H)
AGAIN: INPUT ;
invoke
macro (input) to read character from keyboard
CMP
AL, 0DH ;
compare
end of string ie: whether the
entered key is enter key
JE
DISP ; if yes terminate the read process and go to DISP to display
; the
user entered string stored in array STR
on the monitor.
MOV
[SI], AL ; otherwise store
character in array STR.
INC
SI ; increment the STR
memory ptr by one 1 to point
;
to the next memory location (ie: STR+1)
JMP
AGAIN ; go to AGAIN location ,to read the next character from
keyboard DISP
:
MOV AL,0AH
MOV
[SI], AL ; store
the ASCII code 0AH in last memory
location of STR array
MOV
DX, OFFSET MSG2 ; store the offset of memory MSG2 in DX MOV AH, 09H ; display
the message in MSG2 using 09H in DOS
interrupt.
INT 21H
MOV
SI, OFFSET STR ; store offset address of STR in SI
register (memory address
; of 1st location in STR array )
BACK :
MOV
DL, [SI] ; take input string character stored in
STR one by one.
CMP
DL, 0AH ; compare with 0AH, to decide whether
the last
; character of
the sting in STR array is reached.
JE
STOP ; if equal go to STOP, and terminate the program.
PRINT ;
otherwise invoke
PRINT macro to display character
on
;
the output
device (monitor)
INC
SI ; increment the memory
ptr of STR array by one to get the
;
next character from STR array to be displayed on the monitor
JMP
BACK ;
go
to BACK location, to display the
next character on the monitor
STOP :
MOV AH,4CH ; terminate the program
INT 21H
CODE
ENDS ;
end of code segment
END
START ; end of program
Output:
D:\MASM>
Masm 2a.asm;
or (Masm
2a;)
D:\MASM>
Link 2a.obj; (Link
2a;)
D:\MASM>2a.exe
Or
we
can Debug the program using
D:\MASM>
TD 2a.exe
Then press F7
to trace the program (line by line execution) or press F9 to run the program in one operation
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
You are very Important to Us...
STAY TUNE...