CS401P Ass 1 by Saadix
CS401P Ass 1 by Saadix
ID: BC230427138
Subject: CS401p
Assignment #1
Q.1) You are required to write an assembly language program to perform the following
tasks:
a) Store the numeric part of your VUID in an array of numbers in memory.
b) Find the smallest odd number of your VUID and store it in memory.
c) Add each numeric digit of your VUID to the smallest odd number (computed in part
b) and store it in a 2nd array.
Solution:
[org 0x0100]
jmp start
vuid db 2,3,0,4,2,7,1,3,8
sm_odd db 0
result times 9 db 0
start:
mov si, 0
mov bl, 0FFh
find_odd:
mov al, [vuid + si]
test al, 1
jz not_odd
cmp al, bl
jae not_odd
mov bl, al
not_odd:
inc si
cmp si, 9
jl find_odd
mov [sm_odd], bl
mov si, 0
mov al, [sm_odd]
add_loop:
mov bl, [vuid + si]
add bl, al
mov [result + si], bl
inc si
cmp si, 9
jl add_loop
; Exit program
mov ax, 0x4C00
int 0x21
Screenshot