"Double Dutch night reading - from assembly language to the Windows kernel programming" anti-C 3.3 Assembler language practice Answers

In recent safety study classic book "Double Dutch night reading - from assembly language to the Windows kernel programming" and found little reference to the answer online, and there is obviously a serious error part of the answer, so write this article.

Given assembly code books as follows:

 

According to the book the author's own ideas and understanding restore the following C code:

int myfunction(int a[],int b[],double c[],int d)
{
    int i = 0;
    
    do
    {
        c[i] = a[i*2+1]*b[2] + a[i*2]*b[0];
        c[i+1] = a[i*2+1]*b[3] + a[i*2]*b[1];
        d += c[i] + c[i+1];
    }while(i<2 );     // here transducer is also possible for loop 
    
    D + = RAND (); 
    
    Switch (D) 
    { 
        Case  100 : 
            the printf ( " CNT IS 100 " );
         Case  110 : 
            the printf ( " CNT IS 110 " );
             BREAK ;
         default : 
            the printf ( " Nothing " ); 
    } 
    
    return D; 
}

Where c is the author of the array to think longer-place, for circulating the answers provided by the analysis of the book, we can see the second cycle (ie, i is 1) will c [1] reassigned, and each complete cycle of c 8 address will be added, if c is an array of type int, will not c [. 1] when the second cycle reassigned as type int space of 4 bytes, plus 8 c is equal to the address of the jump 8 / 4 = 2 index, it is c [2] instead of c [1] of the assignment. C can be an element that is 8-byte data type, double type.

 

If there are any errors or questions are welcome timely, we will reply as soon as possible on the line.

Guess you like

Origin www.cnblogs.com/dubh3/p/11784631.html