Lab Exercise 5
Lab Exercise 5
LEA DX, MSG ;Load the effective address where the message is stored
MOV AH,09
INT 21H Used to display on the monitor
1
Program 1: To display a string on the monitor
========================================
.MODEL SMALL
.STACK 64
.DATA
MSG DB 'Welcome to Assembly language Programming$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
Program two
To accept two numbers from the keyboard and display the sum on the monitor
;This program accepts two inputs from the keyboard and display the sum on the monitor.
.model small
.stack 100h
.data
msg1 db ‘Enter the first number $’
2
msg2 db ‘Enter the Second Number $’
msg3 db ‘The sum of the two numbers is $’
num1 db ?
num2 db ?
.code
main proc
mov ax, @data
mov ds, ax
; display the first message
mov ah, 09h
lea dx, mag1
int 21
; input the character
mov ah, 01h
int 21
; the value entered will be stored in al register and it is in ASCII format. We need to subtract 48
to get the ;actual value.
Sub al, 48
mov num1, al
mov ah,01h
int 21
sub al,48
mov num2, al
mov ah, 09h
3
lea dx, msg3
int 21
; add num1, num2 ; it is illegal to add values both source and destination in memory
mov al, num1
add al, num2
mov dl, al
add dl, 48
mov ah, 02h
int 21h
.data
msg1 db 'Enter the first number $'
msg2 db 0dh,0ah,'Enter the Second Number $'
msg3 db 0dh,0ah,'The sum of the two numbers is= $'
num1 db ?
num2 db ?
.code
main proc
4
mov ax, @data
mov ds, ax
; display the first message
mov ah, 09h
lea dx, msg1
int 21h
; input the character
mov ah, 01h
int 21h
; the value entered will be stored in al register and it is in ASCII format. We need to subtract 48
to get the ;actual value.
Sub al, 48
mov num1, al
mov ah,01h
int 21h
sub al,48
mov num2, al
mov ah, 09h