Does any one know if I can find these problemes here ?

3.  Problem #3 
a.  What will be the result of the following code if executed? Comment the assembler instructions
             MOV  BX, 20A           
             MOV  AX, [BX+1]   
             MOV  CX, [BX - 2]
             CMP  AX, CX  
             JB   cxismax       
             SUB  AX, CX
             MOV  DX, AX
             JMP  storeresult 
cxismax:     SUB  CX, AX
             MOV  DX, CX
storeresult: MOV  [BX+3], DX

b.  Write the assembler code to compute b = largest of A[0] ... A[n-1] using the algorithm bellow. Show the result of c. Comment your assembler instructions.
Consider A[10] = {2,8,7,6,5,9,0,3,1,4};
//   b = A[0];
//   for ( c = 1; c < n; c++ )
//    {
//     d = A[c];
//     if ( b < d ) b = d;
//    }

c.  Write the assembler instructions that will read 16 bytes of data from location 0A00H and 16 bytes of data from location 0C00H, on each loop multiply these data from the two source locations and save the results to location 00FFH. Show the last destination address for the last bytes. Comment your assembler instructions.

b.
mov ebx,0
mov edi,A
mov bl,byte [edi]
mov edx,0
inc edi
mov ecx,1
mMain:
cmp bl,byte [edi]
jge mSkip
mov bl,byte [edi]
mov edx,ecx
mSkip:
inc edi
inc ecx
cmp ecx,[n]
jl mMain

A db 2,8,7,6,5,9,0,3,1,4
n dd $-A

edx will contain result (same as c in your C-code).

This article has been dead for over six months. Start a new discussion instead.