LAB EXERCISE COMPUTER ORGANIZATION
SEMESTER NOVEMBER 32334
NAME : MUHAMMAD RAZIN WA’IE BIN MASWADI
Matric No: 3222012181
QUESTION 1
Write An Assembly language program that require range of age as input from user to evaluate
category of people in Malaysia as stated in Table 1. Please provide your student details on the
beginning of your program.
Table 1 : category of people in Malaysia
Age range Category
0-5 Baby
5-12 Children
12-21 Teenager
21-55 Adult
55 onwards Veteran
INCLUDE Irvine32.inc
.data
strname BYTE "My name is : Muhammad Razin.3222012181",0
str1 BYTE "Enter age: ",0
str2 BYTE "The catogory of age: ",0
str3 BYTE "Baby",0
str4 BYTE "Children",0
str5 BYTE "Teenager",0
str6 BYTE "Adult",0
str7 BYTE "Veteran",0
.code
main PROC
mov edx, OFFSET strname
call WriteString
call Crlf
call Clrscr
mov edx,OFFSET str1 ; input age from user
call WriteString
call ReadInt
call Crlf
mov edx,OFFSET str2
call WriteString
call Crlf
.IF eax <= 5
mov edx, OFFSET str3
call WriteString
.ELSEIF eax <= 12
mov edx, OFFSET str4
call WriteString
.ELSEIF eax <= 21
mov edx, OFFSET str5
call WriteString
.ELSEIF eax <= 55
mov edx, OFFSET str6
call WriteString
.ELSE
mov edx, OFFSET str7
call WriteString
.ENDIF
call Crlf
exit
main ENDP
END main
QUESTION 2
Use the solution program from the preceding exercise as a starting point. Let this new program add
value FIVE times by using a loop. Clear the screen after each loop iteration. Display each of the
values every time it loops. The output must display in the middle of the screen.
INCLUDE Irvine32.inc
COUNT = 5
.data
val SDWORD ?
str1 BYTE "Enter an integer: ",0
str2 BYTE "The sum is: ",0
sum SDWORD 0
row BYTE 8
col BYTE 20
.code
main PROC
call ClrScr
mov ecx, COUNT
mov sum, 0
; Input multiple integers, using a loop
L1: mov dh, row
mov dl, col
call Gotoxy
mov edx, OFFSET str1
call WriteString
call ReadInt
add sum, eax ; add integer to sum
add row, 2
loop L1 ; clear screen
; Display the sum
mov dh, 12 ; set the row for displaying the sum
mov dl, 20 ; set the column
call Gotoxy
mov edx, OFFSET str2
call WriteString
mov eax, sum
call WriteInt
call Crlf
call Crlf
exit
main ENDP
END main
QUESTION 3
Complete the following code to produce output for the ten rounds, then sum the values.
mov ax, 0
mov __cx__, ___10____
LI : add __ax__, ____cx___
loop L1