MMDB - Group#8 - Lab Report#2
MMDB - Group#8 - Lab Report#2
SOFTWARE ENGINEERING
COLLEGE OF E&ME, NUST,
RAWALPINDI
Subject Name:
EC-310 Microprocessor and Microcontroller Based
Design
Lab 02: Register access, Assembly code and Logic
building
SUBMITTED TO:
Dr. Sagheer Khan
SUBMITTED BY:
Shafla Rehman; 412780
Areesha Batool ; 413055
Shaheer Mukhtiar ; 432017
CE-44 , Syndicate B
TASK#1
Define three variables of the size of registers. Add all three of them and store their sum in a
register. Verify your results from the register contents. Also confirm by doing the binary
calculations on paper.
Code:
org 100h
.model small
.stack 100h
.data
var1 dw 1230h ; Define the first variable (hexadecimal)
var2 dw 2110h ; Define the second variable (hexadecimal)
var3 dw 1100h ; Define the third variable (hexadecimal)
.code
; Load variables into registers and add them
add bx, var1 ; Move the value of var1 into AX
add bx, var2 ; Add var2 to AX
add bx, var3 ; Add var3 to AX
int 21H
ret
Calculations:
Output:
Figure 1 The final result ''4440h '' stored in BX can be verified by calculations
TASK 2:
Define three variables half the size of registers. Add all three of them and store their sum in a
register. Verify your results from the register contents. Also confirm by doing the binary
calculations on paper. Remember to clear all the registers before using them
Code:
org 100h
.model small
.stack 100h
.data
.code
int 21H
ret
Calculations:
Output:
Figure 2 The final result ''51h '' stored in BX can be verified by calculations
TASK 3:
Prompt the user for entering a lower-case letter. Upon receiving the input, your code should
convert it into an upper-case letter and display it on the screen. The code should be properly
commented.
Code:
org 100h
.model small
.stack 100h
.data
message db 'Enter a lower case letter : ' , '$'
.code
; Load variables into registers and add them
int 21H
mov ah , 01h
int 21h
sub al,20H
mov bl,al
LEA dx ,CRLF
mov ah , 09h
int 21H
int 21H
mov ah ,02h
mov dl ,bl
int 21h
ret
Output:
TASK 4:
Prompt the user for entering an upper-case letter. Upon receiving the input, your code should
convert it into a lower-case letter and display it on the screen. What happens if the user inputs a
lower-case letter
Code:
org 100h
.model small
.stack 100h
.data
message db 'Enter a upper case letter : ' , '$'
.code
; Load variables into registers and add them
int 21H
mov ah , 01h
int 21h
add al,20H
mov bl,al
LEA dx ,CRLF
mov ah , 09h
int 21H
int 21H
mov ah ,02h
mov dl ,bl
int 21h
ret
Output:
Conclusion:
In this lab, we learned the basics of assembly language programming using Emu8086. We implemented
simple programs and utilized DOS interrupt INT 21H for keyboard input and screen output. By working
with functions such as 01H, 02H, and 09H, we gained fundamental skills in handling I/O operations in
assembly language, providing a strong foundation for further microprocessor programming.