pmtest7.asm中 DispMemSize:代码的解释

DispMemSize:

push esi

push edi

push ecx

 

mov esi, MemChkBuf                                                         // esi=7a

mov ecx, [dwMCRNumber]; for(int i=0;i<[MCRNumber];i++)//每次得到一个ARDS      ecx=6 ,

.loop:   ;                           {

mov edx, 5   ;                            for(int j=0;j<5;j++) //每次得到一个ARDS中的成员  edx=5    

mov edi, ARDStruct   ;                         {//依次显示BaseAddrLow,BaseAddrHigh,LengthLow,LengthHigh,Type

.1:   ;                                                           

push dword [esi]   ;                                    //push [ds:0x7a],为0x00000000

call DispInt   ;                                          DispInt(MemChkBuf[j*4]); //显示一个成员

pop eax   ;

stosd   ;                                                  ARDStruct[j*4] = MemChkBuf[j*4];

add esi, 4   ;          //stosb, stosw, stosd。这三个指令把al/ ax/ eax的内容存储到edi指向的内存单元中,同时edi的值根据方向标志的值增加或者减少。  

dec edx   ;

cmp edx, 0   ;

jnz .1   ;                                             }

call DispReturn   ;                                     printf("\n");

cmp dword [dwType], 1 ;                          if(Type == AddressRangeMemory)

jne .2   ;                                                     {

mov eax, [dwBaseAddrLow];

add eax, [dwLengthLow];

cmp eax, [dwMemSize]  ;                                   if(BaseAddrLow + LengthLow > MemSize)

jb .2   ;

mov [dwMemSize], eax  ;                                    MemSize = BaseAddrLow + LengthLow;

.2:   ;                                                           }

loop .loop   ;                           }

  ;

call DispReturn   ;                                     printf("\n");

push szRAMSize   ;

call DispStr   ;                                          printf("RAM size:");

add esp, 4   ;

  ;

push dword [dwMemSize] ;

call DispInt   ;                                           DispInt(MemSize);

add esp, 4   ;

 

pop ecx

pop edi

pop esi

ret

 

%include "lib.inc" ; 库函数

你可能感兴趣的:(test)