#46663 - Locke - Tue Jun 28, 2005 9:59 pm
I'm trying to port a jpeg decoder to the NintendoDS, but I found some asm functions in the original source and I don't know how to handle them.
I don't want to start learning x86 asm only to translate 20 lines, so if any of you can write this 3 functions in plain C I will be very gratefull (of course I will give credit for the work in the readme)
Where BYTE = unsigned char; WORD = unsigned short int; SWORD = signed short int; DWORD = unsigned int; wordval = DWORD; start_neg_pow2 = DWORD;
Thanks for your time.
I don't want to start learning x86 asm only to translate 20 lines, so if any of you can write this 3 functions in plain C I will be very gratefull (of course I will give credit for the work in the readme)
Code: |
#ifdef _MSC_VER
WORD lookKbits(BYTE k) { _asm { mov dl, k mov cl, 16 sub cl, dl mov eax, [wordval] shr eax, cl } } WORD WORD_hi_lo(BYTE byte_high,BYTE byte_low) { _asm { mov ah,byte_high mov al,byte_low } } SWORD get_svalue(BYTE k) // k>0 always // Takes k bits out of the BIT stream (wordval), and makes them a signed value { _asm { xor ecx, ecx mov cl,k mov eax,[wordval] shl eax,cl shr eax, 16 dec cl bt eax,ecx jc end_macro signed_value:inc cl mov ebx,[start_neg_pow2] add ax,word ptr [ebx+ecx*2] end_macro: } } #endif |
Where BYTE = unsigned char; WORD = unsigned short int; SWORD = signed short int; DWORD = unsigned int; wordval = DWORD; start_neg_pow2 = DWORD;
Thanks for your time.