0% found this document useful (0 votes)
199 views3 pages

cs401p Solution

Uploaded by

bubbloomoosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
199 views3 pages

cs401p Solution

Uploaded by

bubbloomoosa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Computer Architecture and Assembly Language Programming

Practical
(CS401P)
Assignment No. 1
Spring 2024
BC230215316

a) Assembly language program.

[org 0x0100]
jmp start

id: db 2,3,0,2,1,5,3,1,6
less: db 0
sumResult: db 0,0,0,0,0,0,0,0,0
sortResult: db 0,0,0,0,0,0,0,0,0
swap: db 0

start:
mov cx, 8
mov bl, 9
mov si, id

low:
mov al, [si]
cmp al, bl
jge next
cmp al, 0
jz next
mov bl, al

next:
inc si
dec cx
jnz low

mov [less], bl
mov si, id
mov cx, 9
mov bl, 0

addroutine:
mov al, [si]
mov bl, [less]
add bl, al
mov [sumResult + di], bl
mov [sortResult + di], bl
inc si
inc di
dec cx
jnz addroutine

mov bx, sortResult


mov cx, 8

main:
mov si, 0
mov byte [swap], 0

inner:
mov al, [bx + si]
cmp al, [bx + si + 1]
jae noswap

mov dl, [bx + si + 1]


mov [bx + si], dl
mov [bx + si + 1], al
mov byte [swap], 1

noswap:
add si, 1
cmp si, cx
jne inner
cmp byte [swap], 1
je main
mov ax, 0x4c00
int 0x21
b) Screenshot showing the results.

You might also like