CS401 Assignment # 1
Name: SHAHID AMEEN
VUID: BC210415570
Question No 1:
Write an assembly language program to store your Roll Number (Number
part only) and calculate their sum. Print a message on the screen that shows
that the received number is even or odd?
We write the code for display the result in the compiler your vu id is even or odd.
Assembly language program
[org 0x0100]
jmp start
msg1 db 'number is Even','$'
msg2 db 'number is odd','$'
m1:dw 2,1,0,4,1,5,5,7,0
start:
mov bx,0
mov cx,0
loop:
add ax, [m1+bx]
add bx,2
sub cx,1 ; numbers to be added reduced
cmp cx,0 ;compare the length
jnz loop ;if numbers remain add next
mov bx,ax
and bx,1
cmp bx,0
jnz odd
even:
mov SI,msg1 ; ;initialize array index for msg 1
MOV DX,SI
MOV AH,09H
INT 21H
jmp exit
odd:
mov SI,msg2 ;initialize array index for msg 2
MOV DX,SI
MOV AH,09H
INT 21H
Terminate: ;program termination
mov ax,0x4c00
int 0x21
Sample Screen Shot output of this above code is as under below:
Question No 2: 05 Marks
Find the offset address where Physical address is 4A37Bh and the segment address is
40FFh?
Answer:
First we subtract the physical address from segment address
Offset address = physical address – segment address * 10h
We put the values in the above statement
Offset address is equal to = 4A37Bh – 40FFh * 10h
After putting value we get this value and multiply this
Offset address is equal to = 4A37Bh – 40FF0h
We achieved this offset address as below.
Offset address = 938Bh Answer: