Tiny embeddable Intel 80186/80188 disassembler

This is a complete disassembler supporting the full instruction set of Intel 80186/80188 CPUs (16-bit x86 for embedded applications - essentially a 286 without protected mode, as far as a disassembler is concerned). I wrote this in 1996 and have since placed it in the public domain.

Download i186dasm.zip (includes .asm and .com files).

Quite possibly this is the smallest disassembler of its kind (for a complete CISC CPU architecture). The .asm source for the disassembler is under 17 KB, the resulting compiled program is around 2.5 KB, of which only 164 bytes are the disassembler code (the rest is data and an optional tiny wrapper program to test/demonstrate the disassembler function by having it disassemble and print itself under DOS).

While there might be little need for a 186-only disassembler and for embedding it right into the device these days, the general approach at writing a disassembler/decoder may well be re-used for other processor architectures, other binary file formats (not necessarily programs), and in other programming languages, although having the source in assembly made it particularly easy to specify the data structures with ASCII text (instruction and register names, etc.), bitmasks, and pointers inter-mixed.

Back to other source code snippets and frameworks placed in the public domain.

; Tiny i80186/80188 disassembler:
; * suitable for embedded applications;
; * less than 2.5 KB compiled (164 bytes code).
;
; Use Borland's TASM to assemble:
;
;	tasm disasm.asm /m
;	tlink disasm.obj /t /x
;
; Written by Solar Designer <solar at openwall.com> in 1996, and now placed
; in the public domain -- 2000/11/26 SD.
 
.model tiny
.code
.186
.startup
 
IfNDef EMBEDDED
mov  si,100h ; for brainless debuggers.. 
@@TestLoop: 
mov  di,8000h 
call Disasm
mov  ax,0A0Dh
stosw 
mov  ax,900h+'$'
stosb
mov  dx,8000h
int  21h
cmp  si,offset PrintFns 
jb   @@TestLoop 
retn
EndIf
 
DisAsm:
cld
mov  bp,offset daMain
xor  ax,ax
cwd
push ax
@@DisAsmLoop:
mov  al,cs:[bp]
inc  bp
cmp  al,8
jb   @@StringDone
stosb
jmp  short @@DisAsmLoop
@@StringDone:
cmp  al,7
je   @@DisAsmDone
cmp  ax,dx
jbe  @@Processed
mov  dx,ax
@@Processed:
mov  bx,ax
mov  al,cs:[bp]
mov  cl,[si+bx]
cmp  al,0FCh
jb   @@ShiftLoop
inc  bp
and  al,3
mov  bx,ax
add  bx,ax
call word ptr cs:[PrintFns+bx]
xchg ax,bx
jmp  short @@DisAsmLoop
@@ShiftLoop:
test al,1
jnz  @@ShiftDone
shr  cl,1
shr  al,1
jnz  @@ShiftLoop
jmp  short @@DisAsmDone
@@ShiftDone:
mov  bx,ax
and  al,cl
add  bx,bx
add  bx,3
add  bx,bp
add  bp,ax
add  bp,ax
mov  bp,cs:[bp+1]
test bp,8000h
jz   @@NoCall
push bx
@@NoCall:
and  bp,7FFFh
jnz  @@DisAsmLoop
@@DisAsmDone:
pop  bp
or   bp,bp
jnz  @@DisAsmLoop
add  si,dx
inc  si
retn
 
PrintRelW:
mov  dl,2
mov  ax,[si+1]
inc  ax
jmp  short PrintRel
 
PrintRelB:
mov  al,cl
cbw
 
PrintRel:
inc  ax
inc  ax
add  ax,si
xchg al,ah
call PrintByte
xchg al,ah
call PrintByte
retn
 
PrintSX:
mov  al,cl
cbw
mov  al,ah
call PrintByte
 
PrintASIS:
mov  al,cl
 
PrintByte:
push ax
shr  al,4 
call PrintNibble
pop  ax
and  al,0Fh 
PrintNibble: 
add  al,90h
daa
adc  al,40h
daa
stosb
ret
 
PrintFns:
dw   PrintRelW, PrintRelB, PrintSX, PrintASIS
 
daSpace = 9
daCall = 8000h
 
