Statistics

Members: 1927
News: 293
Web Links: 1
Visitors: 3962603

Who's Online

Damn Vulnerable LinuxDamn Vulnerable Linux (DVL) is a Linux-based (modified Damn Small Linux) tool for IT-Security & IT-Anti- Security and Attack & Defense. [CLICK HERE FOR MORE INFOS! ]

Featured Conference Video

T16-Recon2006-Joe_Stewart-OllyBonE.gif OllyBone - Semi-Automatic Unpacking on IA-32. View the conference video here!
Home arrow Submit Your Paper!
Challenge
User Rating: / 0
PoorBest 
Written by Angel Tsankov   


Challenge
---------
Write as short as possible program to convert a two-digit BCD to hexadecimal;
that is, the decimal representation of the output must represent the
hexadecimal representation of the input.

Solution
--------
The solution, in 14 bytes:
    ;Input  AL = (A * 16) + B
    ;Output AL = (A * 10) + B
    88 C4      MOV  AH, AL       ;AH = AL
    82 E4 F0   AND  AH, 0F0h     ;AH = (A * 16)
    D0 EC      SHR  AH, 1        ;AH = (A * 8)
    28 E0      SUB  AL, AH       ;AL = (A * 8) + B
    C0 EC 02   SHR  AH, 2        ;AH = A * 2
    00 E0      ADD  AL, AH       ;AL = (A * 10) + B

Submitted by Angel Tsankov <{ This e-mail address is being protected from spam bots, you need JavaScript enabled to view it }>.