News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to convert synchsafe integer to integer?

Started by Igor, July 29, 2010, 08:07:54 AM

Previous topic - Next topic

Igor

QuoteSynchsafe integers are integers that keep its highest bit (bit 7) zeroed, making seven bits out of eight available. Thus a 32 bit synchsafe integer can store 28 bits of information.

255 (00000000 11111111) encoded as a synchsafe integer is 383 (00000001 01111111).

Can someone help me convert this "01111111 01111111 01111111 01111111" to this "00001111 11111111 11111111 11111111"?

jj2007

Try this:
mov ecx, 01111111011111110111111101111111b
bswap ecx
movzx eax, cl ; eax=01111111b
REPEAT 3
shl eax, 7 ; move 7 bits left
shr ecx, 8
or al, cl
ENDM

dedndave

;EAX = synchsafe integer

mov ecx,eax
shl al,1
shl ax,1
and ecx,7F000000h
shl eax,1
and eax,0FFFFF8h
orĀ  eax,ecx
shr eax,3

;EAX = binary integer

Igor


Both solutions work fine, thank you guys.  :U


Forgot to mention that this "synchsafe integer" is from ID3v2.4 for tags in mp3 files, in case someone else tries to search for it.

drizz

The truth cannot be learned ... it can only be recognized.

Igor

Wou, nice thread and very good code, thanks.