daMain:
db   0, 0F8h
dw   da00, da08, da10, da18, da20, da28, da30, da38
dw   da40, da48, da50, da58, da60, da68, da70, da78
dw   da80, da88, da90, da98, daA0, daA8, daB0, daB8
dw   daC0, daC8, daD0, daD8, daE0, daE8, daF0, daF8
 
daXX:
db   'DB', daSpace, 0, 0FFh
 
daDone: 
db   7
 
daXX2:
db   'DB', daSpace, 0, 0FFh, ',', 1, 0FFh, 7
 
daModRM:
db   1, 0C0h
dw   daRM00, daRM40, daRM80, daRMC0
 
daRM00:
db   1, 7
dw   daMBXSI, daMBXDI, daMBPSI, daMBPDI
dw   daMSI, daMDI, daMd16, daMBX
 
daMBXSI:
db   '[BX+SI]', 7
 
daMBXDI:
db   '[BX+DI]', 7
 
daMBPSI:
db   '[BP+SI]', 7
 
daMBPDI:
db   '[BP+DI]', 7
 
daMSI:
db   '[SI]', 7
 
daMDI:
db   '[DI]', 7
 
daMd16:
db   '[', 3, 0FFh, 2, 0FFh, ']', 7
 
daMBX:
db   '[BX]', 7
 
daRM40:
db   1, 7
dw   daMBXSId8, daMBXDId8, daMBPSId8, daMBPDId8
dw   daMSId8, daMDId8, daMBPd8, daMBXd8
 
daMBXSId8:
db   '[BX+SI+', 2, 0FEh, ']', 7
 
daMBXDId8:
db   '[BX+DI+', 2, 0FEh, ']', 7
 
daMBPSId8:
db   '[BP+SI+', 2, 0FEh, ']', 7
 
daMBPDId8:
db   '[BP+DI+', 2, 0FEh, ']', 7
 
daMSId8:
db   '[SI+', 2, 0FEh, ']', 7
 
daMDId8:
db   '[DI+', 2, 0FEh, ']', 7
 
daMBPd8:
db   '[BP+', 2, 0FEh, ']', 7
 
daMBXd8:
db   '[BX+', 2, 0FEh, ']', 7
 
daRM80:
db   1, 7
dw   daMBXSId16, daMBXDId16, daMBPSId16, daMBPDId16
dw   daMSId16, daMDId16, daMBPd16, daMBXd16
 
daMBXSId16:
db   '[BX+SI+', 3, 0FFh, 2, 0FFh, ']', 7
 
daMBXDId16:
db   '[BX+DI+', 3, 0FFh, 2, 0FFh, ']', 7
 
daMBPSId16:
db   '[BP+SI+', 3, 0FFh, 2, 0FFh, ']', 7
 
daMBPDId16:
db   '[BP+DI+', 3, 0FFh, 2, 0FFh, ']', 7
 
daMSId16:
db   '[SI+', 3, 0FFh, 2, 0FFh, ']', 7
 
daMDId16:
db   '[DI+', 3, 0FFh, 2, 0FFh, ']', 7
 
daMBPd16:
db   '[BP+', 3, 0FFh, 2, 0FFh, ']', 7
 
daMBXd16:
db   '[BX+', 3, 0FFh, 2, 0FFh, ']', 7
 
daRMC0:
db   0, 1
dw   daRMC0b, daRMC0w
 
daRMC0b:
db   1, 7
dw   daAL, daCL, daDL, daBL, daAH, daCH, daDH, daBH
 
daOUTDXAL:
db   'OUT', daSpace, 'DX,' 
 
daAL:
db   'AL', 7
 
daRCL:
db   'R' 
 
daCL:
db   'CL', 7
 
daDL:
db   'DL', 7
 
daBL:
db   'BL', 7
 
daAH:
db   'AH', 7
 
daCH:
db   'CH', 7
 
daDH:
db   'DH', 7
 
daBH:
db   'BH', 7
 
daRMC0w:
db   1, 7
dw   daAX, daCX, daDX, daBX, daSP, daBP, daSI, daDI
 
daOUTDXAX:
db   'OUT', daSpace, 'DX,' 
 
daAX:
db   'AX', 7
 
daCX:
db   'CX', 7
 
daINALDX:
db   'IN', daSpace, 'AL,' 
 
daDX:
db   'DX', 7
 
daBX:
db   'BX', 7
 
daSP:
db   'SP', 7
 
daBP:
db   'BP', 7
 
daSI:
db   'SI', 7
 
