Powered By Blogger

Tuesday, 3 May 2011

cs401 assignment solution 2


Question No. 1:                                         10 Marks

Write an Assembly language program as per following instructions and tell what will be the value of CX and BL registers at the End of your program?

Let say your Roll number is MC789207290. So you need to initialize CX with 0, and BX with the least two significant digits of your roll no. i.e. (90 in this case). After this you need to execute the following loop instructions.

Label1:       inc  bl    
              inc  cx  
              cmp  bl, 0
              jnz  Label1 

Report your values in the BL and CX registers after the execution of the above loop with brief explanation.

Solution No. 1:                                         10 Marks

Two significant digits= 49 according to mc100403250
[org 0x0100]
mov cx, 0
mov bl,49

Label1:       inc  bl    
              inc  cx  
              cmp  bl, 0
              jnz  Label1
mov ax, 0x4c00
int 0x21 

Value at the end of program CX=CF)207 in decimal) BL=00
Loop in program executes 207 times in program and increment Cx CF(207) times as soon as after it Bl becomes 00 and program ends.



Question No. 2:                                         10 Marks

Write an Assembly language program as per following instructions and tell what will be the value of BX and CX registers at the End of your program?

Again, Let say your Roll number is MC789207290. So you need to initialize BX with 90 (least two significant digits of your roll no.), and CX with 72 (the next two least significant digits of your roll no.). After this you need to execute the following three XOR instructions.

              xor cx, bx
              xor bx, cx
              xor cx, bx

Report your values in the BX and CX registers after the execution of the above three XOR instructions with brief explanation.

Solution No. 2:                                         10 Marks

Second two least numbers of roll no. is 50

              xor cx, bx
              xor bx, cx
              xor cx, bx

[org 0x0100]
mov cx,50
mov bx,32
    xor cx,bx
    xor bx,cx
    xor cx,bx
mov ax,0x4c00
int 0x21
At the end values of registers : Cx=32 bx=50
The value registers are such because of Consecutive xor instructions 
Question No. 1:                                         10 Marks

Write an Assembly language program as per following instructions and tell what will be the value of CX and BL registers at the End of your program?

Let say your Roll number is MC789207290. So you need to initialize CX with 0, and BX with the least two significant digits of your roll no. i.e. (90 in this case). After this you need to execute the following loop instructions.

Label1:       inc  bl    
              inc  cx  
              cmp  bl, 0
              jnz  Label1 

Report your values in the BL and CX registers after the execution of the above loop with brief explanation.

Solution No. 1:                                         10 Marks

Two significant digits= 49 according to mc100403250
[org 0x0100]
mov cx, 0
mov bl,49

Label1:       inc  bl    
              inc  cx  
              cmp  bl, 0
              jnz  Label1
mov ax, 0x4c00
int 0x21 

Value at the end of program CX=CF)207 in decimal) BL=00
Loop in program executes 207 times in program and increment Cx CF(207) times as soon as after it Bl becomes 00 and program ends.



Question No. 2:                                         10 Marks

Write an Assembly language program as per following instructions and tell what will be the value of BX and CX registers at the End of your program?

Again, Let say your Roll number is MC789207290. So you need to initialize BX with 90 (least two significant digits of your roll no.), and CX with 72 (the next two least significant digits of your roll no.). After this you need to execute the following three XOR instructions.

              xor cx, bx
              xor bx, cx
              xor cx, bx

Report your values in the BX and CX registers after the execution of the above three XOR instructions with brief explanation.

Solution No. 2:                                         10 Marks

Second two least numbers of roll no. is 50

              xor cx, bx
              xor bx, cx
              xor cx, bx

[org 0x0100]
mov cx,50
mov bx,32
    xor cx,bx
    xor bx,cx
    xor cx,bx
mov ax,0x4c00
int 0x21
At the end values of registers : Cx=32 bx=50
The value registers are such because of Consecutive xor instructions 

No comments:

Post a Comment