Assignment No. 1 Graded: Semester Spring 2016 Computer Architecture and Assembly Language Programming - CS401 Objective
Assignment No. 1 Graded: Semester Spring 2016 Computer Architecture and Assembly Language Programming - CS401 Objective
1
Graded
Total Marks: 20
Objective:
The assignment has been designed to enhance your knowledge about how to write assembly program using
branching.
Student id= 150400903
Question: 1
[20 Marks]
Write an assembly language program to find the smallest number from an array of following ten numbers.
Explain each instruction of program and also provide/paste snapshot of your assemble and debug program
result which will be run in AFD (A Full Screen Debugger) window showing the executed code final results in
AX register.
Numbers :
20, 50, 30, 14, 19, 3, 5, 6, 40, 8
Answer
[ORG 100h]
JMP START
Num: DW 20, 50, 30, 14, 19, 3, 5, 6, 40, 8
L2: MOV AX, SI ; Save Small number in AX
ADD BX, 2 ; bx +=2; Point to next character
RET
START:
MOV BX, 0
MOV AX, 0
MOV AX, [Num + BX]
MOV CX, 10
L1: CMP AX , [Num + BX]
JLE L2
MOV AX, [Num +BX] ;
L3: ADD BX, 2
Loop L1 ; Poinyt next Numbetr
MOV AX, 0x4*00
INT 0*21
[Program:5, Explantion:3,Snashot:2]
Question: 2
Write an assembly language program to find the largest number from an array of following ten numbers.
Explain each instruction of program and also provide/paste snapshot of your assemble and debug program
result which will be run in AFD (A Full Screen Debugger) window showing the executed code final results in
AX register.
Numbers :
[Program:5, Explantion:3,Snashot:2]
Note: Provide snapshot of your program which will be run in AFD window. You will not get any marks for
copied assignment.
Answer
[org 0x0100]
jmp start;
array1: dw 10, 40, 20, 14, 19, 13, 50, 6, 60, 14
max:
dw 0
start:
mov bx, 0;
mov ax, 0;
mov ax, [array1+bx];
mov cx, 10
top2: cmp ax, [array1+bx];
jge end2;
mov ax, [array1+bx];
end2:
add bx, 2;
loop top2
mov [max],
ax;
mov ax, 0x4c00;
int 0x21