mirror of
https://github.com/exoticorn/upkr.git
synced 2026-01-20 03:26:43 +01:00
optimize dos stub size to save 2 bytes (discovered by qkumba)
This commit is contained in:
parent
2eb8f230ba
commit
f502bf4e28
@@ -105,15 +105,14 @@ upkr_decode_bit:
|
||||
dec dx
|
||||
jns upkr_load_bit
|
||||
movzx ax, byte [bx] ; u16 prob = upkr_probs[context_index]
|
||||
neg byte [bx]
|
||||
push ax ; save prob, tmp = prob
|
||||
cmp dl, al ; int bit = (upkr_state & 255) < prob ? 1 : 0; (carry = bit)
|
||||
pushf ; save bit flags
|
||||
jc .bit ; (skip if bit)
|
||||
neg al ; tmp = 256 - tmp;
|
||||
xchg [bx], al ; tmp = 256 - tmp;
|
||||
.bit:
|
||||
mov [bx], al ; upkr_probs[context_index] = tmp + (256 - tmp + 8) >> 4;
|
||||
neg byte [bx]
|
||||
shr byte [bx], 4
|
||||
shr byte [bx], 4 ; upkr_probs[context_index] = tmp + (256 - tmp + 8) >> 4;
|
||||
adc [bx], al
|
||||
mul dh ; upkr_state = tmp * (upkr_state >> 8) + (upkr_state & 255);
|
||||
mov dh, 0
|
||||
|
||||
@@ -95,16 +95,15 @@ upkr_decode_bit:
|
||||
inc dx
|
||||
dec dx ; inc dx, dec dx is used to test the top (sign) bit of dx
|
||||
jns upkr_load_bit
|
||||
movzx ax, byte [bx] ; int prob = upkr_probs[context_index]
|
||||
push ax ; save prob
|
||||
movzx ax, byte [bx] ; u16 prob = upkr_probs[context_index]
|
||||
neg byte [bx]
|
||||
push ax ; save prob, tmp = prob
|
||||
cmp dl, al ; int bit = (upkr_state & 255) < prob ? 1 : 0; (carry = bit)
|
||||
pushf ; save bit flags
|
||||
jc .bit ; (skip if bit)
|
||||
neg al ; tmp = 256 - tmp;
|
||||
xchg [bx], al ; tmp = 256 - tmp;
|
||||
.bit:
|
||||
mov [bx], al ; tmp_new = tmp + (256 - tmp + 8) >> 4;
|
||||
neg byte [bx]
|
||||
shr byte [bx], 4
|
||||
shr byte [bx], 4 ; upkr_probs[context_index] = tmp + (256 - tmp + 8) >> 4;
|
||||
adc [bx], al
|
||||
mul dh ; upkr_state = tmp * (upkr_state >> 8) + (upkr_state & 255);
|
||||
mov dh, 0
|
||||
|
||||
@@ -98,16 +98,15 @@ upkr_decode_bit:
|
||||
inc dx
|
||||
dec dx ; or whatever other test for the top bit there is
|
||||
jns upkr_load_bit
|
||||
movzx ax, byte [bx] ; int prob = upkr_probs[context_index]
|
||||
push ax ; save prob
|
||||
movzx ax, byte [bx] ; u16 prob = upkr_probs[context_index]
|
||||
neg byte [bx]
|
||||
push ax ; save prob, tmp = prob
|
||||
cmp dl, al ; int bit = (upkr_state & 255) < prob ? 1 : 0; (carry = bit)
|
||||
pushf ; save bit flags
|
||||
jc .bit ; (skip if bit)
|
||||
neg al ; tmp = 256 - tmp;
|
||||
xchg [bx], al ; tmp = 256 - tmp;
|
||||
.bit:
|
||||
mov [bx], al ; tmp += (256 - tmp + 8) >> 4;
|
||||
neg byte [bx]
|
||||
shr byte [bx],4
|
||||
shr byte [bx], 4 ; upkr_probs[context_index] = tmp + (256 - tmp + 8) >> 4;
|
||||
adc [bx], al ; upkr_probs[context_index] = tmp;
|
||||
mul dh ; upkr_state = tmp * (upkr_state >> 8) + (upkr_state & 255);
|
||||
mov dh, 0
|
||||
|
||||
Reference in New Issue
Block a user