Assembly Language for Beginners

(Jeff_L) #1

1.24. STRUCTURES


mov esi, 1
push ebx
mov eax, esi
sub esp, 18h
cpuid
mov esi, eax
and eax, 0Fh
mov [esp+8], eax
mov dword ptr [esp+4], offset aSteppingD ; "stepping=%d\n"
mov dword ptr [esp], 1
call _printf_chk
mov eax, esi
shr eax, 4
and eax, 0Fh
mov [esp+8], eax
mov dword ptr [esp+4], offset aModelD ; "model=%d\n"
mov dword ptr [esp], 1
call _printf_chk
mov eax, esi
shr eax, 8
and eax, 0Fh
mov [esp+8], eax
mov dword ptr [esp+4], offset aFamily_idD ; "familyid=%d\n"
mov dword ptr [esp], 1
call
printf_chk
mov eax, esi
shr eax, 0Ch
and eax, 3
mov [esp+8], eax
mov dword ptr [esp+4], offset aProcessor_type ; "processor_type=%d\n"
mov dword ptr [esp], 1
call ___printf_chk
mov eax, esi
shr eax, 10h
shr esi, 14h
and eax, 0Fh
and esi, 0FFh
mov [esp+8], eax
mov dword ptr [esp+4], offset aExtended_model ; "extended_modelid=%d\n"
mov dword ptr [esp], 1
call
printf_chk
mov [esp+8], esi
mov dword ptr [esp+4], offset unk_80486D0
mov dword ptr [esp], 1
call ___printf_chk
add esp, 18h
xor eax, eax
pop ebx
pop esi
mov esp, ebp
pop ebp
retn
main endp


Almost the same. The only thing worth noting is that GCC somehow combines the calculation of
extended_model_idandextended_family_idinto one block, instead of calculating them separately be-
fore eachprintf()call.


Handling float data type as a structure


As we already noted in the section about FPU (1.19 on page 218), bothfloatanddoubletypes consist of
asign, asignificand(orfraction) and anexponent. But will we be able to work with these fields directly?
Let’s try this withfloat.


3031 2322 0

S exponent mantissa or fraction
Free download pdf