daDI:
db   'DI', 7
 
da1R8:
db   0, 7 
dw   daAL, daCL, daDL, daBL, daAH, daCH, daDH, daBH
 
da1R16:
db   0, 7 
dw   daAX, daCX, daDX, daBX, daSP, daBP, daSI, daDI
 
da2R8:
db   1, 038h
dw   daAL, daCL, daDL, daBL, daAH, daCH, daDH, daBH
 
da2R16:
db   1, 038h
dw   daAX, daCX, daDX, daBX, daSP, daBP, daSI, daDI
 
daImm8:
db   1, 0C0h
dw   daImm8_RM00, daImm8_1, daImm8_2, daImm8_0
 
daImm8_RM00:
db   1, 3
dw   daImm8_0, daImm8_0, daImm8_CHECK, daImm8_0
 
daImm8_CHECK:
db   1, 4
dw   daImm8_0, daImm8_2
 
daImm8SX:
db   1, 0C0h
dw   daImm8SX_RM00, daImm8SX_1, daImm8SX_2, daImm8SX_0
 
daImm8SX_RM00:
db   1, 3
dw   daImm8SX_0, daImm8SX_0, daImm8SX_CHECK, daImm8SX_0
 
daImm8SX_CHECK:
db   1, 4
dw   daImm8SX_0, daImm8SX_2
 
daImm16:
db   1, 0C0h
dw   daImm16_RM00, daImm16_1, daImm16_2, daImm16_0
 
daImm16_RM00:
db   1, 3
dw   daImm16_0, daImm16_0, daImm16_CHECK, daImm16_0
 
daImm16_CHECK:
db   1, 4
dw   daImm16_0, daImm16_2
 
daImm16_0:
db   3, 0FFh
 
daImm8_0:
db   2, 0FFh, 7
 
daImm8SX_0:
db   2, 0FEh, 7
 
daImm16_1:
db   4, 0FFh
 
daImm8_1:
db   3, 0FFh, 7
 
daImm8SX_1:
db   3, 0FEh, 7
 
daImm16_2:
db   5, 0FFh
 
daImm8_2:
db   4, 0FFh, 7
 
daImm8SX_2:
db   4, 0FEh, 7
 
daModRMImm:
db   0, 1
dw   daCall+daModRM, daCall+daModRM
db   ',', 0, 1
dw   daImm8, daImm16
 
daSeg:
db   1, 018h
dw   daES, daCS, daSS, daDS
 
daES:
db   'ES', 7
 
daCS:
db   'CS', 7
 
daSS:
db   'SS', 7
 
daDS:
db   'DS', 7
 
da00:
db   0, 6
dw   daADD, daADD, daADD, daX67EF
 
da08:
db   0, 6
dw   daOR, daOR, daOR, daX67EF
 
da10:
db   0, 6
dw   daADC, daADC, daADC, daX67EF
 
da18:
db   0, 6
dw   daSBB, daSBB, daSBB, daX67EF
 
da20:
db   0, 6
dw   daAND, daAND, daAND, daX67EF
 
da28:
db   0, 6
dw   daSUB, daSUB, daSUB, daX67EF
 
da30:
db   0, 6
dw   daXOR, daXOR, daXOR, daX67EF
 
da38:
db   0, 6
dw   daCMP, daCMP, daCMP, daX67EF
 
daX67EF:
db   0, 1
dw   daX6E, daX7F 
 
daX6E:
db   0, 38h
dw   da06, da0E, da16, da1E, da26, da2E, da36, da3E
 
daX7F:
db   0, 38h
dw   da07, da0F, da17, da1F, da27, da2F, da37, da3F 
 
da06:
db   'PUSH', daSpace, 'ES', 7
 
da07:
db   'POP', daSpace, 'ES', 7
 
da0E:
db   'PUSH', daSpace, 'CS', 7
 
da0F = daXX 
 
da16:
db   'PUSH', daSpace, 'SS', 7
 
da17:
db   'POP', daSpace, 'SS', 7
 
da1E:
db   'PUSH', daSpace, 'DS', 7
 
da1F:
db   'POP', daSpace, 'DS', 7
 
da26:
db   'ES:', 7
 
da27:
db   'DAA', 7
 
da2E:
db   'CS:', 7
 
da2F:
db   'DAS', 7
 
da36:
db   'SS:', 7
 
