Monday, November 14, 2011

CS401: Computer Architecture and Assembly Language Programming Assignment No. 02 Semester: Fall 2011

Suppose your roll number is MC432198765. Here we refer 8765 as last four digits of your roll number.

Question No. 1:                                         5 Marks

Write and execute the following Assembly language program on your system and tell what will be the value of BX register at the end of this program?

[org 0x0100]
Mov bx, 0x8765
Ror bx,8
mov ax, 0x4c00
int 0x21

Note: In above program 8765 is used as an example. You have to put last four digits of your roll number there.


Let us suppose the last four digits of your rollno. is 1234 then 

Answer: will     3412

only interchange the last two digit with the first two digits.

example:    abcd   then   cd  will come before  ab  as   cdab


Question No. 2:                                         5 Marks

Modify the above program such that at the end of your program, we shall have 1’s compliment of your roll number’s last four digits in BX register.
[org 0x0100]

Mov bx, 0x8765--------Please enter your roll number’s last four digits here
Not bx
mov ax, 0x4c00
int 0x21


Question No. 3:                                          10 Marks

Write an assembly language program that will calculate the number of 1’s in the binary representation of last four digits of your roll number. For example if the binary representation of last four digits of your roll no. is 1101001100001 then the number of 1’s will be 6. The total number of 1’s should be stored in AX register. In this case, AX will contain 6 at the end of program.


[org 0x0100]


     mov dx, 0x8765--------Please enter your roll number’s last four digits here
     mov cl, 17
     mov ax,0

a:
     shr dx, 1
     dec cl
     jz t
     jnc a

     add ax,1

    
      
     jnz a
t:

     mov ax, 0x4c00
     int 0x21

No comments:

Post a Comment