More Assembly

Moving around

Common use of cdq and idiv

mov eax, 1007 ; 1007 will be divided
mov ecx, 10   ; by 10
cdq           ; extends eax into edx
idiv ecx      ; eax will be  1007/10 = 100 and edx will be 1007%10 = 7

Divide by 2

mov eax, 16   ;eax = 16    0000 1000
shr eax, 1    ;eax = 8     0000 0100

Multiply by 4

mov eax, 5    ;eax = 5     0000 0101
sal eax, 2    ;eax = 20    0000 1010