da3E:
db   'DS:', 7
 
da3F:
db   'AAS', 7
 
da3X:
db   daSpace, 0, 7 
dw   daX0, daX1, daX2, daX3, daX4, daX5 
 
daADD:
db   'ADD', 0, 80h
dw   da3X 
 
daXOR:
db   'X' 
 
daOR:
db   'OR', 0, 80h 
dw   da3X 
 
daADC:
db   'ADC', 0, 80h
dw   da3X 
 
daSBB:
db   'SBB', 0, 80h
dw   da3X 
 
daAND:
db   'AND', 0, 80h
dw   da3X 
 
daSUB:
db   'SUB', 0, 80h
dw   da3X 
 
daCMP:
db   'CMP', 0, 80h 
dw   da3X 
 
daX0:
daX1:
db   0, 1
dw   daCall+daModRM, daCall+daModRM
db   ',', 0, 1
dw   da2R8, da2R16
 
daX2:
daX3:
db   0, 1
dw   daCall+da2R8, daCall+da2R16
db   ',', 0, 1
dw   daModRM, daModRM
 
daX4:
db   'AL,'
da1Imm8: 
db   1, 0FFh, 7
 
daX5:
db   'AX,'
da1Imm16: 
db   2, 0FFh, 1, 0FFh, 7
 
da40:
db   'INC', daSpace, 0, 1
dw   da1R16, da1R16
 
da48:
db   'DEC', daSpace, 0, 1
dw   da1R16, da1R16 
 
da50:
db   'PUSH', daSpace, 0, 1
dw   da1R16, da1R16
 
da58:
db   'POP', daSpace, 0, 1
dw   da1R16, da1R16
 
da60:
db   0, 7
dw   daPUSHA, daPOPA, daBOUND, daXX, daXX, daXX, daXX, daXX 
 
daPUSHA:
db   'PUSHA', 7
 
daPOPA:
db   'POPA', 7
 
daBOUND:
db   1, 0C0h
dw   daBOUND_OK, daBOUND_OK, daBOUND_OK, daXX2 
 
daBOUND_OK: 
db   'BOUND', daSpace, 0, 1
dw   daCall+da2R16, daCall+da2R16
db   ',', 0, 1
dw   daModRM 
 
da68:
db   0, 7
dw   daPUSHi16, daIMULi16, daPUSHi8, daIMULi8
dw   daCall+daINS, daCall+daINS, daCall+daOUTS, daCall+daOUTS
db   0, 80h
dw   daBW 
 
daPUSHi16:
db   'PUSH', daSpace, 0, 80h
dw   da1Imm16 
 
daIMULi16:
db   'IMUL', daSpace, 0, 1
dw   daCall+da2R16, daCall+da2R16
db   ',', 0, 80h 
dw   daModRMImm 
 
daPUSHi8:
db   'PUSH', daSpace, 1, 0FFh, 7
 
daIMULi8:
db   'IMUL', daSpace, 0, 1
dw   daCall+da2R16, daCall+da2R16 
db   ',', 0, 1 
dw   daCall+daModRM, daCall+daModRM
db   ',', 0, 80h
dw   daImm8SX
 
daINS:
db   'INS', 7
 
daOUTS:
db   'OUTS', 7
 
da70: 
da78:
db   'J', 0, 1 
dw   daCall+daJumps, daCall+daJumps
db   daSpace, 1, 0FDh, 7
 
daJumps:
db   0, 0Fh
dw   daJO, daJNO, daJB, daJNB, daJZ, daJNZ, daJBE, daJA
dw   daJS, daJNS, daJP, daJNP, daJL, daJGE, daJLE, daJG 
 
daJNO: 
db   'N' 
 
daJO:
db   'O', 7
 
daJNB:
db   'N' 
 
daJB:
daB: 
db   'B', 7
 
daJNZ:
db   'N' 
 
daJZ:
db   'Z', 7
 
daJBE:
db   'BE', 7
 
da37:
db   'AA' 
 
daJA:
db   'A', 7
 
daJNS:
db   'N' 
 
daJS:
db   'S', 7
 
daJNP: 
db   'N' 
 
daJP:
db   'P', 7
 
daROL:
db   'RO' 
 
daJL:
db   'L', 7
 
daJGE:
db   'GE', 7
 
daJLE:
db   'LE', 7
 
