.


1. 1 i

x, i .

Mov cl, [i]

mov 1, eax

shl eax, cl

or [x], eax

2. , 32. , 5 .

Ideal

p386

model flat

extrn ExitProcess:proc

dataseg

x db 3,5,7,9,2,4,6

xpack db (((xpack-x)*8+4)/5) dup (0)

count dd xpack - x

codeseg

begin:

mov eax, [count]

; for (i=0; i< count; i++){

unsigned *p = xpack+(i*5)/8

}

mov esi, 0;

mov ebx, 0

fori:

mov dx, 0

mov ecx, ebx

and ecx, 7

mov dl, [x+esi]

shl dx, cl

mov ecx, ebx

shr ecx, 3

or [xpack+ecx], dx

add ebx, 5

inc esi

cmp esi, [count]

jl fori

call ExitProcess

end begin