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 BCD. Show all posts
Showing posts with label BCD. Show all posts
Friday, February 21, 2014
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)