daNEG:
db   'NE' 
 
daJG:
db   'G', 7
 
da80:
db   0, 6 
dw   daArOp1, daArOp2, daTEST, daXCHG  
 
daArOp1:
db   1, 38h
dw   daCall+daADDa, daCall+daORa, daCall+daADCa, daCall+daSBBa
dw   daCall+daANDa, daCall+daSUBa, daCall+daXORa, daCall+daCMPa 
db   daSpace, 0, 8 
dw   daModRMImm
 
daArOp2:
db   1, 38h
dw   daCall+daADDa, daCall+daORa, daCall+daADCa, daCall+daSBBa
dw   daCall+daANDa, daCall+daSUBa, daCall+daXORa, daCall+daCMPa
db   daSpace, 0, 1
dw   daCall+daModRM, daCall+daModRM
db   ',', 0, 8
dw   daImm8SX
 
daADDa:
db   'ADD', 7
 
daXORa:
db   'X' 
 
daORa:
db   'OR', 7
 
daADCa:
db   'ADC', 7
 
daSBBa:
db   'SBB', 7 
 
daANDa:
db   'AND', 7
 
daSUBa:
db   'SUB', 7 
 
daCMPa:
db   'CMP', 7
 
daTEST:
db   'TEST', daSpace, 0, 1
dw   daCall+daModRM, daCall+daModRM
db   ',', 0, 1
dw   da2R8, da2R16 
 
daXCHG:
db   'XCHG', daSpace, 0, 1
dw   daCall+da2R8, daCall+da2R16
db   ',', 0, 8 
dw   daModRM
 
da88:
db   0, 7
dw   daMOVtoRM, daMOVtoRM, daMOVfromRM, daMOVfromRM
dw   daMOVfromSeg, daLEA, daMOVtoSeg, daPOPRM 
 
daMOVtoRM:
db   'MOV', daSpace, 0, 1
dw   daCall+daModRM, daCall+daModRM
db   ',', 0, 1
dw   da2R8, da2R16
 
daMOVfromRM:
db   'MOV', daSpace, 0, 1
dw   daCall+da2R8, daCall+da2R16
db   ',', 0, 1
dw   daModRM, daModRM 
 
daMOVfromSeg:
db   1, 20h
dw   daMOVfromSeg_OK, daXX2 
 
daMOVfromSeg_OK:
db   'MOV', daSpace, 1, 0C0h 
dw   daCall+daModRM, daCall+daModRM, daCall+daModRM, daCall+daRMC0w 
db   ',', 0, 1
dw   daSeg 
 
daLEA:
db   1, 0C0h
dw   daLEA_OK, daLEA_OK, daLEA_OK, daXX2 
 
daLEA_OK:
db   'LEA', daSpace, 0, 1
dw   daCall+da2R16, daCall+da2R16
db   ',', 0, 2
dw   daModRM 
 
daMOVtoSeg:
db   1, 20h
dw   daMOVtoSeg_OK, daXX2 
 
daMOVtoSeg_OK:
db   'MOV', daSpace, 0, 1 
dw   daCall+daSeg, daCall+daSeg 
db   ',', 1, 0C0h 
dw   daModRM, daModRM, daModRM, daRMC0w 
 
daPOPRM: 
db   'POP', daSpace, 0, 8 
dw   daModRM 
 
da90:
db   0, 3 
dw   daNOP_CHECK, daXCHGAX, daXCHGAX, daXCHGAX
 
daNOP_CHECK:
db   0, 4 
dw   daNOP, daXCHGAX
 
daNOP:
db   'NOP', 7 
 
daXCHGAX:
db   'XCHG', daSpace, 'AX,', 0, 20h
dw   da1R16 
 
da98:
db   0, 7
dw   daCBW, daCWD, daCALLF, daWAIT
dw   daPUSHF, daPOPF, daSAHF, daLAHF
 
daCBW:
db   'CB'
 
daW: 
db   'W', 7
 
daCWD:
db   'CWD', 7
 
daCALLF:
db   'CALL'
daPTR: 
db   daSpace, 4, 0FFh, 3, 0FFh, ':', 0, 1
dw   da1Imm16 
 
daWAIT:
db   'WAIT', 7
 
daPUSHF:
db   'PUSHF', 7
 
daPOPF:
db   'POPF', 7
 
daSAHF:
db   'SAHF', 7
 
