;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;*--==--* You are given a 32 bit value where the Most Significant
;*--==--* Bit in each byte (Bit 7) must be ignored, thus encoding
;*--==--* a 28 bit value. Write an optimal function to decode the
;*--==--* value (strip the ignored bits).
;*--==--* By G-Spider
;*--==--* fasm mtTest.asm mtTest.exe
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
format PE console
entry start
include 'win32a.inc'
;---------------------------------------------
section '.text' code readable executable
start:
stdcall _UInt32ToUInt28,0f7abh
cinvoke printf,szFmt,eax
cinvoke system,szPause
ret
align 16
_UInt32ToUInt28:
mov eax,dword [esp+4]
and eax,7f7f7f7fh
movzx ecx,ax
shr eax,16
movzx ecx, word [LUT + ecx * 2]
movzx eax, word [LUT + eax * 2]
shl eax,14
or eax,ecx
ret 4
;---------------------------------------------
section '.data' data readable writeable
LUT:
repeat 32768
dw (((%-1) and 0x7F00) shr 1) or ((%-1) and 0x7F)
end repeat
szFmt db '%x ', 0aH, 00H
szPause db 'pause',0
;---------------------------------------------
section '.idata' import data readable writeable
library msvcrt,'msvcrt.dll'
import msvcrt,\
printf,'printf',\
system,'system'