18 Bytes !!! Anyone can beat this? HEX16 for 8086 | ROL (Developers)
rr wrote:
> http://www.df.lth.se/%7Ejohn_e/gems/gem003a.html
mht wrote:
> You can still improve register usage. Use rotations on one
> register instead of shifts on two (4 rotations by 4 bits = no-op).
Thanks You can't beat the 18 Bytes this way but indeed improve the "useful" variant
> better cut-and-paste from there, instead of introducing additional
> noise
Welcome back to NOiSe ain't dead - the great C&P forum
use16
; HEX16 output conversion, 8086 compatible
; Input in AX | Trashes CX only !!!
; 9 instructions 18 Bytes vary bare, input in DX, trashes AX
; 10 instructions 18 Bytes very bare, input in AX, uses stack
; 10 instructions 19 Bytes very bare, input in AX, trashes DX, no stack
; 11 instructions 21 Bytes including call, input in AX, uses stack
; 14 instructions 24 Bytes including call, full register preservation and RET
hex16:
push cx
mov cx, 1028 ; "MOVNTQ CL, 4" + "MOVNTQ CH, 4"
h16l:
rol ax, cl ; 8086 compatible, after 4 ROL's original back
; rol dx, cl ; 8086 compatible, after 4 ROL's original back
; mov al, dl ; AL <- DL , transfer 8 bits, only 4 are useful
push ax
; mov dx, ax ; Now both DX and AX are equal, XCHG not good
and al, $0F
cmp al, 10 ; Now must be and is AL<=15 | Decimal "10" !!!
sbb al, $69 ; Securely Bugged Backup
das ; Digital Attack System | ASCII result in AL
call onecharal ; Input in AL | Must preserve CX (+ DX or AX)
pope ax
; xchg dx, ax ; Restore trashed AX from DX, but now DX trash
dec ch ; & No LOO'p on CH
jnz short h16l ; &
pope cx
ret
;----
; Avoiding cryptic "DAS" (also preceding SBB, OTOH keep CMP) costs 3 Bytes:
cmp al, 10
jb short @f ; OK, 0 ... 9
add al, 7 ; Fix for A ... F
@@: add al, 48
---
This is a LOGITECH mouse driver, but some software expect here
the following string:*** This is Copyright 1983 Microsoft ***
Complete thread:
- 18 Bytes !!! Anyone can beat this? HEX16 for 8086 - DOS386, 13.04.2009, 10:20 (Developers)
- 18 Bytes! Anyone can beat this? - No - ecm, 13.04.2009, 14:08
- 18 Bytes! Anyone can beat this? - No DAS - DOS386, 13.04.2009, 14:32
- 18 Bytes! Anyone can beat this? - No DAS - rr, 13.04.2009, 16:13
- 18 Bytes! Anyone can beat this? - No DAS - DOS386, 13.04.2009, 14:32
- 18 Bytes !!! Anyone can beat this? HEX16 for 8086 - mht, 13.04.2009, 16:04
- 18 Bytes !!! Anyone can beat this? HEX16 for 8086 | ROL - DOS386, 18.05.2009, 05:54
- 18 Bytes! Anyone can beat this? - No - ecm, 13.04.2009, 14:08