daLAHF:
db   'LAHF', 7
 
daA0: 
db   0, 7 
dw   daMOVALm, daMOVAXm, daMOVmAL, daMOVmAX
dw   daCall+daMOVS, daCall+daMOVS, daCall+daCMPS, daCall+daCMPS
 
daBW: 
db   0, 1
dw   daB, daW 
 
daA8:
db   0, 6 
dw   daTESTA, daCall+daSTOS, daCall+daLODS, daCall+daSCAS
db   0, 10h 
dw   daBW 
 
daMOVALm:
db   'MOV', daSpace, 'AL,[', 2, 0FFh, 1, 0FFh, ']', 7
 
daMOVAXm:
db   'MOV', daSpace, 'AX,[', 2, 0FFh, 1, 0FFh, ']', 7
 
daMOVmAL:
db   'MOV', daSpace, '[', 2, 0FFh, 1, 0FFh, '],AL', 7
 
daMOVmAX:
db   'MOV', daSpace, '[', 2, 0FFh, 1, 0FFh, '],AX', 7
 
daMOVS:
db   'MOVS', 7
 
daCMPS:
db   'CMPS', 7
 
daTESTA:
db   'TEST', daSpace, 'A', 0, 1
dw   daTESTAL, daTESTAX
 
daTESTAL: 
db   'L,', 1, 0FFh, 7
 
daTESTAX:
db   'X,', 0, 2
dw   da1Imm16 
 
daSTOS:
db   'STOS', 7
 
daLODS:
db   'LODS', 7
 
daSCAS:
db   'SCAS', 7
 
daB0:
daB8: 
db   'MOV', daSpace, 0, 8
dw   daCall+da1R8, daCall+da1R16
db   ',', 0, 8
dw   da1Imm8, da1Imm16
 
daC0: 
db   0, 6 
dw   daShfOp, daRETN, daLXS, daMOVmi
 
daShfOp:
db   1, 38h
dw   daCall+daROL, daCall+daROR, daCall+daRCL, daCall+daRCR
dw   daCall+daSHL, daCall+daSHR, daXX2, daCall+daSAR
db   daSpace, 0, 1
dw   daCall+daModRM, daCall+daModRM
db   ',', 0, 10h
dw   daShf186, daShf086 
 
daShf186 = daImm8
 
daShf086:
db   0, 2
dw   daShf1, daShfCL
 
daShf1:
db   '1', 7
 
daShfCL = daCL 
 
daROR:
db   'ROR', 7
 
daRCR:
db   'RCR', 7
 
daSHL:
db   'SHL', 7
 
daSHR:
db   'SHR', 7
 
daSAR:
db   'SAR', 7
 
daIRET:
db   'I' 
 
daRETN:
db   'RET', 0, 1
dw   daRETNi, daDone 
 
daRETNi:
db   daSpace, 0, 8
dw   da1Imm16 
 
daLXS:
db   1, 0C0h
dw   daLXS_OK, daLXS_OK, daLXS_OK, daXX2 
 
daLXS_OK:
db   'L', 0, 1
dw   daCall+daLES, daCall+daLDS
db   'S', daSpace, 0, 1
dw   daCall+da2R16, daCall+da2R16
db   ',', 0, 8
dw   daModRM 
 
daLES:
db   'E', 7
 
daLDS:
db   'D', 7
 
daMOVmi:
db   1, 18h
dw   daMOVmi_CHECK, daXX2, daXX2, daXX2 
 
daMOVmi_CHECK:
db   1, 20h
dw   daMOVmi_OK, daXX2 
 
daMOVmi_OK: 
db   'MOV', daSpace, 0, 8 
dw   daModRMImm  
 
daC8:
db   0, 7 
dw   daENTER, daLEAVE, daRETFi, daRETF, daINT3, daINT, daINTO, daIRET 
 
daENTER:
db   'ENTER', daSpace, 2, 0FFh, 1, 0FFh, ',', 3, 0FFh, 7
 
daLEAVE:
db   'LEAVE', 7
 
daRETFi:
db   'RETF', daSpace, 0, 1
dw   da1Imm16 
 
daRETF:
db   'RETF', 7
 
daINT3:
db   'INT', daSpace, '3', 7
 
daINT:
db   'INT', daSpace, 1, 0FFh, 7
 
daINTO:
db   'INTO', 7 
 
