;--- Masm2Htm.asm
;--- simple masm source to html converter. Public Domain.
;--- it's a sample for a mixed-language application (uses CRT)
;--- Win32 binary:
;--- assemble: jwasm -coff masm2htm.asm crtexe.asm
;--- link: link masm2htm.obj crtexe.obj msvcrt.lib
;--- Linux binary:
;--- assemble: jwasm -zcw -elf -D?MSC=0 -Fo masm2htm.o masm2htm.asm
;--- link: gcc -o masm2htm masm2htm.o
.386
.MODEL FLAT, c
option casemap:none
?USEDYN equ 1 ;0=use static CRT, 1=use dynamic CRT
ifndef ?MSC
?MSC equ 1 ;0=use gcc, 1=use ms crt
endif
BG_COLOR equ ;background color
REGS_COLOR equ <00B000> ;register's text color
COM_COLOR equ <808080> ;comment's text color
INST_COLOR equ <0000E0> ;instruction text color
OPTR_COLOR equ <808000> ;operator text color
TYPE_COLOR equ <800000> ;basic types text color
REGS_COLORED equ 1 ;if registers are to be colored
REGS64 equ 1 ;scan for amd64 registers?
INST_COLORED equ 1 ;if instructions are to be colored
OPTR_COLORED equ 1 ;if text operators are to be colored
TYPE_COLORED equ 1 ;if basic types are to be colored
printf proto c :ptr BYTE, :VARARG
fopen proto c :ptr BYTE, :ptr BYTE
fclose proto c :ptr
fseek proto c :ptr, :DWORD, :DWORD
ftell proto c :ptr
fread proto c :ptr BYTE, :DWORD, :DWORD, :ptr
fwrite proto c :ptr BYTE, :DWORD, :DWORD, :ptr
strcat proto c :ptr BYTE, :ptr BYTE
strcpy proto c :ptr BYTE, :ptr BYTE
strlen proto c :ptr BYTE
_stricmp proto c :ptr BYTE, :ptr BYTE
malloc proto c :DWORD
free proto c :ptr
lf equ 10
cr equ 13
SEEK_SET equ 0
SEEK_END equ 2
NULL equ 0
EOL equ
CStr macro text
local xxx
.const
xxx db text,0
.code
exitm
endm
;--- errno access
ife ?USEDYN
externdef c errno:dword ;errno is global var
else
__errno macro
;--- if errno is to be defined as a function call
if ?MSC
_errno proto c ;ms crt
call _errno
else
__errno_location proto c ;gcc
call __errno_location
endif
mov eax,[eax]
exitm
endm
errno textequ <__errno()>
endif
@DD macro list:VARARG
for directive,
local xxx
.const
xxx db "&directive&",0
.data
dd offset xxx
endm
endm
.data
;--- array of directives which are to be displayed "bold"
dirtab label dword
@DD <.186>, <.286>, <.286c>, <.286p>
@DD <.287>, <.386>, <.386c>, <.386p>
@DD <.387>, <.486>, <.486p>, <.586>
@DD <.586p>, <.686>, <.686p>, <.8086>
@DD <.8087>, <.allocstack>, <.alpha>, <.break>
@DD <.code>, <.const>, <.continue>, <.cref>
@DD <.data>, <.data?>, <.dosseg>, <.else>
@DD <.elseif>, <.endif>, <.endprolog>, <.endw>
@DD <.err>, <.err1>, <.err2>, <.errb>
@DD <.errdef>, <.errdif>, <.errdifi>, <.erre>
@DD <.erridn>, <.erridni>, <.errnb>, <.errndef>
@DD <.errnz>, <.exit>, <.fardata>, <.fardata?>
@DD <.if>, <.k3d>, <.lall>, <.lfcond>
@DD <.list>, <.listall>, <.listif>, <.listmacro>
@DD <.listmacroall>, <.mmx>, <.model>, <.no87>
@DD <.nocref>, <.nolist>, <.nolistif>, <.nolistmacro>
@DD <.pushframe>,<.pushreg>, <.radix>, <.repeat>
@DD <.safeseh>, <.sall>, <.savereg>, <.savexmm128>
@DD <.seq>, <.setframe>, <.sfcond>, <.stack>
@DD <.startup>, <.tfcond>, <.until>, <.untilcxz>
@DD <.while>, <.x64>, <.x64p>, <.xall>
@DD <.xcref>, <.xlist>, <.xmm>
@DD , , ,
@DD , , ,
@DD , , ,
@DD , , ,
@DD , , ,
@DD , ,,
@DD ,, ,
@DD , , ,
@DD , , ,
@DD , , ,
@DD , , ,
@DD , , ,
@DD , , ,
@DD , , ,
@DD ,, ,
@DD ,