; "SELFDASM.ASM" - 256-Byte's SELF disassembler ; RiXtA's SELF - DISASSEMBLER ; anno domino 2000 ; supported instructions are (in alphabetical order): ; ADD AND CMP INT JNL JNZ MOV RET ROR SUB (10 instructions) ; Converted from NASM to FASM by DOS386 only 10 years later 2010-05-12 ; Fixed BUG's (operand out of range, added "SUB" into list, ; bad label syntax, dead labels) ; Flaws: ; - original NASM code had absolutely no comments ; except (C) note (partially fixed) ; - original NASM code had bugs (fixed, see above) ; - slow as hell ; - screen mode switches for unknown reason (output redirection works, ; but still slow, otherwise text vanishes immediately when done) ; - numbers are raw hex without dollar "$" prefix or whatever ; - jump operands are reported "raw" rather than decoded ; - register assumptions on entry ??? ; added note by Baudsurfer march 21st 2013 : at least one of DOS386's assumptions is false vs. RiXtA : com startup cl!=0 but 0ffh format binary as "COM" use16 org $0100 ; ASS'ume: AX=0 | CL=0 ??? mov ch, 0 ; WtF ??? int $10 ; Set mode 40x25 text | Needs AH and AL only MAIN: mov bh, 1 mov bl, ch mov dh, [bx] mov al, dh ; Picked Byte in AL add al, 16 and al, 120 ; (248-128) ??? add cl, bh ; INCNTQ CL jnz short MAIN ; ??? mov bl, (TAB-1-$0100) mov cl, 3 ror al, cl ; RORNTQ AL, 3 add bl, al add bl, al add bl, al add dl, bh ; INCNTQ DL jnz short MAIN add ah, bh ; INCNTQ AH jnz short MAIN mov ah, 2 mov dl, 10 ; Drop EOL int $21 mov dl, 13 ; Also part of EOL mov cl, 252 ; Count 4 passes and brew only 3 chars ... WtF CYK2: int $21 ; Called to "VYPIS" from 1 other place also add bl, bh ; INCNTQ BL VYPIS: mov dl, [bx] add cl, bh ; INCNTQ CL jnz short CYK2 ; BCK mov dl, 9 ; TAB int $21 mov cl, dh mov al, dh and al, 248 cmp al, 176 jnz short OBS4 ; FWD | Obsolete ??? REGPRN: mov al, $CC ror al, cl ; CL = ??? and al, 3 mov dl, 'a' add dl, al int $21 ; Register A , B , C , D mov al, cl and al, 4 mov dl, 'l' ; Register L or H (X NOT used at all !!!) sub dl, al ; FYI: "l" - "h" = 4 !!! int $21 cmp ah, dh jnz short OBS5 ; FWD | Obsolete ??? NNQINC: add ch, bh ; INCNTQ CH NN: mov al, ch ; OK, AL is the address $0100-based cmp al, (TAB-$0100) jnz short MAIN ; BCK | JNE | NOT done mov ah, 0 mov al, 3 int $10 ; Restore 80x25 mode ret ;---- OBS3: cmp al, 0 jnz short NN ; BCK jnl short REGPRN ; BCK OBS5: mov dl, ',' int $21 mov al, 5 mov bl, (ZTEXT-$0100) cmp dh, bh jnz short OBS16 ; FWD | JNE | DH<>BH | DH<>1 | Obsolete ??? mov cl, 251 jnl short VYPIS ; BCK | Do 5 passes and brew 4 chars "[bx]" OBS16: and dh, dh jnz short OBS2 add dh, ah SPRSPC: mov al, cl mov cl, 3 ror al, cl ; RORNTQ AL, 3 mov cl, al jnz short REGPRN ; BCK OBS4: mov bl, 5 and dh, bl mov al, dh cmp al, 4 jnz short OBS2 ; FWD | Obsolete ??? mov cl, 8 jnl short REGPRN ; BCK OBS2: add ch, bh mov dl, 138 cmp cl, dl mov bl, ch mov cl, [bx] jnz short OBS15 ; FWD add dh, bh jnz short SPRSPC ; BCK OBS15: cmp al, 5 jnz short OBS3 ; BCK | Obsolete ??? NUMPRN: mov dh, 254 ; Counter of 2 passes ??? WtF ... NUMPR1: mov al, cl mov cl, 4 ror al, cl ; RORNTQ AL, 4 mov cl, al N2: and al, 15 ; Can be 0 to 15 add al, 55 ; Can be 55 to 70 cmp al, 65 jnl short OBS6 ; FWD | JNL AKA JNB AKA JAE ??? | Keep letter add al, 249 ; (256-7) | SUBNTQ AL, 7 -> "0" to "9" OBS6: mov dl, al int $21 ; Drop "0" to "9" or "A" to "F" add dh, bh ; INCNTQ DH jnz short NUMPR1 ; Most likely will jump if NOT ZERO jnl short NNQINC ; Signed comarison NL AKA GE | SF XOR OF = 0 TAB: db "jnz" db "jnl" db "add" db "mov" ; Duplicate ZTEXT: db "[bx]" db "RX" ; Unused ??? RAX ??? RSX ??? db "and" db "sub" ; Only "SUB DL, AL" db "mov" ; Duplicate db "cmp" db "ret" db "int" db "ror" ; Only "ROR AL, CL" ; END.