daD0:
db   0, 4
dw   daShfOp, daD4
 
daD4:
db   0, 3
dw   daAAM, daAAD, daSETALC, daXLAT
 
daAAM:
db   'AAM', daSpace, 1, 0FFh, 7
 
daAAD:
db   'AAD', daSpace, 1, 0FFh, 7
 
daSETALC:
db   'SETALC', 7
 
daXLAT:
db   'XLAT', 7
 
daD8 = daXX
 
daE0: 
daE8:
daF0:
daF8: 
db   0, 1Fh
dw   daLOOPNZ, daLOOPZ, daLOOP, daJCXZ
dw   daINAL, daINAX, daOUTAL, daOUTAX
dw   daCALLN, daJMPN, daJMPF, daJMPS
dw   daINALDX, daINAXDX, daOUTDXAL, daOUTDXAX
dw   daLOCK, daXX, daREP, daREPZ
dw   daHLT, daCMC, daGrp1, daGrp1
dw   daCLC, daSTC, daCLI, daSTI
dw   daCLD, daSTD, daGrp2, daGrp3 
 
daLOOPNZ:
db   'LOOPNZ', daSpace, 1, 0FDh, 7
 
daLOOPZ:
db   'LOOPZ', daSpace, 1, 0FDh, 7
 
daLOOP:
db   'LOOP', daSpace, 1, 0FDh, 7
 
daJCXZ:
db   'JCXZ', daSpace, 1, 0FDh, 7
 
daINAL:
db   'IN', daSpace, 'AL,', 1, 0FFh, 7
 
daINAX:
db   'IN', daSpace, 'AX,', 1, 0FFh, 7
 
daOUTAL:
db   'OUT', daSpace, 1, 0FFh, ',AL', 7
 
daOUTAX:
db   'OUT', daSpace, 1, 0FFh, ',AX', 7
 
daCALLN:
db   'CALL', daSpace, 1, 0FCh, 7
 
daJMPN:
db   'JMP', daSpace, 1, 0FCh, 7
 
daJMPF:
db   'JMP', 0, 1
dw   daPTR 
 
daJMPS:
db   'JMP', daSpace, 1, 0FDh, 7
 
daINAXDX: 
db   'IN', daSpace, 'AX,DX', 7
 
daLOCK:
db   'LOCK', 7
 
daREP:
db   'REP', 7
 
daREPZ:
db   'REPZ', 7 
 
daHLT:
db   'HLT', 7
 
daCMC:
db   'CMC', 7
 
daGrp1:
db   1, 38h
dw   daTESTRMI, daXX2, daCall+daNOT, daCall+daNEG
dw   daCall+daMUL, daCall+daIMUL, daCall+daDIV, daCall+daIDIV
db   daSpace, 0, 8
dw   daModRM 
 
daTESTRMI:
db   'TEST', daSpace, 0, 8 
dw   daModRMImm
 
daNOT:
db   'NOT', 7
 
daIMUL:
db   'I' 
 
daMUL:
db   'MUL', 7
 
daIDIV:
db   'I' 
 
daDIV:
db   'DIV', 7
 
daCLC:
db   'CLC', 7
 
daSTC:
db   'STC', 7
 
daCLI:
db   'CLI', 7
 
daSTI:
db   'STI', 7
 
daCLD:
db   'CLD', 7
 
daSTD:
db   'STD', 7
 
daGrp2:
db   1, 38h
dw   daINCb, daDECb, daXX2, daXX2
dw   daXX2, daXX2, daXX2, daXX2 
 
daINCb:
db   'INC', daSpace, 1, 20h 
dw   daModRM
 
daDECb:
db   'DEC', daSpace, 1, 20h
dw   daModRM
 
daGrp3:
db   1, 38h
dw   daINCw, daDECw, daCALLw, daCALLd
dw   daJMPw, daJMPd, daPUSH, daXX2  
 
daINCw = daINCb
 
daDECw = daDECb 
 
daCALLw:
db   'CALL', daSpace, 1, 20h
dw   daModRM
 
daCALLd = daCALLw
 
daJMPw:
db   'JMP', daSpace, 1, 10h 
dw   daModRM
 
daJMPd = daJMPw
 
daPUSH: 
db   'PUSH', daSpace, 1, 8 
dw   daModRM
 
end

Back to other source code snippets and frameworks placed in the public domain.