📄 dehuff.asm
字号:
AC1 = AC1 + (@(p_arg4) * T3)
@(d_pass1) = AC1 ; PASS1 = UvldTabDC[htype]
XAR0 = #_lowmask
call #_uvld ; s = Uvld()
if (AC0 == #0) goto #storedc
@(d_pass0) = AC0 ; PASS0 = s (PASS1 since SP-- is already done)
call #_getdctcoeff
storedc:
XAR2 = dbl(@(p_arg2)) ; AR2 = lastdc
XAR4 = dbl(@(p_uvldlenmaxac))
T1 = @(p_arg4)
T3 = #UVLDACTABSIZE
AC1 = @(p_uvldtabac+1)
AC1 = AC1 + (@(p_arg4) * T3)
@(d_pass1) = AC1 ; PASS1 = UvldTabAC[htype]
AC0 = AC0 + *AR2
*AR2 = AC0 ; *lastdc += GetDctCoeff()
|| *AR7+ = AC0 ; *out_p+ = *lastdc
;; AC decoding
AR2=@InputAD
;XAR2 = #0x6000 ; set up function arguments to pass
;XAR2 = dbl(*AR5(#(4)))
AR6 = #63 ; AR6: coefficient counter
BRC0 = AR6
AC1 = *AR4(T1)
@(d_tmp) = AC1
AC1 = @(p_uvldctltabac+1)
AC1 = AC1 + (@(p_arg4) * T0)
@(d_pass2) = AC1 ; PASS2 = UvldCtlTabAC[htype]
bit(ST2, #ST2_AR2LC) = #1
AC1 = @(d_tmp)
|| blockrepeat {
@(d_pass0) = AC1 ; CAREFUL! Use PASS1 since SP-- is already done
XAR4 = dbl(@(p_uvldctltabac))
AR2 = *AR5(#(1)) ; *AR5(1) = buf_ptr, A = stream->databuf[buf_ptr]
AC1 = @(d_pass0)
AC1 = AC1 - *AR5 ; B = nrbits-bit_ptr
AR3 = AR0 + @(d_pass0) ; A = nrbits;
AC0 = *AR2 ; A = stream->databuf[buf_ptr]
if (AC1 <= #0) goto #($7) ; if (-bit_ptr>=0) goto$2
; if (bit_ptr <=0)
AC1 = AC1 + #(-16) ; -bit_ptr+=-16
AC0 = *AR2+ << #16 ; buffer=stream->databuf[buf_ptr]<<16
AC0 = AC0 | *AR2 ; buffer+=stream->databuf[++buf_ptr]
$7:
T3 = AC1 ; T = B
|| AR4 = @(d_pass2) ; B = dcdctl;
AC0 = AC0 << T3
AC0 = AC0 ^ #(-1) ; reversed
AC0 = AC0 & *AR3 ; A = (buffer>>bit_ptr)&mask[nrbits]
T3 = exp(AC0) ; index = 31 - T
AR4 = AR4 - T3 ; B = dcdctl-(31-index);
; get index
@(d_dat) = AC0 ; code stored in *AR5(-1)
AC0 = uns(*AR4(#(31))) ; pattern = dcdctl[index]
; get coding pattern
AR1 = AC0 & #7ffh ; offset = pattern&0x07ff;
AC0 = AC0 <<< #-11 ; shift = (pattern>>11)&0xf
AC0 = -AC0
T3 = AC0 ; T = -shift
|| AC2 = uns(@(d_dat))
AC2 = AC2 << T3
AR1 = AR1 + AC2
AR1 = AR1 + @(d_pass1) ; AR4 = dcdtab+code
AC0 = uns(*AR1) ; pattern = dcdtab[code];
AC1 = AC0 <<< #-11 ; nrbits = (pattern>>11)&0x1f
; flush_bits(stream, nrbits)
AC1 = AC1 - *AR5
AC1 = -AC1 ; stream->bit_ptr -=nrbits
AC0 = AC0 & #07ffh ; pattern&0x07ff
if (AC1 <= #0) execute (AD_unit)
*AR5(#(1)) = *AR5(#(1)) + #1 ; stream->buf_ptr++;
if (AC1 <= #0) execute (AD_unit)
*AR5(#(1)) = *AR5(#(1)) & #(MCUBUFFINLEN-1)
if (AC1 <= #0) execute (D_unit)
|| AC1 = AC1 + #16 ; stream->bit_ptr+= c16;
*AR5 = AC1 ; store stream->bit_ptr
; if s = 0x00 (EOB)
if (AC0 == #0) goto #endjpegdechuff
AC2 = AC0 - #0xf0
AC1 = AC0 <<C #-4
AR6 = AR6 - AC1 ; AR6 -= s>>4
XAR7 = #(unzigzag_r)
T1 = AR6 ; AR7 = i (loop index)
AR6 = AR6 - #1
BRC0 = AR6
if (AC2 == #0) goto $0xF0
; if s is regular r/s
AC0 = AC0 & #0fh
@(d_pass0) = AC0 ; PASS0 = s
AC1 = *AR7(T1) ; B = unzigzag_r[i]
AC1 = AC1 + dbl(@(p_arg3)) ; out_p += unzigzag_r[i]
XAR7 = AC1 ; AR7 = out_p
XAR4 = XAR0
AC0 = *AR5 ; *AR5(0) = bit_ptr
AC2 = AR0 + @(d_pass0) ; A = lowmask + ssss
AR2 = *AR5(#(1))
AC0 = AC0 - @(d_pass0) ; A = bit_ptr - ssss
*AR5 = AC0
AC0 = -AC0
|| AR4 = AC2 ; AR4 = &lowmask[ssss]
T3 = AC0 ; set up T for NORM B
AC1 = *AR2+ << #16 ; BH = current word
AC1 = AC1 | *AR2 ; BL = next word
if (AC0 < #0) goto #getvalue2
*AR5(#(1)) = *AR5(#(1)) + #1 ; buf_ptr++
*AR5(#(1)) = *AR5(#(1)) & #(MCUBUFFINLEN-1)
AC0 = AC0 + #(-16)
AC0 = -AC0
*AR5 = AC0 ; store bit_ptr
getvalue2:
XAR3 = #(_bitmask)
T1 = @(d_pass0)
AC1 = AC1 << T3
AC1 = AC1
AC0 = *AR4 ; *AR4 -> lowmask[ssss]
AC0 = AC0 & (AC1 <<< #-16)
AC1 = *AR3(T1)
AC1 = AC1 & AC0
if (AC1 == #0) execute (AD_unit)
|| AC0 = AC0 ^ #(-1)
if (AC1 == #0) execute (AD_unit)
|| AC0 = AC0 & *AR4
if (AC1 == #0) execute (AD_unit)
|| AC0 = -AC0
*AR7+ = AC0 ; *out_p+ = A
$0xF0: ; if s = 0xF0 (ZRL)
AC1 = @(d_tmp)
}
endjpegdechuff:
BSA23 = #0
bit(ST2, #ST2_AR2LC) = #0
bit(ST2, #ST2_ARMS) = #1
bit(ST1, #ST1_CPL) = #1
SP = SP + #2
AR6, T3 = pop()
XAR5 = popboth()
XAR7 = popboth()
return
.align 4
_getdctcoeff:
AC0 = *AR5 ; *AR5(0) = bit_ptr
XAR4 = XAR0
AC2 = AR0 + @(d_pass0) ; A = lowmask + ssss
;XAR2 = dbl(*AR5(#(4)))
AR2=@InputAD
;XAR2= #0x6000
AR2 = *AR5(#(1)) ; B = &(stream_p->databuf[buf_ptr])
AC0 = AC0 - @(d_pass0) ; A = bit_ptr - ssss
*AR5 = AC0
AC0 = -AC0
|| AR4 = AC2 ; AR4 = &lowmask[ssss]
T3 = AC0 ; set up T for NORM B
AC1 = *AR2+ << #16 ; BH = current word
|| circular()
AC1 = AC1 | *AR2 ; BL = next word
|| circular()
if (AC0 < #0) goto #getvalue
*AR5(#(1)) = *AR5(#(1)) + #1 ; buf_ptr++
*AR5(#(1)) = *AR5(#(1)) & #(MCUBUFFINLEN-1)
AC0 = AC0 + #(-16)
AC0 = -AC0
*AR5 = AC0 ; store bit_ptr
getvalue:
XAR3 = #(_bitmask)
T1 = @(d_pass0)
AC1 = AC1 << T3
AC1 = AC1
AC0 = *AR4 ; *AR4 -> lowmask[ssss]
AC0 = AC0 & (AC1 <<< #-16)
AC1 = *AR3(T1)
AC1 = AC1 & AC0
if (AC1 == #0) execute (AD_unit)
|| AC0 = AC0 ^ #(-1)
if (AC1 == #0) execute (AD_unit)
|| AC0 = AC0 & *AR4
if (AC1 == #0) execute (AD_unit)
|| AC0 = -AC0
return
.align 4
_uvld:
XAR3 = XAR0
; XAR2 = dbl(*AR5(#(4)))
; XAR2 = dbl(*AR5(#(2)))
AR2=@InputAD
;XAR2=#0x6000
BSA23 = @AR2_L
|| mmap()
XAR2=#0
AR2 = *AR5(#(1)) ; *AR5(1) = buf_ptr,
AC1 = @(d_pass0)
AC1 = AC1 - *AR5 ; B = nrbits-bit_ptr
; AC0=#0
AC0 = *AR2 ; A = stream->databuf[buf_ptr]
|| circular()
AR3 = AR0 + @(d_pass0) ; A = nrbits;
|| nop
; core part of the kernel
if (AC1 <= #0) goto #($9) ; if (-bit_ptr>=0) goto$2
; if (bit_ptr <=0)
AC1 = AC1 + #(-16) ; -bit_ptr+=-16
AC0 = *AR2+ << #16 ; buffer=stream->databuf[buf_ptr]<<16
|| circular()
AC0 = AC0 | *AR2 ; buffer+=stream->databuf[++buf_ptr]
|| circular()
$9:
T3 = AC1 ; T = B
|| AR4 = @(d_pass2) ; B = dcdctl;
AC0 = AC0 << T3
AC0 = AC0 ^ #(-1) ; reversed
AC0 = AC0 & *AR3 ; A = (buffer>>bit_ptr)&mask[nrbits]
T3 = exp(AC0) ; index = 31 - T
AR4 = AR4 - T3 ; B = dcdctl-(31-index);
; get index
@(d_dat) = AC0 ; code stored in *AR5(-1)
AC0 = uns(*AR4(#(31))) ; pattern = dcdctl[index]
; get coding pattern
AR1 = AC0 & #7ffh ; offset = pattern&0x07ff;
AC0 = AC0 <<< #-11 ; shift = (pattern>>11)&0xf
AC0 = -AC0
T3 = AC0 ; T = -shift
|| AC2 = uns(@(d_dat))
AC2 = AC2 << T3
AR1 = AR1 + AC2
AR1 = AR1 + @(d_pass1) ; AR4 = dcdtab+code
AC0 = uns(*AR1) ; pattern = dcdtab[code];
AC1 = AC0 <<< #-11 ; nrbits = (pattern>>11)&0x1f
; flush_bits(stream, nrbits)
AC1 = AC1 - *AR5
AC1 = -AC1 ; stream->bit_ptr -=nrbits
AC0 = AC0 & #07ffh ; pattern&0x07ff
if (AC1 <= #0) execute (AD_unit)
*AR5(#(1)) = *AR5(#(1)) + #1 ; stream->buf_ptr++;
if (AC1 <= #0) execute (AD_unit)
*AR5(#(1)) = *AR5(#(1)) & #(MCUBUFFINLEN-1)
if (AC1 <= #0) execute (D_unit)
|| AC1 = AC1 + #16 ; stream->bit_ptr+= c16;
*AR5 = AC1 ; store stream->bit_ptr
return
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -