I22-7423 - C, Lab Assignment 1
I22-7423 - C, Lab Assignment 1
LAB Assignment 1
Table of Contents
Page 1 of 17
∙ Introduction 3
∙ Steps 3
∙ Summary 3
∙ References 3
Page 2 of 17
● Question 1
A customer went for shopping and bought five different items. You need to
write an assembly program to take the prices (double digits) of the items from
user then add the prices of all the items and display the total bill of that
customer.
include Irvine32.inc
.data
total_marks dword ?
sub1 dword ?
sub2 dword ?
sub3 dword ?
sub4 dword ?
sub5 dword ?
.code
main proc
Page 3 of 17
; display message for subject 1 and read input and so on
call writestring
call readdec
call writestring
call readdec
call writestring
call readdec
call writestring
call readdec
call writestring
call readdec
Page 4 of 17
; calculate total marks
call writestring
call writedec
call crlf
; exit program
call waitmsg
exit
main endp
end main
Output
Page 5 of 17
● Question 2
Write an assembly program to take total marks (100) and obtained marks
(double digits) of a student for five subjects and display the total marks and
percentage (integral part only).
include Irvine32.inc
.data
Page 6 of 17
result_msg byte "Total Marks : ", 0
total_marks dword ?
sub1 dword ?
sub2 dword ?
sub3 dword ?
sub4 dword ?
sub5 dword ?
percentage dword ?
.code
main proc
call writestring
call readdec
call writestring
call readdec
call writestring
Page 7 of 17
call readdec
call writestring
call readdec
call writestring
call readdec
; Total marks
; Percentage
mul ebx
Page 8 of 17
mov ebx, 500
div ebx
; display result
call writestring
call writedec
call crlf
; display percentage
call writestring
call writedec
call crlf
; exit program
call waitmsg
exit
main endp
end main
Page 9 of 17
Output
● Question 3
.model small
include Irvine32.inc
.data
num dword ?
total_sum dword ?
Page 10 of 17
.code
main proc
call writestring
inc eax
mul ebx
mov ebx, 2
div ebx
call writestring
call writestring
call crlf
Page 11 of 17
; exit program
call waitmsg
exit
main endp
end main
● Question 4
include Irvine32.inc
.data
num1 dword ?
num2 dword ?
num3 dword ?
num4 dword ?
num5 dword ?
num6 dword ?
Page 12 of 17
num7 dword ?
num8 dword ?
add_result dword ?
mul_result dword ?
sub_result dword ?
div_result dword ?
.code
main proc
call writestring
call readint
call readint
call readint
call readint
call readint
call readint
Page 13 of 17
call readint
call readint
; num1 + num2
; num3 * num4
mul ebx
; num5 - num6
;num7 / num8
Page 14 of 17
mov ebx, num8
div ebx
; Display results
; Display addition
call writestring
call writedec
call crlf
; Display multiplication
call writestring
call writedec
call crlf
; Display subtraction
call writestring
cmp eax, 0
Page 15 of 17
jge sub_display
call writedec
jmp end_sub
sub_display:
call writedec
end_sub:
call crlf
; Display division
call writestring
call writedec
call crlf
; Exit program
call waitmsg
exit
main endp
end main
Page 16 of 17
● Question 5
Output
● Question 6
inclu
Output
Page 17 of 17