Importing sources from JWasm212s_140105.zip

This commit is contained in:
Anton Kochkov 2014-06-18 19:16:56 +04:00
commit 2d5853b0c2
1336 changed files with 87977 additions and 0 deletions

71
BCC.mak Normal file
View File

@ -0,0 +1,71 @@
# this makefile (NMake) creates the JWasm Win32 binary with Borland Commandline Tools.
name = jwasm
!ifndef BCDIR
BCDIR = \bcc55
!endif
!ifndef DEBUG
DEBUG=0
!endif
!if $(DEBUG)
OUTD=BCC32D
!else
OUTD=BCC32R
!endif
inc_dirs = /IH /I"$(BCDIR)\include"
!if $(DEBUG)
extra_c_flags = -v -y -DDEBUG_OUT
!else
extra_c_flags = -O2 /DNDEBUG
!endif
c_flags =-q -WC -K -D__NT__ -w-8012 -w-8057 -w-8060 $(extra_c_flags)
CC = $(BCDIR)\bin\bcc32.exe -c $(inc_dirs) $(c_flags)
LINK = $(BCDIR)\Bin\ilink32.exe -s -Tpe -ap -Gn -c -L$(BCDIR)\Lib
.c{$(OUTD)}.obj:
@$(CC) -o$* $<
proj_obj = \
!include msmod.inc
TARGET1=$(OUTD)\$(name).exe
ALL: $(OUTD) $(TARGET1)
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).exe : $(OUTD)/main.obj $(OUTD)/$(name).lib
@cd $(OUTD)
$(LINK) $(BCDIR)\Lib\c0x32.obj +main.obj, $(name).exe, $(name).map, $(name).lib import32.lib cw32.lib
@cd ..
$(OUTD)/$(name).lib: $(proj_obj)
@cd $(OUTD)
@erase $(name).lib
!if $(DEBUG)
$(BCDIR)\bin\tlib $(name).lib /C $(proj_obj:BCC32D/=+)
!else
$(BCDIR)\bin\tlib $(name).lib /C $(proj_obj:BCC32R/=+)
!endif
@cd ..
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h
@$(CC) /o$* msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
@$(CC) /o$* reswords.c
######
clean:
@erase $(OUTD)\*.exe
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

67
CLang.mak Normal file
View File

@ -0,0 +1,67 @@
# This makefile creates the JWasm Win32 binary with
# the CLang driver on either MinGW or Cygwin.
# 'make -f CLang.mak' will use MinGW.
# 'make -f CLang.mak CYGWIN=1' will use Cygwin.
name = jwasm
ifndef CYGWIN
CYGWIN=0
endif
ifndef DEBUG
DEBUG=0
endif
inc_dirs = -IH
#cflags stuff
ifeq ($(DEBUG),1)
extra_c_flags = -DDEBUG_OUT -g
ifeq ($(CYGWIN),1)
OUTD=CygwinD
else
OUTD=CLangD
endif
else
extra_c_flags = -DNDEBUG -O2
ifeq ($(CYGWIN),1)
OUTD=CygwinR
else
OUTD=CLangR
endif
endif
c_flags = -D__NT__ $(extra_c_flags)
CC=clang.exe -c $(inc_dirs) $(c_flags)
$(OUTD)/%.o: %.c
$(CC) -o $(OUTD)/$*.o $<
include gccmod.inc
TARGET1=$(OUTD)/$(name).exe
ALL: $(OUTD) $(TARGET1)
$(OUTD):
mkdir $(OUTD)
$(OUTD)/$(name).exe : $(OUTD)/main.o $(proj_obj)
clang.exe $(OUTD)/main.o $(proj_obj) -s -o $(OUTD)/$(name).exe -Wl,-Map,$(OUTD)/$(name).map
$(OUTD)/msgtext.o: msgtext.c H/msgdef.h
$(CC) -o $(OUTD)/msgtext.o msgtext.c
$(OUTD)/reswords.o: reswords.c H/instruct.h H/special.h H/directve.h
$(CC) -o $(OUTD)/reswords.o reswords.c
######
clean:
@rm $(OUTD)/*.exe
@rm $(OUTD)/*.obj
@rm $(OUTD)/*.map

48
Doc/enh.txt Normal file
View File

@ -0,0 +1,48 @@
Possible Enhancements for JWasm
1. support UNICODE strings. Similar to PoAsm? Most likely no,
since using the DB/DW directives to define such strings
doesn't seem to be the best strategy. Might be better to
have an extra type for unicode strings (tchar), in
conjunction with a cmdline option to switch ansi/unicode.
2. [ done, was: option FPO (frame pointer omission); has
become option STACKBASE. ]
3. unnamed RECORD within a STRUCT. Record field names
will be local then and must be unique within the STRUCT. This
feature will ease converting C include files to ASM.
Syntax:
operator WIDTH: ok
operator MASK: ???
S1 STRUCT
f1 dd ?
RECORD bit0:1, bit1:1
S1 ends
mov eax, MASK S1.bit0
or v1.bit0 ???
4. [ done, was: native support for PE binaries ]
5. ASSUME extension
use ASSUME CS:[USE16|USE32|USE64] to change current offset size
without changing segments.
6. FOR extension
Preprocessor extension:
FOR EACH x IN [<struct>|<union>|<record>|<proc>]
...
ENDM
- x is the loop variable, it's a text macro, its value will be
the name of the item.
- the "members" are enumerated. For PROCedures, these are the
parameters, local variables and local labels.

26
Doc/fixes.txt Normal file
View File

@ -0,0 +1,26 @@
Issues in the source which should be fixed.
1. Backpatching
Currently backpatching handles JMPs and CALLs only. It
is unable to handle PUSHs ( and may be others as well).
So the backpatch routine calculates addresses wrong and
as a result an additional assembly pass is required.
2. Two Pass Minimum
Currently the generated code/data bytes aren't stored in
assembly pass one. So a second pass is always needed.
With better backpatching capabilities, JWasm should be
able to virtually become a one-pass assembler.
[ issue fixed in v2.06
3. Token Buffer
The token buffer is a global variable. This causes
a lot of problems. There are some workarounds implemented
to make the buffer reusable, but these hacks didn't
help to make the code more readable.
]

21
Doc/gencode.txt Normal file
View File

@ -0,0 +1,21 @@
1. What is generated code
Some directives (and also instructions RET/IRET inside a procedure block)
will generate source lines. In the listing file, those generated
lines will be marked with a '*'.
2. Where is generated code used?
- INVOKE directive
- hll directives (.IF, .ELSE, .WHILE, .REPEAT, ...)
- .MODEL directive
- .STARTUP and .EXIT directives
- simplified segment directives (.CODE, .DATA, .CONST, ...)
- default PROC prologue and epilogue (when a RET/IRET is detected)
- ENDP ( in Win64, if procedure has FRAME attribute )
- END
+ if a segment opened by simplified segment directives is still open
+ PE format: generates import/export data, MZ header
- [removed since v2.09: STRUCT data initialization (was slightly peculiar)]

158
Doc/overview.txt Normal file
View File

@ -0,0 +1,158 @@
A brief overview of JWasm's source code
1. Source files
file comment
-----------------------------------------------------------------------
main.c contains main()
cmdline.c parse command line
assemble.c assembler (generic)
input.c read source file,
preprocessor (generic)
calling preprocessor directives
expans.c (text) macro expansion
tokenize.c tokenizer, COMMENT directive
condasm.c preprocessor conditional directives (IFx, ELSEx, ENDIF )
loop.c preprocessor loop directives (FOR, FORC, REPT, WHILE, ...)
equate.c (preprocessor) EQU and '=' directives
string.c preprocessor string directives (TEXTEQU, CATSTR, SUBSTR, ...)
macro.c preprocessor MACRO and PURGE directives
parser.c parser (generic)
branch.c parsing of branch instructions (JMP, Jcc, CALL, JxxxZ, LOOPx )
expreval.c expression evaluator
assume.c parsing of ASSUME directive
context.c parsing of directives PUSHCONTEXT, POPCONTEXT
cpumodel.c parsing of .MODEL and cpu (.8086, .80186, ...) directives
data.c parsing of data directives (DB, DW, ... ), data labels
handles data generation (+fixups)
directiv.c parsing of various directives which have no other home
end.c parsing of END, .STARTUP and .EXIT directives
extern.c parsing of EXTERN, EXTERNDEF, COMM, PUBLIC, PROTO
hll.c parsing of hll directives (.IF, .ELSE, .WHILE, .REPEAT, ...)
invoke.c parsing of INVOKE directive
labels.c parsing of LABEL directive, code labels
listing.c parsing of listing directives (.LIST, .CREF, ...)
writing of listing file
option.c parsing of OPTION directive
posndir.c parsing of ORG, ALIGN, EVEN directives
proc.c parsing of PROC, ENDP, LOCAL directives
generates procedure prologues and epilogues
safeseh.c parsing of .SAFESEH directive
segment.c parsing of SEGMENT (+ENDS) and GROUP directives
simsegm.c parsing of simplified segment directives (.CODE, .DATA, ...)
types.c parsing of STRUCT (+ENDS), UNION, TYPEDEF, RECORD directives
omf.c handles OMF output format
omffixup.c handles OMF fixup generation
omfint.c handles OMF I/O
coff.c handles COFF output format (32- and 64-bit)
elf.c handles ELF output format (32- and 64-bit)
bin.c handles binary and DOS MZ output format
dbgcv.c handles output of CodeView symbolic debugging info
reswords.c handles access to table of reserved words
symbol.c handles access to - global and local - symbol (hash) table
backptch.c handles backpatching (jump distance optimization)
codegen.c handles instruction code generation (+fixups)
fixup.c fixup creation
fpfixup.c 16-bit floating-point fixup creation
errmsg.c handles assembler error messages (non-fatal)
fatal.c handles fatal assembler errors
memalloc.c handles dynamic memory allocations
tbyte.c handles TBYTE data format (10-byte floating-point format)
queue.c handles internal queues
mangle.c handles symbol name mangling (name decoration)
apiemu.c handles C compiler peculiarities and bugs
2. Calling hierarchy
main
- main_init
- main_fini
- AssembleModule
- AssembleInit
- AssembleFini
- OnePass
- GetPreprocessedLine ( if pass == 1 )
- GetTextLine
- Tokenize ( if pass > 1 )
- ParseLine
- directive
- data_init
- EvalOperand
- EvalOperand()
- codegen()
1. main()
cmdline parsing, wildcards
calls AssembleModule() for each source module.
2. AssembleModule()
assembles one module in at least 2 passes.
3. OnePass()
Executes one pass for a module. Pass one is handled
differently than the others, because the preprocessed
lines are saved in this pass and then read in the
consecutive passes.
4. Tokenize()
The tokenizer. Scans a source line and detects reserved words,
numbers, IDs, operators, literals. Converts the items to tokens
stored in array tokenarray[].
5. GetPreprocessedLine()
This is the preprocessor. It
- reads a line from the current source,
- converts in into tokens ( function Tokenize() )
- calls macro expansion.
- checks if the line contains a preprocessor directive
preprocessor directives are IF, WHILE, REPEAT, INCLUDE,
TEXTEQU, CATSTR, INSTR, ...
- if yes, handles the directive and returns 0.
- if no, returns the number of tokens found in the line
6. ParseLine()
The parser. It does:
- checks if first item is a code label (ID followed by ':'). If yes,
a label is created ( function LabelCreate() ).
- checks if current item is a directive. If yes, calls function
directive() or - if directive is a "data definition directive" -
function data_item()
- checks if current item is predefined type or an arbitrary type.
If yes, calls function data_item().
- if current item is an instruction, it calls the expression
evaluator ( function EvalOperand() ), up to 3 times, to get
the operands.
- if more than 1 operand has been read, function check_sizes()
is called, which verifies that the sizes of the operands will
"match".
- the code generator ( function codegen() ) is called.
7. codegen()
The code generator. This part
- scans the instruction table to find an entry which matches
the number of operands and their types.
- if an entry is found, the code bytes and fixups are generated
and written into a buffer.
8. data_init()
Handles data lines. This is either a data directive ( DB, DW, DD, ...),
a predefined type ( BYTE, WORD, DWORD, ... ) or an arbitrary type, defined
with TYPEDEF, STRUCT, UNION, ....
9. GetTextLine()
Reads a line from the current source. This is either a macro, a source
file or the global line queue, which is used to store generated code.

66
Doc/srclic.txt Normal file
View File

@ -0,0 +1,66 @@
JWasm originally was a fork of Wasm. The old Open Watcom Wasm source
was released under the Sybase license (S).
In the meantime, a part of the source contain no lines of
Wasm anymore - they are new or have been completely rewritten. The license
for these files is Public Domain (P).
apiemu.c P
assemble.c P
assume.c S
atofloat.c P
backptch.c S
bin.c P
branch.c S
cmdline.c S
codegen.c S
coff.c P
condasm.c S
context.c P
cpumodel.c P
data.c S
dbgcv.c P
directiv.c P
elf.c P
end.c P
equate.c P
errmsg.c S
expans.c P
expreval.c S
extern.c P
fastpass.c P
fixup.c S
fpfixup.c S
hll.c P
input.c S
invoke.c P
label.c S
linnum.c P
listing.c P
loop.c P
lqueue.c P
macro.c P
main.c P
mangle.c S
memalloc.c P
msgtext.c P
omf.c S
omffixup.c S
omfint.c S
option.c P
parser.c S
posndir.c S
preproc.c P
proc.c P
queue.c S
reswords.c P
safeseh.c P
segment.c S
simsegm.c P
string.c P
symbols.c S
tbyte.c S
tokenize.c S
trmem.c S
types.c P

53
GccDos.mak Normal file
View File

@ -0,0 +1,53 @@
# This makefile creates the JWasm 32-bit DOS binary with DJGPP.
# 'make -f GccDos.mak'
name = jwasm
ifndef DEBUG
DEBUG=0
endif
inc_dirs = -IH
#cflags stuff
ifeq ($(DEBUG),1)
extra_c_flags = -DDEBUG_OUT -g
OUTD=DJGPPd
else
extra_c_flags = -DNDEBUG -O2
OUTD=DJGPPr
endif
c_flags = $(extra_c_flags)
CC=gcc.exe -c $(inc_dirs) $(c_flags)
$(OUTD)/%.o: %.c
$(CC) -o $(OUTD)/$*.o $<
include gccmod.inc
TARGET1=$(OUTD)/$(name).exe
ALL: $(OUTD) $(TARGET1)
$(OUTD):
mkdir $(OUTD)
$(OUTD)/$(name).exe : $(OUTD)/main.o $(proj_obj)
gcc.exe $(OUTD)/main.o $(proj_obj) -s -o $(OUTD)/$(name).exe -Wl,-Map,$(OUTD)/$(name).map
$(OUTD)/msgtext.o: msgtext.c H/msgdef.h H/globals.h
$(CC) -o $(OUTD)/msgtext.o msgtext.c
$(OUTD)/reswords.o: reswords.c H/instruct.h H/special.h H/directve.h
$(CC) -o $(OUTD)/reswords.o reswords.c
######
clean:
@erase $(OUTD)\*.exe
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

60
GccUnix.mak Normal file
View File

@ -0,0 +1,60 @@
# This makefile creates the JWasm Elf binary for Linux/FreeBSD.
TARGET1=jwasm
ifndef DEBUG
DEBUG=0
endif
inc_dirs = -IH
#cflags stuff
ifeq ($(DEBUG),0)
extra_c_flags = -DNDEBUG -O2
OUTD=GccUnixR
else
extra_c_flags = -DDEBUG_OUT -g
OUTD=GccUnixD
endif
c_flags =-D__UNIX__ $(extra_c_flags)
CC = gcc
.SUFFIXES:
.SUFFIXES: .c .o
include gccmod.inc
#.c.o:
# $(CC) -c $(inc_dirs) $(c_flags) -o $(OUTD)/$*.o $<
$(OUTD)/%.o: %.c
$(CC) -c $(inc_dirs) $(c_flags) -o $(OUTD)/$*.o $<
all: $(OUTD) $(OUTD)/$(TARGET1)
$(OUTD):
mkdir $(OUTD)
$(OUTD)/$(TARGET1) : $(OUTD)/main.o $(proj_obj)
ifeq ($(DEBUG),0)
$(CC) $(OUTD)/main.o $(proj_obj) -s -o $@ -Wl,-Map,$(OUTD)/$(TARGET1).map
else
$(CC) $(OUTD)/main.o $(proj_obj) -o $@ -Wl,-Map,$(OUTD)/$(TARGET1).map
endif
$(OUTD)/msgtext.o: msgtext.c H/msgdef.h
$(CC) -c $(inc_dirs) $(c_flags) -o $*.o msgtext.c
$(OUTD)/reswords.o: reswords.c H/instruct.h H/special.h H/directve.h H/opndcls.h H/instravx.h
$(CC) -c $(inc_dirs) $(c_flags) -o $*.o reswords.c
######
clean:
rm $(OUTD)/$(TARGET1)
rm $(OUTD)/*.o
rm $(OUTD)/*.map

76
GccWin.mak Normal file
View File

@ -0,0 +1,76 @@
# This makefile creates the JWasm Win32 binary with either MinGW or Cygwin.
# 'mingw32-make -f GccWin.mak' will use MinGW (no MSys needed!).
# 'make -f GccWin.mak CYGWIN=1' will use Cygwin.
#
# As for MinGW: you don't need MSYS - just run mingw32-make.exe. However,
# the MinGW 'bin' subdirectory has to be in your path.
name = jwasm
ifndef CYGWIN
CYGWIN=0
endif
ifndef DEBUG
DEBUG=0
endif
inc_dirs = -IH
#cflags stuff
ifeq ($(DEBUG),1)
extra_c_flags = -DDEBUG_OUT -g
lflagsd=
ifeq ($(CYGWIN),1)
OUTD=CygwinD
else
OUTD=MinGWD
endif
else
extra_c_flags = -DNDEBUG -O2 -fomit-frame-pointer
lflagsd=-s
ifeq ($(CYGWIN),1)
OUTD=CygwinR
else
OUTD=MinGWR
endif
endif
c_flags = -D__NT__ $(extra_c_flags)
CC=gcc.exe -c $(inc_dirs) $(c_flags)
LINK=gcc.exe
$(OUTD)/%.o: %.c
$(CC) -o $(OUTD)/$*.o $<
include gccmod.inc
TARGET1=$(OUTD)/$(name).exe
ALL: $(OUTD) $(TARGET1)
$(OUTD):
mkdir $(OUTD)
$(OUTD)/$(name).exe : $(OUTD)/main.o $(proj_obj)
$(LINK) $(OUTD)/main.o $(proj_obj) $(lflagsd) -o $(OUTD)/$(name).exe -Wl,-Map,$(OUTD)/$(name).map
$(OUTD)/msgtext.o: msgtext.c H/msgdef.h
$(CC) -o $(OUTD)/msgtext.o msgtext.c
$(OUTD)/reswords.o: reswords.c H/instruct.h H/special.h H/directve.h
$(CC) -o $(OUTD)/reswords.o reswords.c
######
clean:
@rm $(OUTD)/*.exe
@rm $(OUTD)/*.o
@rm $(OUTD)/*.map

53
GccWin64.mak Normal file
View File

@ -0,0 +1,53 @@
# This makefile creates a Win64 binary of JWasm with MinGW-w64.
# 'make -f GccWin64.mak'
name = jwasm
ifndef DEBUG
DEBUG=0
endif
inc_dirs = -IH
#cflags stuff
ifeq ($(DEBUG),1)
extra_c_flags = -DDEBUG_OUT -g
OUTD=MinGW-w64D
else
extra_c_flags = -DNDEBUG -O2
OUTD=MinGW-w64R
endif
c_flags = -D__NT__ $(extra_c_flags)
CC=x86_64-w64-mingw32-gcc.exe -c $(inc_dirs) $(c_flags)
$(OUTD)/%.o: %.c
$(CC) -o $(OUTD)/$*.o $<
include gccmod.inc
TARGET1=$(OUTD)/$(name).exe
ALL: $(OUTD) $(TARGET1)
$(OUTD):
mkdir $(OUTD)
$(OUTD)/$(name).exe : $(OUTD)/main.o $(proj_obj)
x86_64-w64-mingw32-gcc.exe $(OUTD)/main.o $(proj_obj) -s -o $(OUTD)/$(name).exe -Wl,-Map,$(OUTD)/$(name).map
$(OUTD)/msgtext.o: msgtext.c H/msgdef.h
$(CC) -o $(OUTD)/msgtext.o msgtext.c
$(OUTD)/reswords.o: reswords.c H/instruct.h H/special.h H/directve.h
$(CC) -o $(OUTD)/reswords.o reswords.c
######
clean:
@rm $(OUTD)/*.exe
@rm $(OUTD)/*.obj
@rm $(OUTD)/*.map

84
H/assume.h Normal file
View File

@ -0,0 +1,84 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: declarations for assume.c
*
****************************************************************************/
#ifndef _ASSUME_H_
#define _ASSUME_H_
/* flags for error field, used for GPR's ASSUME:ERROR|NOTHING */
enum err_flags {
RL_ERROR = 0x01,
RX_ERROR = 0x02,
ERX_ERROR = 0x04,
RRX_ERROR = 0x08,
RH_ERROR = 0x10
};
struct assume_info {
struct asym *symbol; /* segment, group or type that is to
be associated with the register */
unsigned char error; /* register assumed to ERROR */
unsigned char is_flat; /* register assumed to FLAT */
};
/* v2.05: introduced */
struct stdassume_typeinfo {
struct asym *type;
struct asym *target_type;
enum memtype mem_type;
unsigned char ptr_memtype;
unsigned char is_ptr;
};
/* segment assume table is sorted by seg reg number: ES,CS,SS,DS,FS,GS.
* see enum assume_segreg in globals.h.
*/
extern struct assume_info SegAssumeTable[];
/* standard register assume table; contains 8/16 entries for the GPRs */
extern struct assume_info StdAssumeTable[];
#define NUM_SEGREGS 6
extern void AssumeInit( int ); /* init assume tables */
extern enum assume_segreg search_assume( const struct asym *sym, enum assume_segreg def, bool search_grps );
extern enum assume_segreg GetAssume( const struct asym *, const struct asym *, enum assume_segreg, struct asym * * );
extern struct asym *GetOverrideAssume( enum assume_segreg );
extern struct asym *GetStdAssume( int );
extern struct asym *GetStdAssumeEx( int );
extern void ModelAssumeInit( void );
extern void SetSegAssumeTable( void * );
extern void GetSegAssumeTable( void * );
extern void SetStdAssumeTable( void *, struct stdassume_typeinfo * );
extern void GetStdAssumeTable( void *, struct stdassume_typeinfo * );
#endif

7
H/atofloat.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef ATOFLOAT_H
#define ATOFLOAT_H
extern void atofloat( void *, const char *, unsigned, bool, uint_8 );
#endif

17
H/bin.h Normal file
View File

@ -0,0 +1,17 @@
/****************************************************************************
*
* Description: header for BIN output format
*
****************************************************************************/
#ifndef _BIN_H_INCLUDED_
#define _BIN_H_INCLUDED_
void bin_init( struct module_info * );
#if PE_SUPPORT
void pe_create_PE_header( void );
#endif
#endif // _BIN_H_INCLUDED_

42
H/bool.h Normal file
View File

@ -0,0 +1,42 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: defines bool, TRUE and FALSE
* This file is included by globals.h
*
****************************************************************************/
#if !defined( BOOL_DEFINED ) && !defined( bool ) && !(__WATCOMC__ >= 1070 && defined(__cplusplus))
#define BOOL_DEFINED
typedef unsigned char bool;
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif

14
H/cmdline.h Normal file
View File

@ -0,0 +1,14 @@
/****************************************************************************
*
* Description: prototypes of cmdline.c
*
****************************************************************************/
#ifdef __SW_BD
#define EXPQUAL __stdcall
#else
#define EXPQUAL
#endif
extern char * EXPQUAL ParseCmdline( const char **cmdline, int * );
extern void EXPQUAL CmdlineFini( void );

135
H/codegen.h Normal file
View File

@ -0,0 +1,135 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: definitions for code generator interface
*
****************************************************************************/
#ifndef _CODEGEN_H_INCLUDED
#define _CODEGEN_H_INCLUDED
#define BIT_012 0x07
#define BIT_345 0x38
#define BIT_67 0xC0
#define NOT_BIT_012 0xF8
#define NOT_BIT_345 0xC7 /* mask to filter Mod- and R/M-bits for ModRM-byte */
#define NOT_BIT_67 0x3F
#define MOD_00 0x00
#define MOD_01 0x40
#define MOD_10 0x80
#define MOD_11 0xC0
/* opcode bits:
* 0: w/ide bit, operand size BYTE <-> D/WORD
* 1: s/ign bit, sign extended immediate
* 1: d/irection bit
*/
#define W_BIT 0x01
#define NOT_W_BIT 0xFE
#define ADRSIZ 0x67
#define OPSIZ 0x66
#define OP_WAIT 0x9B
#define EXTENDED_OPCODE 0x0F
#define OP_NOP 0x90
#define RM_BX_SI 0x00
#define RM_BX_DI 0x01
#define RM_BP_SI 0x02
#define RM_BP_DI 0x03
#define RM_SI 0x04
#define RM_DI 0x05
#define RM_BP 0x06
#define RM_BX 0x07
#define RM_SIB 0x04
#define RM_D32 0x05 /* direct 32 */
#define RM_D16 0x06 /* direct 16 */
#define SCALE_FACTOR_1 0x00
#define SCALE_FACTOR_2 0x40
#define SCALE_FACTOR_4 0x80
#define SCALE_FACTOR_8 0xC0
#define FPE_MIN 0xD8
#define FPE_MAX 0xDF
#define IS_MEM_TYPE( op, typ ) ( (op) == MT_##typ || (op) == MT_S##typ )
#define IS_MEMTYPE_SIZ( op, siz ) ( ( ( (op) & MT_SPECIAL_MASK ) < MT_SPECIAL ) && ( ( (op) & MT_SIZE_MASK ) == ( siz - 1 ) ) )
/*
* values for <byte1_info>
* 000 : the first byte is opcode, follow by rm_byte
* F_16 : the first byte is OPSIZ prefix if in use32 segment
* F_32 : the first byte is OPSIZ prefix if in use16 segment
* F_0F : the first byte is 0x0F, follow by opcode and rm_byte
* the entries must be sorted related to F_0F prefix:
* entries < F_0F emit NO 0F prefix, entries >= F_0F emit one.
* v2.06: magnitude of this field extended to 8 (previously 4).
* the entries with 38/3A must be last in the 0F group!
*/
enum byte1_info {
F_16 = 1, /* 16bit variant, 66h switches */
F_32, /* 32bit variant, 66h switches */
F_16A, /* 16bit variant, 67h switches */
F_32A, /* 32bit variant, 67h switches */
F_F3, /* F3 prefix (pause: F3 90) */
#if AMD64_SUPPORT
F_48, /* REX.W prefix */
#endif
F_0F = 16, /* 0F escape */
F_0F0F, /* AMD 3DNow "prefix" */
F_660F, /* SSEx prefix 1 */
F_F20F, /* SSEx prefix 2 */
F_F30F, /* SSEx prefix 3 */
F_0FNO66, /* 0F escape, no size prefix */
#if AMD64_SUPPORT
F_480F, /* REX.W + 0F prefix ( cmpxchg16b ) */
#endif
F_0F38, /* must be first of 38/3A variants */
F_0F3A,
F_660F38,
F_660F3A,
F_F20F38,
};
#if AVXSUPP
/* VX_NND is only needed if instruction has more than 2 operands */
enum vex_info {
VX_L = 0x01, /* VEX.L supported */
VX_NND = 0x02, /* VEX.NDS/NDD not supported */
VX_DST = 0x04, /* VEX.NDD (if op3 is an immediate) */
VX_IMM = 0x08, /* no VEX.NDS if op3 is an immediate */
VX_NMEM = 0x10, /* no VEX.NDS if op1 is a mem ref (vmovs[d|s], vmov[h|l]p[d|s] ) */
VX_HALF = 0x20, /* op2 is half-sized */
};
#endif
extern ret_code codegen( struct code_info *, uint_32 );
#endif

14
H/coff.h Normal file
View File

@ -0,0 +1,14 @@
/* prototypes of functions defined in coff.c */
#ifndef _COFF_H_INCLUDED
#define _COFF_H_INCLUDED
struct qditem {
uint_8 *next;
unsigned size;
};
extern void coff_init( struct module_info * );
#endif

288
H/coffspec.h Normal file
View File

@ -0,0 +1,288 @@
/* the MS COFF declarations, as far as it's relevant for JWasm.
* The full declarations can be found in MS PSDK, WinNT.h.
*/
/* Machine values */
#define IMAGE_FILE_MACHINE_I386 0x014c /* Intel 386 or later processors */
#define IMAGE_FILE_MACHINE_AMD64 0x8664 /* AMD64 (K8) */
/* Characteristics flags */
#define IMAGE_FILE_RELOCS_STRIPPED 0x0001 // no relocations
#define IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // is executable
#define IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // no line number info
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // no local symbols
#define IMAGE_FILE_LARGE_ADDRESS_AWARE 0x0020 // App can handle >2gb addresses
#define IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine.
struct IMAGE_FILE_HEADER {
uint_16 Machine;
uint_16 NumberOfSections;
uint_32 TimeDateStamp;
uint_32 PointerToSymbolTable;
uint_32 NumberOfSymbols;
uint_16 SizeOfOptionalHeader;
uint_16 Characteristics;
};
#define IMAGE_SIZEOF_SHORT_NAME 8
struct IMAGE_SECTION_HEADER {
char Name[IMAGE_SIZEOF_SHORT_NAME];
union {
uint_32 PhysicalAddress;
uint_32 VirtualSize;
} Misc;
uint_32 VirtualAddress;
uint_32 SizeOfRawData;
uint_32 PointerToRawData;
uint_32 PointerToRelocations;
uint_32 PointerToLinenumbers;
uint_16 NumberOfRelocations;
uint_16 NumberOfLinenumbers;
uint_32 Characteristics;
};
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
#define IMAGE_SCN_TYPE_REG 0
#define IMAGE_SCN_TYPE_DSECT 1
#define IMAGE_SCN_TYPE_NOLOAD 2
#define IMAGE_SCN_TYPE_GROUP 4
#define IMAGE_SCN_TYPE_NO_PAD 8
#define IMAGE_SCN_TYPE_COPY 16
#define IMAGE_SCN_CNT_CODE 0x00000020
#define IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
#define IMAGE_SCN_LNK_OTHER 0x00000100
#define IMAGE_SCN_LNK_INFO 0x00000200
#define IMAGE_SCN_TYPE_OVER 0x00000400
#define IMAGE_SCN_LNK_REMOVE 0x00000800
#define IMAGE_SCN_LNK_COMDAT 0x00001000
#define IMAGE_SCN_GPREL 0x00008000 /* Valid only for IA64 */
#define IMAGE_SCN_MEM_FARDATA 0x00008000 /* Not in PECOFF v8 spec */
#define IMAGE_SCN_MEM_PURGEABLE 0x00020000
#define IMAGE_SCN_MEM_16BIT 0x00020000
#define IMAGE_SCN_MEM_LOCKED 0x00040000
#define IMAGE_SCN_MEM_PRELOAD 0x00080000
#define IMAGE_SCN_ALIGN_1BYTES 0x00100000
#define IMAGE_SCN_ALIGN_2BYTES 0x00200000
#define IMAGE_SCN_ALIGN_4BYTES 0x00300000
#define IMAGE_SCN_ALIGN_8BYTES 0x00400000
#define IMAGE_SCN_ALIGN_16BYTES 0x00500000
#define IMAGE_SCN_ALIGN_32BYTES 0x00600000
#define IMAGE_SCN_ALIGN_64BYTES 0x00700000
#define IMAGE_SCN_ALIGN_128BYTES 0x00800000
#define IMAGE_SCN_ALIGN_256BYTES 0x00900000
#define IMAGE_SCN_ALIGN_512BYTES 0x00a00000
#define IMAGE_SCN_ALIGN_1024BYTES 0x00b00000
#define IMAGE_SCN_ALIGN_2048BYTES 0x00c00000
#define IMAGE_SCN_ALIGN_4096BYTES 0x00d00000
#define IMAGE_SCN_ALIGN_8192BYTES 0x00e00000
#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000
#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000
#define IMAGE_SCN_MEM_NOT_PAGED 0x08000000
#define IMAGE_SCN_MEM_SHARED 0x10000000
#define IMAGE_SCN_MEM_EXECUTE 0x20000000
#define IMAGE_SCN_MEM_READ 0x40000000
#define IMAGE_SCN_MEM_WRITE 0x80000000
#pragma pack(push,2)
typedef struct _IMAGE_RELOCATION {
union {
uint_32 VirtualAddress;
uint_32 RelocCount;
};
uint_32 SymbolTableIndex;
uint_16 Type;
} IMAGE_RELOCATION;
#pragma pack(pop)
#define IMAGE_REL_I386_ABSOLUTE 0x0000 /* relocation is ignored */
#define IMAGE_REL_I386_DIR16 0x0001 /* 16bit VA */
#define IMAGE_REL_I386_REL16 0x0002 /* 16bit PC-relative offset */
#define IMAGE_REL_I386_DIR32 0x0006 /* 32bit VA */
#define IMAGE_REL_I386_DIR32NB 0x0007 /* 32bit RVA (IMAGEREL) */
#define IMAGE_REL_I386_SEG12 0x0009 /* ??? */
#define IMAGE_REL_I386_SECTION 0x000A /* 16bit section index */
#define IMAGE_REL_I386_SECREL 0x000B /* 32bit offset (SECTIONREL) */
#define IMAGE_REL_I386_TOKEN 0x000C /* CLR token */
#define IMAGE_REL_I386_SECREL7 0x000D /* 7bit offset */
#define IMAGE_REL_I386_REL32 0x0014 /* 32bit PC-relative offset */
// X86-64 relocations
#define IMAGE_REL_AMD64_ABSOLUTE 0x0000 /* Reference is absolute, no relocation is necessary */
#define IMAGE_REL_AMD64_ADDR64 0x0001 /* 64-bit address (VA).*/
#define IMAGE_REL_AMD64_ADDR32 0x0002 /* 32-bit address (VA).*/
#define IMAGE_REL_AMD64_ADDR32NB 0x0003 /* 32-bit address w/o image base (RVA).*/
#define IMAGE_REL_AMD64_REL32 0x0004 /* 32-bit relative address from byte following reloc */
#define IMAGE_REL_AMD64_REL32_1 0x0005 /* 32-bit relative address from byte distance 1 from reloc */
#define IMAGE_REL_AMD64_REL32_2 0x0006 /* 32-bit relative address from byte distance 2 from reloc */
#define IMAGE_REL_AMD64_REL32_3 0x0007 /* 32-bit relative address from byte distance 3 from reloc */
#define IMAGE_REL_AMD64_REL32_4 0x0008 /* 32-bit relative address from byte distance 4 from reloc */
#define IMAGE_REL_AMD64_REL32_5 0x0009 /* 32-bit relative address from byte distance 5 from reloc */
#define IMAGE_REL_AMD64_SECTION 0x000A /* Section index */
#define IMAGE_REL_AMD64_SECREL 0x000B /* 32 bit offset from base of section containing target */
#define IMAGE_REL_AMD64_SECREL7 0x000C /* 7 bit unsigned offset from base of section containing target */
#define IMAGE_REL_AMD64_TOKEN 0x000D /* 32 bit metadata token */
#define IMAGE_SIZEOF_SYMBOL 18
#define IMAGE_SIZEOF_AUX_SYMBOL 18
#pragma pack(push,2)
typedef struct _IMAGE_SYMBOL {
union {
/* v2.08 */
//char ShortName[8];
uint_8 ShortName[8];
struct {
uint_32 Short;
uint_32 Long;
} Name;
/* v2.07: don't use pointers in COFF structures! */
//unsigned char *LongName[2];
uint_32 LongName[2];
} N;
uint_32 Value;
uint_16 SectionNumber;
uint_16 Type;
uint_8 StorageClass;
uint_8 NumberOfAuxSymbols;
} IMAGE_SYMBOL;
/* special section numbers */
#define IMAGE_SYM_UNDEFINED 0
#define IMAGE_SYM_ABSOLUTE (-1)
#define IMAGE_SYM_DEBUG (-2)
#define IMAGE_SYM_TYPE_NULL 0
#define IMAGE_SYM_TYPE_VOID 1
#define IMAGE_SYM_TYPE_CHAR 2
#define IMAGE_SYM_TYPE_SHORT 3
#define IMAGE_SYM_TYPE_INT 4
#define IMAGE_SYM_TYPE_LONG 5
#define IMAGE_SYM_TYPE_FLOAT 6
#define IMAGE_SYM_TYPE_DOUBLE 7
#define IMAGE_SYM_TYPE_STRUCT 8
#define IMAGE_SYM_TYPE_UNION 9
#define IMAGE_SYM_TYPE_ENUM 10
#define IMAGE_SYM_TYPE_MOE 11
#define IMAGE_SYM_TYPE_BYTE 12
#define IMAGE_SYM_TYPE_WORD 13
#define IMAGE_SYM_TYPE_UINT 14
#define IMAGE_SYM_TYPE_DWORD 15
#define IMAGE_SYM_TYPE_PCODE 32768
#define IMAGE_SYM_DTYPE_NULL 0
#define IMAGE_SYM_DTYPE_POINTER 1
#define IMAGE_SYM_DTYPE_FUNCTION 2
#define IMAGE_SYM_DTYPE_ARRAY 3
/* StorageClass values */
#define IMAGE_SYM_CLASS_END_OF_FUNCTION (-1)
#define IMAGE_SYM_CLASS_NULL 0
#define IMAGE_SYM_CLASS_AUTOMATIC 1
#define IMAGE_SYM_CLASS_EXTERNAL 2
#define IMAGE_SYM_CLASS_STATIC 3
#define IMAGE_SYM_CLASS_REGISTER 4
#define IMAGE_SYM_CLASS_EXTERNAL_DEF 5
#define IMAGE_SYM_CLASS_LABEL 6
#define IMAGE_SYM_CLASS_UNDEFINED_LABEL 7
#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8
#define IMAGE_SYM_CLASS_ARGUMENT 9
#define IMAGE_SYM_CLASS_STRUCT_TAG 10
#define IMAGE_SYM_CLASS_MEMBER_OF_UNION 11
#define IMAGE_SYM_CLASS_UNION_TAG 12
#define IMAGE_SYM_CLASS_TYPE_DEFINITION 13
#define IMAGE_SYM_CLASS_UNDEFINED_STATIC 14
#define IMAGE_SYM_CLASS_ENUM_TAG 15
#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16
#define IMAGE_SYM_CLASS_REGISTER_PARAM 17
#define IMAGE_SYM_CLASS_BIT_FIELD 18
#define IMAGE_SYM_CLASS_FAR_EXTERNAL 68 /* Not in PECOFF v8 spec */
#define IMAGE_SYM_CLASS_BLOCK 100
#define IMAGE_SYM_CLASS_FUNCTION 101
#define IMAGE_SYM_CLASS_END_OF_STRUCT 102
#define IMAGE_SYM_CLASS_FILE 103
#define IMAGE_SYM_CLASS_SECTION 104
#define IMAGE_SYM_CLASS_WEAK_EXTERNAL 105
#define IMAGE_SYM_CLASS_CLR_TOKEN 107
/* values for IMAGE_AUX_SYMBOL.Section.Selection */
#define IMAGE_COMDAT_SELECT_NODUPLICATES 1
#define IMAGE_COMDAT_SELECT_ANY 2
#define IMAGE_COMDAT_SELECT_SAME_SIZE 3
#define IMAGE_COMDAT_SELECT_EXACT_MATCH 4
#define IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
#define IMAGE_COMDAT_SELECT_LARGEST 6
#define IMAGE_COMDAT_SELECT_NEWEST 7
/* values for IMAGE_AUX_SYMBOL.Sym.Characteristics(=TotalSize) */
#define IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
#define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
#define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
typedef union _IMAGE_AUX_SYMBOL {
/* AUX format 2: .bf and .ef entries */
struct {
uint_32 TagIndex;
union {
struct {
uint_16 Linenumber;
uint_16 Size;
} LnSz;
uint_32 TotalSize;
} Misc;
union {
struct {
uint_32 PointerToLinenumber;
uint_32 PointerToNextFunction;
} Function;
struct {
uint_16 Dimension[4];
} Array;
} FcnAry;
uint_16 TvIndex;
} Sym;
/* AUX format 4: file entries */
struct {
/* v2.08 */
//char Name[IMAGE_SIZEOF_SYMBOL];
uint_8 Name[IMAGE_SIZEOF_SYMBOL];
} File;
/* AUX format 5: section entries */
struct {
uint_32 Length;
uint_16 NumberOfRelocations;
uint_16 NumberOfLinenumbers;
uint_32 CheckSum;
uint_16 Number;
uint_8 Selection;
} Section;
} IMAGE_AUX_SYMBOL;
#pragma pack(pop)
typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
uint_32 NumberOfSymbols;
uint_32 LvaToFirstSymbol;
uint_32 NumberOfLinenumbers;
uint_32 LvaToFirstLinenumber;
uint_32 RvaToFirstByteOfCode;
uint_32 RvaToLastByteOfCode;
uint_32 RvaToFirstByteOfData;
uint_32 RvaToLastByteOfData;
} IMAGE_COFF_SYMBOLS_HEADER;
#pragma pack(push,2)
typedef struct _IMAGE_LINENUMBER {
union {
uint_32 SymbolTableIndex;
uint_32 VirtualAddress;
} Type;
uint_16 Linenumber;
} IMAGE_LINENUMBER;
#pragma pack(pop)

59
H/condasm.h Normal file
View File

@ -0,0 +1,59 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: prototypes for conditional assembly and errors
*
****************************************************************************/
#ifndef _CONDASM_H_
#define _CONDASM_H_
enum if_state {
BLOCK_ACTIVE, /* current cond is true */
BLOCK_INACTIVE, /* current IF cond is false, looking for elseif */
BLOCK_DONE /* done TRUE section of current if, just nuke
everything until we see an endif */
};
enum cond_class {
CC_NULL,
CC_NUMARG,
CC_LITARG,
CC_BLKARG,
CC_SYMARG,
CC_PASS1,
CC_PASS2,
};
extern enum if_state CurrIfState;
extern void conditional_assembly_prepare( int );
extern int GetIfNestLevel( void );
extern void SetIfNestLevel( int );
extern void CondCheckOpen( void );
extern void CondInit( void );
#endif

17
H/context.h Normal file
View File

@ -0,0 +1,17 @@
/****************************************************************************
*
* Description: PUSHCONTEXT/POPCONTEXT interface
*
****************************************************************************/
#ifndef _CONTEXT_H_
#define _CONTEXT_H_
/*---------------------------------------------------------------------------*/
extern void ContextInit( int );
#if FASTMEM==0
extern void ContextFini( void );
#endif
#endif

13
H/cpumodel.h Normal file
View File

@ -0,0 +1,13 @@
/****************************************************************************
*
* Description: prototypes for cpumodel.c
*
****************************************************************************/
#ifndef _CPUMODEL_H_INCLUDED_
#define _CPUMODEL_H_INCLUDED_
extern ret_code SetCPU( enum cpu_info );
#endif

7
H/data.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef DATA_H
#define DATA_H
extern ret_code data_dir( int, struct asm_tok[], struct asym * );
#endif

725
H/dbgcv.h Normal file
View File

@ -0,0 +1,725 @@
/****************************************************************************
*
* This code is Public Domain. It's new for JWasm.
*
* ========================================================================
*
* Description: MS codeview debug info header. Values and structures
* in this header are derived from document:
* "Microsoft Symbol and Type Information"
* Format Specifications for Windows Version 1.0
* Tool Interface Standards (TIS)
*
* CV 5 format is described in
* "Visual C++ 5.0 Symbolic Debug Information Specification";
* the doc is available in MSDN libraries ( 199?-2001 ).
*
* CV 8 is not "officially" described.
* It's an extended CV5 format - 'names' are no longer
* prefixed by a 1-byte length, instead they are terminated
* by a x'00 (asciiz).
* Additionally, the $$SYMBOLS segment has now sub-sections
* for filenames, files, linenumbers and symbols.
****************************************************************************/
#ifndef CVDBG_H
#define CVDBG_H 1
#define CV4_SIGNATURE 1
#define CV5_SIGNATURE 2
#define CV8_SIGNATURE 4 /* not yet supported */
#define CV_SIGNATURE CV4_SIGNATURE /* default is CV4 */
/* reserved primitive types (0x0000-0x0FFF) */
struct cv_primitive_type {
uint_16 size:3, /* see CV_PDS_ below */
reserved:1, /* added to size in CV8? */
type:4, /* see CV_PDT_ below */
mode:3, /* see CV_PDM_ below */
reserved2:1;
};
/* typeref type. for CV4, this is uint_16, for CV5/CV8, it's uint_32 */
#if CV_SIGNATURE==CV4_SIGNATURE
typedef uint_16 cv_typeref;
#else
typedef uint_32 cv_typeref;
#endif
/* bits 4-7 of predefined primitive types */
enum cv_predef_type_types {
CV_PDT_SPECIAL = 0x00, /* CV_PDS_SPECIAL_xxx */
CV_PDT_SIGNED_INTEGRAL = 0x01, /* CV_PDS_INTEGRAL_xxx */
CV_PDT_UNSIGNED_INTEGRAL = 0x02, /* CV_PDS_INTEGRAL_xxx */
CV_PDT_BOOLEAN = 0x03, /* CV_PDS_INTEGRAL_xxx */
CV_PDT_REAL = 0x04, /* CV_PDS_REAL_xxx */
CV_PDT_COMPLEX = 0x05, /* CV_PDS_REAL_xxx */
CV_PDT_SPECIAL2 = 0x06, /* CV_PDS_SPECIAL2_xxx */
CV_PDT_REAL_INT_VALUE = 0x07 /* CV_PDS_REAL_INT_xxx */
/* values 08-0F are reserved */
};
/* bits 0-2 of predefined primitive types */
enum cv_predef_type_sizes {
CV_PDS_SPECIAL_NO_TYPE = 0x00,
CV_PDS_SPECIAL_ABSOLUTE = 0x01,
CV_PDS_SPECIAL_SEGMENT = 0x02,
CV_PDS_SPECIAL_VOID = 0x03,
CV_PDS_SPECIAL_BASIC_CURRENCY = 0x04,
CV_PDS_SPECIAL_BASIC_NEAR_STRING = 0x05,
CV_PDS_SPECIAL_BASIC_FAR_STRING = 0x06,
CV_PDS_SPECIAL_UNTRANSLATED = 0x07,
CV_PDS_INTEGRAL_1BYTE = 0x00,
CV_PDS_INTEGRAL_2BYTE = 0x01,
CV_PDS_INTEGRAL_4BYTE = 0x02,
CV_PDS_INTEGRAL_8BYTE = 0x03,
/* values 4-7 reserved */
CV_PDS_REAL_32BIT = 0x00,
CV_PDS_REAL_64BIT = 0x01,
CV_PDS_REAL_80BIT = 0x02,
CV_PDS_REAL_128BIT = 0x03,
CV_PDS_REAL_48BIT = 0x04,
/* values 5-7 reserved */
CV_PDS_SPECIAL2_BIT = 0x00,
CV_PDS_SPECIAL2_PASCAL_CHAR = 0x01,
/* values 2-7 reserved? */
CV_PDS_REAL_INT_CHAR = 0x00,
CV_PDS_REAL_INT_WCHAR = 0x01,
CV_PDS_REAL_INT_SINT16 = 0x02,
CV_PDS_REAL_INT_UINT16 = 0x03,
CV_PDS_REAL_INT_SINT32 = 0x04,
CV_PDS_REAL_INT_UINT32 = 0x05,
CV_PDS_REAL_INT_SINT64 = 0x06,
CV_PDS_REAL_INT_UINT64 = 0x07,
};
/* bits 8-10 of predefined primitive types */
enum cv_predef_type_modes {
CV_PDM_DIRECT = 0x00,
CV_PDM_NEARPTR = 0x01,
CV_PDM_FARPTR = 0x02,
CV_PDM_HUGEPTR = 0x03,
CV_PDM_NEAR32PTR = 0x04,
CV_PDM_FAR32PTR = 0x05,
CV_PDM_NEAR64PTR = 0x06
/* value 7 reserved */
};
struct cv_attribute {
uint_16 access:2, /* see CV_ATTR_ACC_ below */
mprop:3, /* see CV_ATTR_MPR_ below */
pseudo:1,
noinherit:1,
noconstruct:1,
reserved:8;
};
enum cv_attr_access {
CV_ATTR_ACC_NOPROTECTION = 0,
CV_ATTR_ACC_PRIVATE = 1,
CV_ATTR_ACC_PROTECTED = 2,
CV_ATTR_ACC_PUBLIC = 3,
};
enum cv_attr_mprop {
CV_ATTR_MPR_VANILLA = 0,
CV_ATTR_MPR_VIRTUAL = 1,
CV_ATTR_MPR_STATIC = 2,
CV_ATTR_MPR_FRIEND = 3,
CV_ATTR_MPR_INTRO_VIRTUAL = 4,
CV_ATTR_MPR_PURE_VIRTUAL = 5,
CV_ATTR_MPR_PURE_INTRO_VIRTUAL = 6,
};
enum cv4_leaf_indices {
CV4_LF_MODIFIER = 0x0001,
CV4_LF_POINTER = 0x0002, /* emitted by jwasm */
CV4_LF_ARRAY = 0x0003, /* emitted by jwasm */
CV4_LF_CLASS = 0x0004,
CV4_LF_STRUCTURE = 0x0005, /* emitted by jwasm */
CV4_LF_UNION = 0x0006, /* emitted by jwasm */
CV4_LF_ENUM = 0x0007,
CV4_LF_PROCEDURE = 0x0008, /* not yet emitted by jwasm */
//CV4_LF_MFUNCTION = 0x0009,
//CV4_LF_VTSHAPE = 0x000A,
//CV4_LF_BARRAY = 0x000D,
CV4_LF_ARGLIST = 0x0201, /* not yet emitted by jwasm */
CV4_LF_FIELDLIST = 0x0204, /* emitted by jwasm */
CV4_LF_BITFIELD = 0x0206, /* emitted by jwasm */
CV4_LF_MEMBER = 0x0406, /* emitted by jwasm */
};
enum cv5_leaf_indices {
CV5_LF_POINTER = 0x1002,
CV5_LF_ARRAY = 0x1003,
CV5_LF_CLASS = 0x1004,
CV5_LF_STRUCTURE = 0x1005,
CV5_LF_UNION = 0x1006,
CV5_LF_ENUM = 0x1007,
CV5_LF_PROCEDURE = 0x1008,
CV5_LF_ARGLIST = 0x1201,
CV5_LF_FIELDLIST = 0x1203,
CV5_LF_BITFIELD = 0x1205,
CV5_LF_MEMBER = 0x1405,
};
enum cv8_leaf_indices {
CV8_LF_ARRAY = 0x1503,
CV8_LF_STRUCTURE = 0x1505,
CV8_LF_UNION = 0x1506,
CV8_LF_MEMBER = 0x150D,
};
enum cv_leaf_indices {
LF_MODIFIER = 0x0001,
LF_LABEL = 0x000E, /* emitted by jwasm */
#if CV_SIGNATURE==CV4_SIGNATURE
LF_POINTER = CV4_LF_POINTER,
LF_ARRAY = CV4_LF_ARRAY,
LF_CLASS = CV4_LF_CLASS,
LF_STRUCTURE = CV4_LF_STRUCTURE,
LF_UNION = CV4_LF_UNION,
LF_ENUM = CV4_LF_ENUM,
LF_PROCEDURE = CV4_LF_PROCEDURE,
LF_ARGLIST = CV4_LF_ARGLIST,
LF_FIELDLIST = CV4_LF_FIELDLIST,
LF_BITFIELD = CV4_LF_BITFIELD,
LF_MEMBER = CV4_LF_MEMBER,
#else
LF_POINTER = CV5_LF_POINTER,
LF_ARRAY = CV5_LF_ARRAY,
LF_CLASS = CV5_LF_CLASS,
LF_STRUCTURE = CV5_LF_STRUCTURE,
LF_UNION = CV5_LF_UNION,
LF_ENUM = CV5_LF_ENUM,
LF_PROCEDURE = CV5_LF_PROCEDURE,
LF_ARGLIST = CV5_LF_ARGLIST,
LF_FIELDLIST = CV5_LF_FIELDLIST,
LF_BITFIELD = CV5_LF_BITFIELD,
LF_MEMBER = CV5_LF_MEMBER,
#endif
LF_NUMERIC = 0x8000,
LF_CHAR = 0x8000,
LF_SHORT = 0x8001,
LF_USHORT = 0x8002,
LF_LONG = 0x8003,
LF_ULONG = 0x8004,
LF_PAD0 = 0xF0,
LF_PAD1 = 0xF1,
LF_PAD2 = 0xF2,
LF_PAD3 = 0xF3,
LF_PAD4 = 0xF4,
LF_PAD5 = 0xF5,
LF_PAD6 = 0xF6,
LF_PAD7 = 0xF7,
LF_PAD8 = 0xF8,
LF_PAD9 = 0xF9,
LF_PAD10 = 0xFA,
LF_PAD11 = 0xFB,
LF_PAD12 = 0xFC,
LF_PAD13 = 0xFD,
LF_PAD14 = 0xFE,
LF_PAD15 = 0xFF
};
struct cv_typerec {
uint_16 size;
uint_16 leaf;
};
/* values in attribute bits 0-4 */
enum cv_typerec_pointer_types {
CV_TYPE_PTRTYPE_NEAR = 0,
CV_TYPE_PTRTYPE_FAR = 1,
CV_TYPE_PTRTYPE_HUGE = 2,
CV_TYPE_PTRTYPE_BASED1 = 3,
CV_TYPE_PTRTYPE_BASED2 = 4,
CV_TYPE_PTRTYPE_BASED3 = 5,
CV_TYPE_PTRTYPE_BASED4 = 6,
CV_TYPE_PTRTYPE_BASED5 = 7,
CV_TYPE_PTRTYPE_BASED6 = 8,
CV_TYPE_PTRTYPE_BASED7 = 9,
CV_TYPE_PTRTYPE_NEAR32 = 10,
CV_TYPE_PTRTYPE_FAR32 = 11,
};
#pragma pack(push, 1)
struct cv_typerec_pointer { /* LF_POINTER v2.10: added */
struct cv_typerec tr;
uint_16 attribute;
union {
struct cv_primitive_type pptype; /* predefined primitive type */
cv_typeref type;
};
/* variant field ( size? ) */
};
struct cv_typerec_array { /* LF_ARRAY v2.10: added */
struct cv_typerec tr;
cv_typeref elemtype;
cv_typeref idxtype;
uint_16 length; /* numeric leaf */
// length-prefixed name
};
struct cv_typerec_structure { /* LF_STRUCTURE */
struct cv_typerec tr;
uint_16 count;
#if CV_SIGNATURE==CV4_SIGNATURE
cv_typeref field;
uint_16 property; /* see below */
cv_typeref dList; /* type of derivation list */
cv_typeref vshape;/* type of virtual function table shape descriptor */
#else
uint_16 property; /* see below */
cv_typeref field;
cv_typeref dList; /* type of derivation list */
cv_typeref vshape;/* type of virtual function table shape descriptor */
#endif
uint_16 length; /* numeric leaf, size of structure */
// length-prefixed name
};
/* property flags. some bits are for classes only */
enum cv_typerec_structure_property {
CVTSP_PACKED = 0x001, /* is packed */
CVTSP_CTOR = 0x002, /* has constructors or destructors */
CVTSP_OVEROPS = 0x004,
CVTSP_ISNESTED = 0x008, /* is nested class/structure */
CVTSP_CNESTED = 0x010, /* contains nested classes/structures */
CVTSP_OPASSIGN = 0x020, /* has overloaded assignment */
CVTSP_OPCAST = 0x040, /* has casting methods */
CVTSP_FWDREF = 0x080, /* is a forward ref */
CVTSP_SCOPED = 0x100, /* scoped definition */
};
struct cv_typerec_union { /* LF_UNION */
struct cv_typerec tr;
uint_16 count;
#if CV_SIGNATURE==CV4_SIGNATURE
cv_typeref field;
uint_16 property;
#else
uint_16 property;
cv_typeref field;
#endif
uint_16 length; /* numeric leaf */
// length-prefixed name
};
struct cv_typerec_procedure { /* LF_PROCEDURE */
struct cv_typerec tr;
cv_typeref rvtype; /* type of return value */
uint_8 call; /* call convention ( C, Pascal, Fastcall, Stdcall, Syscall, Thiscall ) */
uint_8 rsvd;
uint_16 numparams; /* number of parameters */
cv_typeref arglist;
};
struct cv_typerec_label { /* LF_LABEL */
struct cv_typerec tr;
uint_16 mode; /* see below, CV_TYPE_LABEL_ */
};
/* label flags (values for mode) */
enum cv_typerec_label_values {
CV_TYPE_LABEL_NEAR = 0x00,
CV_TYPE_LABEL_FAR = 0x04
};
struct cv_typerec_arglist { /* LF_ARGLIST */
struct cv_typerec tr;
uint_16 argcount;
//uint_16 indices[];
};
struct cv_typerec_fieldlist { /* LF_FIELDLIST */
struct cv_typerec tr;
};
struct cv_typerec_bitfield { /* LF_BITFIELD */
struct cv_typerec tr;
#if CV_SIGNATURE==CV4_SIGNATURE
uint_8 length;
uint_8 position;
cv_typeref type;
#else
cv_typeref type;
uint_8 length;
uint_8 position;
#endif
};
struct cv_typerec_member { /* LF_MEMBER */
uint_16 leaf;
#if CV_SIGNATURE==CV4_SIGNATURE
cv_typeref type;
struct cv_attribute attribute;
#else
struct cv_attribute attribute;
cv_typeref type;
#endif
uint_16 offset; /* numeric leaf */
// length-prefixed name
};
enum cv4_symbol_types {
CV4_S_REGISTER = 0x0002,
CV4_S_CONSTANT = 0x0003,
CV4_S_UDT = 0x0004,
CV4_S_BPREL32 = 0x0200,
CV4_S_LDATA32 = 0x0201,
CV4_S_GDATA32 = 0x0202,
//CV4_S_PUB32 = 0x0203,
CV4_S_LPROC32 = 0x0204,
CV4_S_GPROC32 = 0x0205,
//CV4_S_BLOCK32 = 0x0207,
CV4_S_REGREL32 = 0x020C,
CV4_S_LTHREAD32 = 0x020D,
CV4_S_GTHREAD32 = 0x020E,
};
/* CV5 symbol types.
* the new types > 0x1000 have a 4 byte typeref.
*/
enum cv5_symbol_types {
CV5_S_REGISTER = 0x1001,
CV5_S_CONSTANT = 0x1002,
CV5_S_UDT = 0x1003,
CV5_S_MANYREG = 0x1005,
CV5_S_BPREL32 = 0x1006,
CV5_S_LDATA32 = 0x1007,
CV5_S_GDATA32 = 0x1008,
//CV5_S_PUB32 = 0x1009,
CV5_S_LPROC32 = 0x100A,
CV5_S_GPROC32 = 0x100B,
CV5_S_REGREL32 = 0x100D,
CV5_S_LTHREAD32 = 0x100E,
CV5_S_GTHREAD32 = 0x100F,
CV5_S_COMPILE = 0x1013, /* not documented in VC50 Spec */
};
/* CV8 symbol types.
* this types also have a 4-byte typeref AND the name is
* in asciiz format, not 1-byte-length-prefixed.
*/
enum cv8_symbol_types {
CV8_S_OBJNAME = 0x1101, /* object filename */
CV8_S_BLOCK32 = 0x1103,
CV8_S_LABEL32 = 0x1105,
CV8_S_CONSTANT = 0x1107,
CV8_S_UDT = 0x1108,
CV8_S_BPREL32 = 0x110B,
CV8_S_LDATA32 = 0x110C,
CV8_S_GDATA32 = 0x110D,
CV8_S_LPROC32 = 0x110F,
CV8_S_GPROC32 = 0x1110,
CV8_S_REGREL32 = 0x1111,
CV8_S_LTHREAD32 = 0x1112,
CV8_S_GTHREAD32 = 0x1113,
};
enum cv_symbol_types {
S_COMPILE = 0x0001,
#if CV_SIGNATURE==CV4_SIGNATURE
S_REGISTER = CV4_S_REGISTER,
S_CONSTANT = CV4_S_CONSTANT,
S_UDT = CV4_S_UDT,
#else
S_REGISTER = CV5_S_REGISTER,
S_CONSTANT = CV5_S_CONSTANT,
S_UDT = CV5_S_UDT,
#endif
//S_SSEARCH = 0x0005, /* used by CVPACK */
S_ENDBLK = 0x0006, /* end of PROC, BLOCK, THUNK, WITH */
//S_SKIP = 0x0007,
//S_CVRES = 0x0008, /* reserved for CodeView */
S_OBJNAME = 0x0009, /* didn't change for CV5 ( CV8 is different ) */
//S_ENDARG = 0x000A, /* end of arguments, not needed */
//S_RETURN = 0x000D,
S_BPREL16 = 0x0100,
S_LDATA16 = 0x0101,
S_GDATA16 = 0x0102,
//S_PUB16 = 0x0103, /* emitted by linker */
S_LPROC16 = 0x0104,
S_GPROC16 = 0x0105,
//S_BLOCK16 = 0x0107,
S_LABEL16 = 0x0109,
//S_REGREL16 = 0x010C,
#if CV_SIGNATURE==CV4_SIGNATURE
S_BPREL32 = CV4_S_BPREL32,
S_LDATA32 = CV4_S_LDATA32,
S_GDATA32 = CV4_S_GDATA32,
//S_PUB32 = CV4_S_PUB32,
S_LPROC32 = CV4_S_LPROC32,
S_GPROC32 = CV4_S_GPROC32,
S_REGREL32 = CV4_S_REGREL32,
S_LTHREAD32 = CV4_S_LTHREAD32,
S_GTHREAD32 = CV4_S_GTHREAD32,
#else
S_BPREL32 = CV5_S_BPREL32,
S_LDATA32 = CV5_S_LDATA32,
S_GDATA32 = CV5_S_GDATA32,
//S_PUB32 = CV5_S_PUB32,
S_LPROC32 = CV5_S_LPROC32,
S_GPROC32 = CV5_S_GPROC32,
S_REGREL32 = CV5_S_REGREL32,
S_LTHREAD32 = CV5_S_LTHREAD32,
S_GTHREAD32 = CV5_S_GTHREAD32,
#endif
S_LABEL32 = 0x0209, /* didn't change for CV5 ( CV8 is different ) */
};
struct cv_symrec {
uint_16 size;
uint_16 type;
//uint_8 data[];
};
struct cv_symrec_compile { /* S_COMPILE */
struct cv_symrec sr;
uint_8 machine; /* see below enum cv_machines */
uint_8 Language; /* see below enum cv_languages */
union {
uint_16 flags;
struct {
uint_8 PCodePresent:1,
FloatPrecision:2,
Floatpackage:2,
AmbientData:3; /* see below enum cv_ambient_model */
uint_8 AmbientCode:3, /* see below enum cv_ambient_model */
Mode32:1,
Reserved:4;
};
};
// uint_8 version[]; /* length-prefixed string */
};
enum cv_machines {
CV_MACH_8080 = 0, /* ??? */
CV_MACH_8086 = 1, /* also 80186 */
CV_MACH_80286 = 2,
CV_MACH_80386 = 3,
CV_MACH_80486 = 4,
CV_MACH_PENTIUM = 5,
CV_MACH_P2 = 6, /* also Pentium Pro */
CV_MACH_P3 = 7,
CV_MACH_AMD64 = 0xD0,
};
enum cv_languages {
CV_LANG_C = 0,
CV_LANG_CPP = 1,
CV_LANG_FORTRAN = 2,
CV_LANG_MASM = 3,
CV_LANG_PASCAL = 4,
CV_LANG_BASIC = 5,
CV_LANG_COBOL = 6
};
enum cv_ambient_model {
CV_AMB_NEAR = 0,
CV_AMB_FAR = 1,
CV_AMB_HUGE = 2,
};
struct cv_symrec_register { /* S_REGISTER */
struct cv_symrec sr;
cv_typeref type;
uint_16 registr; /* low byte is register 1, high byte is (opt) register 2 */
// length-prefixed name
};
struct cv_symrec_constant { /* S_CONSTANT */
struct cv_symrec sr;
cv_typeref type;
uint_16 value; /* numeric leaf */
// length-prefixed name
};
struct cv_symrec_udt { /* S_UDT */
struct cv_symrec sr;
cv_typeref type;
// length-prefixed name
};
struct cv_symrec_endblk { /* S_ENDBLK */
struct cv_symrec sr;
};
struct cv_symrec_objname { /* S_OBJNAME */
struct cv_symrec sr;
uint_32 Signature;
// length-prefixed name
};
struct cv_symrec_bprel16 { /* S_BPREL16 */
struct cv_symrec sr;
int_16 offset;
cv_typeref type;
// length-prefixed name
};
struct cv_symrec_ldata16 { /* S_LDATA16, S_GDATA16 */
struct cv_symrec sr;
int_16 offset;
uint_16 segment;
cv_typeref type;
// length-prefixed name
};
struct cv_symrec_lproc16 { /* S_LPROC16, S_GPROC16 */
struct cv_symrec sr;
uint_32 pParent;
uint_32 pEnd;
uint_32 pNext;
uint_16 proc_length;
uint_16 debug_start;
uint_16 debug_end;
uint_16 offset;
uint_16 segment;
cv_typeref proctype; /* typeref */
uint_8 flags; /* see enum cv_proc_flags */
// length-prefixed name
};
enum cv_proc_flags {
CV_PROCF_FPO = 0x01, /* no frame pointer */
CV_PROCF_INTERRUPT = 0x02, /* proc is interrrupt routine */
CV_PROCF_FAR = 0x04, /* proc does FAR return */
CV_PROCF_NEVER = 0x08, /* proc does not return */
};
struct cv_symrec_label16 { /* S_LABEL16 */
struct cv_symrec sr;
int_16 offset;
uint_16 segment;
uint_8 flags; /* see enum cv_proc_flags */
// length-prefixed name
};
struct cv_symrec_bprel32 { /* S_BPREL32 */
struct cv_symrec sr;
int_32 offset;
cv_typeref type;
// length-prefixed name
};
struct cv_symrec_ldata32 { /* S_LDATA32, S_GDATA32 */
struct cv_symrec sr;
#if CV_SIGNATURE==CV4_SIGNATURE
int_32 offset;
uint_16 segment;
cv_typeref type;
#else
cv_typeref type;
int_32 offset;
uint_16 segment;
#endif
// length-prefixed name
};
struct cv_symrec_lproc32 { /* S_LPROC32, S_GPROC32 */
struct cv_symrec sr;
uint_32 pParent;
uint_32 pEnd;
uint_32 pNext;
uint_32 proc_length;
uint_32 debug_start;
uint_32 debug_end;
#if CV_SIGNATURE==CV4_SIGNATURE
uint_32 offset;
uint_16 segment;
cv_typeref proctype; /* typeref */
#else
cv_typeref proctype; /* typeref */
uint_32 offset;
uint_16 segment;
#endif
uint_8 flags; /* see enum cv_proc_flags */
// length-prefixed name
};
enum cv_registers {
CV_REG_START32 = 17, /* 17-24 are 32-bit GPRs */
CV_REG_ESP = CV_REG_START32+4,
CV_REG_EBP = CV_REG_START32+5,
#if AMD64_SUPPORT
CV_REG_AMD64_START32 = 360, /* 360-367 are 32-bit GPRs R8D-R15D - undocumented! */
CV_REG_AMD64_START64 = 328, /* 328-343 are 64-bit GPRs - undocumented! */
CV_REG_RSP = CV_REG_AMD64_START64+7,
CV_REG_RBP = CV_REG_AMD64_START64+6,
#endif
};
struct cv_symrec_regrel32 { /* S_REGREL32 */
struct cv_symrec sr;
int_32 offset;
#if CV_SIGNATURE==CV4_SIGNATURE
uint_16 reg;
cv_typeref type;
#else
cv_typeref type;
uint_16 reg;
#endif
// length-prefixed name
};
struct cv_symrec_label32 { /* S_LABEL32 */
struct cv_symrec sr;
int_32 offset;
uint_16 segment;
uint_8 flags; /* see enum cv_proc_flags */
// length-prefixed name
};
#if 0
/* CV8 declarations - not needed currently */
enum cv8_s_sections {
CV8_SYMBOLS = 0xF1,
CV8_LINNUM = 0xF2,
CV8_FILENAMES = 0xF3,
CV8_FILES = 0xF4,
CV8_SECTYP_F5 = 0xF5, /* unknown */
};
/* CV8 line numbers - not supported yet */
struct cv8_linenumber_item {
uint_32 offset;
uint_32 line;
};
struct cv8_linenumber_header {
uint_32 section_start;
uint_16 section_index;
uint_32 section_length;
uint_32 src_file;
uint_32 num_items; /* number of cv8_linenumber_info items */
uint_32 length;
};
#endif
#pragma pack(pop)
#endif

642
H/dbgdw.h Normal file
View File

@ -0,0 +1,642 @@
/* ----------------------------------------------------------------------- *
*
* DWARF declarations
*
* ----------------------------------------------------------------------- */
#ifndef DBGDW_H
#define DBGDW_H
/* tags - values according to dwarf documentation v4, section 7 */
enum dwarf_tag {
DW_TAG_array_type = 0x01,
DW_TAG_class_type = 0x02,
DW_TAG_entry_point = 0x03,
DW_TAG_enumeration_type = 0x04,
DW_TAG_formal_parameter = 0x05,
DW_TAG_imported_declaration = 0x08,
DW_TAG_label = 0x0a,
DW_TAG_lexical_block = 0x0b,
DW_TAG_member = 0x0d,
DW_TAG_pointer_type = 0x0f,
DW_TAG_reference_type = 0x10,
DW_TAG_compile_unit = 0x11,
DW_TAG_string_type = 0x12,
DW_TAG_structure_type = 0x13,
DW_TAG_subroutine_type = 0x15,
DW_TAG_typedef,
DW_TAG_union_type,
DW_TAG_unspecified_parameters,
DW_TAG_variant,
DW_TAG_common_block,
DW_TAG_common_inclusion,
DW_TAG_inheritance,
DW_TAG_inlined_subroutine,
DW_TAG_module,
DW_TAG_ptr_to_member_type,
DW_TAG_set_type,
DW_TAG_subrange_type,
DW_TAG_with_stmt,
DW_TAG_access_declaration,
DW_TAG_base_type,
DW_TAG_catch_block,
DW_TAG_const_type,
DW_TAG_constant,
DW_TAG_enumerator,
DW_TAG_file_type,
DW_TAG_friend,
DW_TAG_namelist,
DW_TAG_namelist_item,
DW_TAG_packed_type,
DW_TAG_subprogram,
DW_TAG_template_type_parameter,
DW_TAG_template_value_parameter,
DW_TAG_thrown_type,
DW_TAG_try_block,
DW_TAG_variant_part,
DW_TAG_variable,
DW_TAG_volatile_type,
DW_TAG_dwarf_procedure,
DW_TAG_restrict_type,
DW_TAG_interface_type,
DW_TAG_namespace,
DW_TAG_imported_module,
DW_TAG_unspecified_type,
DW_TAG_partial_unit,
DW_TAG_imported_unit,
DW_TAG_condition,
DW_TAG_shared_type,
DW_TAG_type_unit, /* new since v4 */
DW_TAG_rvalue_reference_type,
DW_TAG_template_alias,
DW_TAG_lo_user = 0x4080,
DW_TAG_hi_user = 0xffff,
};
enum dwarf_child_determination {
DW_CHILDREN_no = 0x00,
DW_CHILDREN_yes = 0x01,
};
enum dwarf_attribute {
DW_AT_sibling = 0x01,
DW_AT_location = 0x02,
DW_AT_name = 0x03,
DW_AT_ordering = 0x09,
DW_AT_byte_size = 0x0b,
DW_AT_bit_offset = 0x0c,
DW_AT_bit_size = 0x0d,
DW_AT_stmt_list = 0x10,
DW_AT_low_pc = 0x11,
DW_AT_high_pc = 0x12,
DW_AT_language = 0x13,
DW_AT_discr = 0x15,
DW_AT_discr_value = 0x16,
DW_AT_visibility = 0x17,
DW_AT_import = 0x18,
DW_AT_string_length = 0x19,
DW_AT_common_reference = 0x1a,
DW_AT_comp_dir = 0x1b,
DW_AT_const_value = 0x1c,
DW_AT_containing_type = 0x1d,
DW_AT_default_value = 0x1e,
DW_AT_inline = 0x20,
DW_AT_is_optional = 0x21,
DW_AT_lower_bound = 0x22,
DW_AT_producer = 0x25,
DW_AT_prototyped = 0x27,
DW_AT_return_addr = 0x2a,
DW_AT_start_scope = 0x2c,
DW_AT_bit_stride = 0x2e,
DW_AT_upper_bound = 0x2f,
DW_AT_abstract_origin = 0x31,
DW_AT_accessibility = 0x32,
DW_AT_address_class = 0x33,
DW_AT_artificial = 0x34,
DW_AT_base_types = 0x35,
DW_AT_calling_convention= 0x36,
DW_AT_count = 0x37,
DW_AT_data_member_location = 0x38,
DW_AT_decl_column = 0x39,
DW_AT_decl_file = 0x3a,
DW_AT_decl_line = 0x3b,
DW_AT_declaration = 0x3c,
DW_AT_discr_list = 0x3d,
DW_AT_encoding = 0x3e,
DW_AT_external = 0x3f,
DW_AT_frame_base = 0x40,
DW_AT_friend = 0x41,
DW_AT_identifier_case = 0x42,
DW_AT_macro_info = 0x43,
DW_AT_namelist_item = 0x44,
DW_AT_priority = 0x45,
DW_AT_segment = 0x46,
DW_AT_specification = 0x47,
DW_AT_static_link = 0x48,
DW_AT_type = 0x49,
DW_AT_use_location = 0x4a,
DW_AT_variable_parameter = 0x4b,
DW_AT_virtuality = 0x4c,
DW_AT_vtable_elem_location = 0x4d,
DW_AT_allocated = 0x4e,
DW_AT_associated = 0x4f,
DW_AT_data_location = 0x50,
DW_AT_byte_stride = 0x51,
DW_AT_entry_pc = 0x52,
DW_AT_use_UTF8 = 0x53,
DW_AT_extension = 0x54,
DW_AT_ranges = 0x55,
DW_AT_trampoline = 0x56,
DW_AT_call_column = 0x57,
DW_AT_call_file = 0x58,
DW_AT_call_line = 0x59,
DW_AT_description = 0x5a,
DW_AT_binary_scale = 0x5b,
DW_AT_decimal_scale = 0x5c,
DW_AT_small = 0x5d,
DW_AT_decimal_sign = 0x5e,
DW_AT_digit_count = 0x5f,
DW_AT_picture_string = 0x60,
DW_AT_mutable = 0x61,
DW_AT_threads_scaled = 0x62,
DW_AT_explicit = 0x63,
DW_AT_object_pointer = 0x64,
DW_AT_endianity = 0x65,
DW_AT_elemental = 0x66,
DW_AT_pure = 0x67,
DW_AT_recursive = 0x68,
DW_AT_signature = 0x69, /* since v4 */
DW_AT_main_subprogram = 0x6a,
DW_AT_data_bit_offset = 0x6b,
DW_AT_const_expr = 0x6c,
DW_AT_enum_class = 0x6d,
DW_AT_linkage_name = 0x6e,
DW_AT_lo_user = 0x2000,
DW_AT_hi_user = 0x3fff,
};
enum dwarf_information_format {
DW_FORM_addr = 0x01,
DW_FORM_block2 = 0x03,
DW_FORM_block4 = 0x04,
DW_FORM_data2 = 0x05,
DW_FORM_data4 = 0x06,
DW_FORM_data8 = 0x07,
DW_FORM_string = 0x08,
DW_FORM_block = 0x09,
DW_FORM_block1 = 0x0a,
DW_FORM_data1 = 0x0b,
DW_FORM_flag = 0x0c,
DW_FORM_sdata = 0x0d,
DW_FORM_strp = 0x0e,
DW_FORM_udata = 0x0f,
DW_FORM_ref_addr = 0x10,
DW_FORM_ref1 = 0x11,
DW_FORM_ref2 = 0x12,
DW_FORM_ref4 = 0x13,
DW_FORM_ref8 = 0x14,
DW_FORM_ref_udata = 0x15,
DW_FORM_indirect = 0x16,
DW_FORM_sec_offset = 0x17, /* since v4 */
DW_FORM_excploc = 0x18,
DW_FORM_flag_present = 0x19,
DW_FORM_ref_sig8 = 0x1a, /* in documentation, value is 0x20 ( probably typo ) */
};
/* operation encodings in dwarf expressions */
enum dwarf_op {
DW_OP_addr = 0x03,
DW_OP_deref = 0x06,
DW_OP_const1u = 0x08,
DW_OP_const1s = 0x09,
DW_OP_const2u = 0x0a,
DW_OP_const2s = 0x0b,
DW_OP_const4u = 0x0c,
DW_OP_const4s = 0x0d,
DW_OP_const8u = 0x0e,
DW_OP_const8s = 0x0f,
DW_OP_constu = 0x10,
DW_OP_consts = 0x11,
DW_OP_dup = 0x12,
DW_OP_drop = 0x13,
DW_OP_over = 0x14,
DW_OP_pick = 0x15,
DW_OP_swap = 0x16,
DW_OP_rot = 0x17,
DW_OP_xderef = 0x18,
DW_OP_abs = 0x19,
DW_OP_and = 0x1a,
DW_OP_div = 0x1b,
DW_OP_minus = 0x1c,
DW_OP_mod = 0x1d,
DW_OP_mul = 0x1e,
DW_OP_neg = 0x1f,
DW_OP_not = 0x20,
DW_OP_or = 0x21,
DW_OP_plus = 0x22,
DW_OP_plus_uconst = 0x23,
DW_OP_shl = 0x24,
DW_OP_shr = 0x25,
DW_OP_shra = 0x26,
DW_OP_xor = 0x27,
DW_OP_skip = 0x2f,
DW_OP_bra = 0x28,
DW_OP_eq = 0x29,
DW_OP_ge = 0x2a,
DW_OP_gt = 0x2b,
DW_OP_le = 0x2c,
DW_OP_lt = 0x2d,
DW_OP_ne = 0x2e,
DW_OP_lit0 = 0x30,
DW_OP_lit1 = 0x31,
DW_OP_lit2 = 0x32,
DW_OP_lit3 = 0x33,
DW_OP_lit4 = 0x34,
DW_OP_lit5 = 0x35,
DW_OP_lit6 = 0x36,
DW_OP_lit7 = 0x37,
DW_OP_lit8 = 0x38,
DW_OP_lit9 = 0x39,
DW_OP_lit10 = 0x3a,
DW_OP_lit11 = 0x3b,
DW_OP_lit12 = 0x3c,
DW_OP_lit13 = 0x3d,
DW_OP_lit14 = 0x3e,
DW_OP_lit15 = 0x3f,
DW_OP_lit16 = 0x40,
DW_OP_lit17 = 0x41,
DW_OP_lit18 = 0x42,
DW_OP_lit19 = 0x43,
DW_OP_lit20 = 0x44,
DW_OP_lit21 = 0x45,
DW_OP_lit22 = 0x46,
DW_OP_lit23 = 0x47,
DW_OP_lit24 = 0x48,
DW_OP_lit25 = 0x49,
DW_OP_lit26 = 0x4a,
DW_OP_lit27 = 0x4b,
DW_OP_lit28 = 0x4c,
DW_OP_lit29 = 0x4d,
DW_OP_lit30 = 0x4e,
DW_OP_lit31 = 0x4f,
DW_OP_reg0 = 0x50,
DW_OP_reg1 = 0x51,
DW_OP_reg2 = 0x52,
DW_OP_reg3 = 0x53,
DW_OP_reg4 = 0x54,
DW_OP_reg5 = 0x55,
DW_OP_reg6 = 0x56,
DW_OP_reg7 = 0x57,
DW_OP_reg8 = 0x58,
DW_OP_reg9 = 0x59,
DW_OP_reg10 = 0x5a,
DW_OP_reg11 = 0x5b,
DW_OP_reg12 = 0x5c,
DW_OP_reg13 = 0x5d,
DW_OP_reg14 = 0x5e,
DW_OP_reg15 = 0x5f,
DW_OP_reg16 = 0x60,
DW_OP_reg17 = 0x61,
DW_OP_reg18 = 0x62,
DW_OP_reg19 = 0x63,
DW_OP_reg20 = 0x64,
DW_OP_reg21 = 0x65,
DW_OP_reg22 = 0x66,
DW_OP_reg23 = 0x67,
DW_OP_reg24 = 0x68,
DW_OP_reg25 = 0x69,
DW_OP_reg26 = 0x6a,
DW_OP_reg27 = 0x6b,
DW_OP_reg28 = 0x6c,
DW_OP_reg29 = 0x6d,
DW_OP_reg30 = 0x6e,
DW_OP_reg31 = 0x6f,
DW_OP_breg0 = 0x70,
DW_OP_breg1 = 0x71,
DW_OP_breg2 = 0x72,
DW_OP_breg3 = 0x73,
DW_OP_breg4 = 0x74,
DW_OP_breg5 = 0x75,
DW_OP_breg6 = 0x76,
DW_OP_breg7 = 0x77,
DW_OP_breg8 = 0x78,
DW_OP_breg9 = 0x79,
DW_OP_breg10 = 0x7a,
DW_OP_breg11 = 0x7b,
DW_OP_breg12 = 0x7c,
DW_OP_breg13 = 0x7d,
DW_OP_breg14 = 0x7e,
DW_OP_breg15 = 0x7f,
DW_OP_breg16 = 0x80,
DW_OP_breg17 = 0x81,
DW_OP_breg18 = 0x82,
DW_OP_breg19 = 0x83,
DW_OP_breg20 = 0x84,
DW_OP_breg21 = 0x85,
DW_OP_breg22 = 0x86,
DW_OP_breg23 = 0x87,
DW_OP_breg24 = 0x88,
DW_OP_breg25 = 0x89,
DW_OP_breg26 = 0x8a,
DW_OP_breg27 = 0x8b,
DW_OP_breg28 = 0x8c,
DW_OP_breg29 = 0x8d,
DW_OP_breg30 = 0x8e,
DW_OP_breg31 = 0x8f,
DW_OP_regx = 0x90,
DW_OP_fbreg = 0x91,
DW_OP_bregx = 0x92,
DW_OP_piece = 0x93,
DW_OP_deref_size = 0x94,
DW_OP_xderef_size = 0x95,
DW_OP_nop = 0x96,
DW_OP_push_object_address = 0x97,
DW_OP_call2 = 0x98,
DW_OP_call4 = 0x99,
DW_OP_call_ref = 0x9a,
DW_OP_form_tls_address = 0x9b,
DW_OP_call_frame_cfa = 0x9c,
DW_OP_bit_piece = 0x9d,
DW_OP_implicit_value = 0x9e, /* since v4 */
DW_OP_stack_value = 0x9f,
DW_OP_lo_user = 0xe0,
DW_OP_hi_user = 0xff,
};
/* DW_AT_encoding */
enum dwarf_base_type_attribute_encoding {
DW_ATE_address = 0x01,
DW_ATE_boolean = 0x02,
DW_ATE_complex_float = 0x03,
DW_ATE_float = 0x04,
DW_ATE_signed = 0x05,
DW_ATE_signed_char = 0x06,
DW_ATE_unsigned = 0x07,
DW_ATE_unsigned_char = 0x08,
DW_ATE_imaginary_float = 0x09,
DW_ATE_packed_decimal = 0x0a,
DW_ATE_numeric_string = 0x0b,
DW_ATE_edited = 0x0c,
DW_ATE_signed_fixed = 0x0d,
DW_ATE_unsigned_fixed = 0x0e,
DW_ATE_decimal_float = 0x0f,
DW_ATE_UTF = 0x10, /* since v4 */
DW_ATE_lo_user = 0x80,
DW_ATE_hi_user = 0xff,
};
/* DW_AT_decimal_sign */
enum dwarf_decimal_sign {
DW_DS_unsigned = 0x01,
DW_DS_leading_overpunch = 0x02,
DW_DS_trailing_overpunch = 0x03,
DW_DS_leading_separate = 0x04,
DW_DS_trailing_separate = 0x05,
};
/* DW_AT_endianity */
enum dwarf_endianity {
DW_END_default = 0x00,
DW_END_big = 0x01,
DW_END_little = 0x02,
DW_END_lo_user = 0x40,
DW_END_hi_user = 0xff,
};
/* DW_AT_accessibility */
enum dwarf_accessibility {
DW_ACCESS_public = 0x01,
DW_ACCESS_protected = 0x02,
DW_ACCESS_private = 0x03,
};
/* DW_AT_visibility */
enum dwarf_visibility {
DW_VIS_local = 0x01,
DW_VIS_exported = 0x02,
DW_VIS_qualified = 0x03,
};
/* DW_AT_virtuality */
enum dwarf_virtuality {
DW_VIRTUALITY_none = 0x00,
DW_VIRTUALITY_virtual = 0x01,
DW_VIRTUALITY_pure_virtual = 0x02,
};
/* DW_AT_language */
enum dwarf_language {
DW_LANG_C89 = 0x0001,
DW_LANG_C = 0x0002,
DW_LANG_Ada83 = 0x0003,
DW_LANG_C_plus_plus = 0x0004,
DW_LANG_Cobol74 = 0x0005,
DW_LANG_Cobol85 = 0x0006,
DW_LANG_Fortran77 = 0x0007,
DW_LANG_Fortran90 = 0x0008,
DW_LANG_Pascal83 = 0x0009,
DW_LANG_Modula2 = 0x000a,
DW_LANG_Java = 0x000b,
DW_LANG_C99 = 0x000c,
DW_LANG_Ada95 = 0x000d,
DW_LANG_Fortran95 = 0x000e,
DW_LANG_PLI = 0x000f,
DW_LANG_ObjC = 0x0010,
DW_LANG_ObjC_plus_plus = 0x0011,
DW_LANG_UPC = 0x0012,
DW_LANG_D = 0x0013,
DW_LANG_Phyton = 0x0014, /* since v4 */
DW_LANG_lo_user = 0x8000,
DW_LANG_hi_user = 0xffff,
};
/* DW_AT_identifier_case */
enum dwarf_identifier_case {
DW_ID_case_sensitive = 0x00,
DW_ID_up_case = 0x01,
DW_ID_down_case = 0x02,
DW_ID_case_insensitive = 0x03,
};
/* DW_AT_calling_convention */
enum dwarf_calling_convention {
DW_CC_normal = 0x01,
DW_CC_program = 0x02,
DW_CC_nocall = 0x03,
DW_CC_lo_user = 0x40,
DW_CC_hi_user = 0xff,
};
/* DW_AT_inline */
enum dwarf_inline {
DW_INL_not_inlined = 0x00,
DW_INL_inlined = 0x01,
DW_INL_declared_not_inlined = 0x02,
DW_INL_declared_inlined = 0x03,
};
/* DW_AT_ordering */
enum dwarf_array_ordering {
DW_ORD_row_major = 0x00,
DW_ORD_col_major = 0x01,
};
/* DW_AT_discr_list */
enum dwarf_discriminant {
DW_DSC_label = 0x00,
DW_DSC_range = 0x01,
};
/* line number information standard opcodes (7.21) */
enum dwarf_line_number_standard {
DW_LNS_copy = 0x01,
DW_LNS_advance_pc = 0x02,
DW_LNS_advance_line = 0x03,
DW_LNS_set_file = 0x04,
DW_LNS_set_column = 0x05,
DW_LNS_negate_stmt = 0x06,
DW_LNS_set_basic_block = 0x07,
DW_LNS_const_add_pc = 0x08,
DW_LNS_fixed_advance_pc = 0x09,
DW_LNS_set_prologue_end = 0x0a,
DW_LNS_set_epilogue_begin = 0x0b,
DW_LNS_set_isa = 0x0c,
};
/* line number information extended opcodes (7.21) */
enum dwarf_line_number_extended {
DW_LNE_end_sequence = 0x01,
DW_LNE_set_address = 0x02,
DW_LNE_define_file = 0x03,
DW_LNE_set_discriminator = 0x04, /* since v4 */
DW_LNE_lo_user = 0x80,
DW_LNE_hi_user = 0xff,
};
enum dwarf_macinfo_type {
DW_MACINFO_define = 0x01,
DW_MACINFO_undef = 0x02,
DW_MACINFO_start_file = 0x03,
DW_MACINFO_end_file = 0x04,
DW_MACINFO_vendor_ext = 0xff,
};
enum dwarf_call_frame {
DW_CFA_advance_loc = 0x01,
DW_CFA_offset = 0x02,
DW_CFA_restore = 0x03,
DW_CFA_nop = 0x00,
DW_CFA_set_loc = 0x01,
DW_CFA_advance_loc1 = 0x02,
DW_CFA_advance_loc2 = 0x03,
DW_CFA_advance_loc4 = 0x04,
DW_CFA_offset_extended = 0x05,
DW_CFA_restore_extended = 0x06,
DW_CFA_undefined = 0x07,
DW_CFA_same_value = 0x08,
DW_CFA_register = 0x09,
DW_CFA_remember_state = 0x0a,
DW_CFA_restore_state = 0x0b,
DW_CFA_def_cfa = 0x0c,
DW_CFA_def_cfa_register = 0x0d,
DW_CFA_def_cfa_offset = 0x0e,
DW_CFA_def_cfa_expression = 0x0f,
DW_CFA_expression = 0x10,
DW_CFA_offset_extended_sf = 0x11,
DW_CFA_def_cfa_sf = 0x12,
DW_CFA_def_cfa_offset_sf = 0x13,
DW_CFA_val_offset = 0x14,
DW_CFA_val_offset_sf = 0x15,
DW_CFA_val_expression = 0x16,
DW_CFA_lo_user = 0x1c,
DW_CFA_hi_user = 0x3f,
};
/* LEB128 - encoded (signed and unsigned) integers:
* a stream of bytes, with bit 7 set, last byte has bit 7 cleared.
* i = 0 - 7f -> b0 = i
* i = 80 - 3fff -> b0 = 0x80 | i[0-6], b1 = i[7-13]
* i = 4000 - 1fffff -> b0 = 0x80 | i[0-6], b1 = 0x80 | i[7-13], b2 = i[14-20]
*/
/* header for compilation unit */
struct dwarf_compilation_unit_header32 {
uint_32 unit_length;
uint_16 version;
uint_32 debug_abbrev_offset;
uint_8 address_size;
};
/* header for type unit */
struct dwarf_type_unit_header32 {
uint_32 unit_length;
uint_16 version;
uint_32 debug_abbrev_offset;
uint_8 address_size;
uint_64 type_signature;
uint_32 type_offset;
};
#if 0
struct dwarf_stmt_prologue {
uint_32 total_length;
uint_16 version;
uint_32 prologue_length;
uint_8 minimum_instruction_length;
uint_8 default_is_stmt;
int_8 line_base;
uint_8 line_range;
uint_8 opcode_base;
uint_8 standard_opcode_lengths[DWLINE_OPCODE_BASE - 1];
};
struct dwarf_segmented_arange_tuple {
uint_32 offset;
uint_16 segment;
uint_32 length;
};
struct dwarf_flat_arange_tuple {
uint_32 offset;
uint_32 length;
};
union dwarf_arange_tuple {
struct segmented_arange_tuple s;
struct flat_arange_tuple f;
};
struct dwarf_arange_prologue {
uint_32 length;
uint_16 version;
uint_32 debug_offset;
uint_8 offset_size;
uint_8 segment_size;
};
struct dwarf_pubnames_prologue {
uint_32 length;
uint_16 version;
uint_32 debug_offset;
uint_32 debug_size;
};
#endif
#endif

266
H/directve.h Normal file
View File

@ -0,0 +1,266 @@
/****************************************************************************
*
* Description: table of directives
*
****************************************************************************/
/* v1.96: items needn't be sorted anymore!
* The items are stored in structures of type special_item.
* If an item is inserted, moved or deleted, the project needs
* a full rebuild.
*/
/* directives field usage:
* value = DF_ flags SpecialTable.value unsigned
* bytval = DRT_ value SpecialTable.bytval uint_8
* flags = RWF_ flags ResWordTable.flags uint_8
* cpu = cpu flags SpecialTable.cpu uint_16
* sflags = dep. on DRT_ SpecialTable.sflags unsigned
*/
/* cpu directives */
/* token str value bytval flags cpu sflags */
res(DOT_8086, .8086, 0, DRT_CPU, 0, P_86, P_86 )
res(DOT_186, .186, 0, DRT_CPU, 0, P_86, P_186 )
res(DOT_286, .286, 0, DRT_CPU, 0, P_86, P_286 )
res(DOT_286C, .286c, 0, DRT_CPU, 0, P_86, P_286 )
res(DOT_286P, .286p, 0, DRT_CPU, 0, P_86, P_286p )
res(DOT_386, .386, 0, DRT_CPU, 0, P_86, P_386 )
res(DOT_386C, .386c, 0, DRT_CPU, 0, P_86, P_386 )
res(DOT_386P, .386p, 0, DRT_CPU, 0, P_86, P_386p )
res(DOT_486, .486, 0, DRT_CPU, 0, P_86, P_486 )
res(DOT_486P, .486p, 0, DRT_CPU, 0, P_86, P_486p )
res(DOT_586, .586, 0, DRT_CPU, 0, P_86, P_586 )
res(DOT_586P, .586p, 0, DRT_CPU, 0, P_86, P_586p )
res(DOT_686, .686, 0, DRT_CPU, 0, P_86, P_686 )
res(DOT_686P, .686p, 0, DRT_CPU, 0, P_86, P_686p )
res(DOT_K3D, .k3d, 0, DRT_CPU, 0, P_586, P_K3D|P_MMX )
res(DOT_MMX, .mmx, 0, DRT_CPU, 0, P_586, P_MMX )
res(DOT_XMM, .xmm, 0, DRT_CPU, 0, P_686, P_MMX|P_SSEALL )
#if AMD64_SUPPORT
res(DOT_X64, .x64, 0, DRT_CPU, 0, P_86, P_64 )
res(DOT_X64P, .x64p, 0, DRT_CPU, 0, P_86, P_64p )
#endif
res(DOT_8087, .8087, 0, DRT_CPU, 0, P_86, P_87 )
res(DOT_287, .287, 0, DRT_CPU, 0, P_86, P_287 )
res(DOT_387, .387, 0, DRT_CPU, 0, P_86, P_387 )
res(DOT_NO87, .no87, 0, DRT_CPU, 0, P_86, P_NO87 )
/* listing directives */
/* .LFCOND is synonym for .LISTIF
* .SFCOND is synonym for .NOLISTIF
* .TFCOND toggles .LFCOND, .SFCOND
*/
res(DOT_CREF, .cref, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_LFCOND, .lfcond, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_LIST, .list, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_LISTALL, .listall, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_LISTIF, .listif, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_NOCREF, .nocref, DF_NOEXPAND, DRT_LISTING, 0, P_86, 0)
res(DOT_NOLIST, .nolist, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_NOLISTIF, .nolistif, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_SFCOND, .sfcond, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_TFCOND, .tfcond, 0, DRT_LISTING, 0, P_86, 0)
res(DOT_XCREF, .xcref, DF_NOEXPAND, DRT_LISTING, 0, P_86, 0)
res(DOT_XLIST, .xlist, 0, DRT_LISTING, 0, P_86, 0)
res(PAGE, page, 0, DRT_LISTING, 0, P_86, 0)
res(SUBTITLE, subtitle, 0, DRT_LISTING, 0, P_86, 0)
res(SUBTTL, subttl, 0, DRT_LISTING, 0, P_86, 0)
res(TITLE, title, 0, DRT_LISTING, 0, P_86, 0)
/* list macro directives
* .XALL is synonym for .LISTMACRO
* .LALL is synonym for .LISTMACROALL
* .SALL is synonym for .NOLISTMACRO
*/
res(DOT_LISTMACRO, .listmacro, 0, DRT_LISTMAC, 0, P_86, LM_LISTMACRO)
res(DOT_LISTMACROALL, .listmacroall, 0, DRT_LISTMAC, 0, P_86, LM_LISTMACROALL)
res(DOT_NOLISTMACRO, .nolistmacro, 0, DRT_LISTMAC, 0, P_86, LM_NOLISTMACRO)
res(DOT_XALL, .xall, 0, DRT_LISTMAC, 0, P_86, LM_LISTMACRO)
res(DOT_LALL, .lall, 0, DRT_LISTMAC, 0, P_86, LM_LISTMACROALL)
res(DOT_SALL, .sall, 0, DRT_LISTMAC, 0, P_86, LM_NOLISTMACRO)
res(DOT_ALPHA, .alpha, 0, DRT_SEGORDER, 0, P_86, SEGORDER_ALPHA )
res(DOT_DOSSEG, .dosseg, 0, DRT_SEGORDER, 0, P_86, SEGORDER_DOSSEG)
res(DOT_SEQ, .seq, 0, DRT_SEGORDER, 0, P_86, SEGORDER_SEQ )
res(DOSSEG, dosseg, 0, DRT_SEGORDER, 0, P_86, SEGORDER_DOSSEG)
/* simplified segment directives, numbers in sflags must match enum sim_seg (simseg.c) */
res(DOT_CODE, .code, DF_NOSTRUC|DF_PROC|DF_CGEN, DRT_SIMSEG, 0, P_86, 0)
res(DOT_STACK, .stack, DF_NOSTRUC|DF_PROC|DF_CGEN, DRT_SIMSEG, 0, P_86, 1)
res(DOT_DATA, .data, DF_NOSTRUC|DF_PROC|DF_CGEN, DRT_SIMSEG, 0, P_86, 2)
res(DOT_DATA_UN, .data?, DF_NOSTRUC|DF_PROC|DF_CGEN, DRT_SIMSEG, 0, P_86, 3)
res(DOT_FARDATA, .fardata, DF_NOSTRUC|DF_PROC|DF_CGEN, DRT_SIMSEG, 0, P_86, 4)
res(DOT_FARDATA_UN, .fardata?, DF_NOSTRUC|DF_PROC|DF_CGEN, DRT_SIMSEG, 0, P_86, 5)
res(DOT_CONST, .const, DF_NOSTRUC|DF_PROC|DF_CGEN, DRT_SIMSEG, 0, P_86, 6)
/* hll directives */
res(DOT_IF, .if, DF_CGEN|DF_CEXPR|DF_NOSTRUC|DF_STORE|DF_PROC, DRT_HLLSTART, 0, P_86, 0)
res(DOT_REPEAT, .repeat, DF_CGEN|DF_NOSTRUC|DF_STORE|DF_PROC, DRT_HLLSTART, 0, P_86, 0)
res(DOT_WHILE, .while, DF_CGEN|DF_CEXPR|DF_NOSTRUC|DF_STORE|DF_PROC, DRT_HLLSTART, 0, P_86, 0)
res(DOT_BREAK, .break, DF_CGEN, DRT_HLLEXIT, 0, P_86, 0)
res(DOT_CONTINUE, .continue, DF_CGEN, DRT_HLLEXIT, 0, P_86, 0)
res(DOT_ELSE, .else, DF_CGEN, DRT_HLLEXIT, 0, P_86, 0)
res(DOT_ELSEIF, .elseif, DF_CGEN|DF_CEXPR, DRT_HLLEXIT, 0, P_86, 0)
res(DOT_ENDIF, .endif, DF_CGEN, DRT_HLLEND, 0, P_86, 0)
res(DOT_ENDW, .endw, DF_CGEN, DRT_HLLEND, 0, P_86, 0)
res(DOT_UNTIL, .until, DF_CGEN|DF_CEXPR, DRT_HLLEND, 0, P_86, 0)
res(DOT_UNTILCXZ, .untilcxz, DF_CGEN|DF_CEXPR, DRT_HLLEND, 0, P_86, 0)
res(DOT_EXIT, .exit, DF_CGEN|DF_STORE, DRT_STARTEXIT, 0, P_86, 0)
res(DOT_STARTUP, .startup, DF_CGEN|DF_STORE, DRT_STARTEXIT, 0, P_86, 0)
res(DOT_MODEL, .model, DF_CGEN, DRT_MODEL, 0, P_86, 0)
res(DOT_RADIX, .radix, 0, DRT_RADIX, 0, P_86, 0)
/* directives invalid for IA32+ */
#if COFF_SUPPORT
res(DOT_SAFESEH, .safeseh, 0, DRT_SAFESEH, RWF_IA32, P_386, 0)
#endif
/* error directives */
res(DOT_ERR, .err, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, 0)
res(DOT_ERR1, .err1, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_PASS1 )
res(DOT_ERR2, .err2, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_PASS2 )
res(DOT_ERRE, .erre, DF_STORE, DRT_ERRDIR, 0, P_86, CC_NUMARG)
res(DOT_ERRNZ, .errnz, DF_STORE, DRT_ERRDIR, 0, P_86, CC_NUMARG)
res(DOT_ERRDIF, .errdif, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_LITARG)
res(DOT_ERRDIFI, .errdifi, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_LITARG)
res(DOT_ERRIDN, .erridn, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_LITARG)
res(DOT_ERRIDNI, .erridni, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_LITARG)
res(DOT_ERRB, .errb, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_BLKARG)
res(DOT_ERRNB, .errnb, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_BLKARG)
res(DOT_ERRDEF, .errdef, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_SYMARG)
res(DOT_ERRNDEF, .errndef, DF_STRPARM|DF_STORE, DRT_ERRDIR, 0, P_86, CC_SYMARG)
/* conditional assembly directives, handled by preprocessor */
/* token str value bytval flgs cpu sflags */
res(COMMENT, comment, 0, DRT_CONDDIR, 0, P_86, 0)
res(IF, if, 0, DRT_CONDDIR, 0, P_86, CC_NUMARG)
res(IFE, ife, 0, DRT_CONDDIR, 0, P_86, CC_NUMARG)
res(IF1, if1, 0, DRT_CONDDIR, 0, P_86, CC_PASS1 )
res(IF2, if2, 0, DRT_CONDDIR, 0, P_86, CC_PASS2 )
res(IFDIF, ifdif, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_LITARG)
res(IFDIFI, ifdifi, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_LITARG)
res(IFIDN, ifidn, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_LITARG)
res(IFIDNI, ifidni, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_LITARG)
res(IFB, ifb, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_BLKARG)
res(IFNB, ifnb, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_BLKARG)
res(IFDEF, ifdef, DF_NOEXPAND, DRT_CONDDIR, 0, P_86, CC_SYMARG)
res(IFNDEF, ifndef, DF_NOEXPAND, DRT_CONDDIR, 0, P_86, CC_SYMARG)
res(ELSE, else, 0, DRT_CONDDIR, 0, P_86, 0)
res(ELSEIF, elseif, 0, DRT_CONDDIR, 0, P_86, CC_NUMARG)
res(ELSEIFE, elseife, 0, DRT_CONDDIR, 0, P_86, CC_NUMARG)
res(ELSEIF1, elseif1, 0, DRT_CONDDIR, 0, P_86, CC_PASS1 )
res(ELSEIF2, elseif2, 0, DRT_CONDDIR, 0, P_86, CC_PASS2 )
res(ELSEIFDIF, elseifdif, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_LITARG)
res(ELSEIFDIFI, elseifdifi, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_LITARG)
res(ELSEIFIDN, elseifidn, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_LITARG)
res(ELSEIFIDNI, elseifidni, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_LITARG)
res(ELSEIFB, elseifb, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_BLKARG)
res(ELSEIFNB, elseifnb, DF_STRPARM, DRT_CONDDIR, 0, P_86, CC_BLKARG)
res(ELSEIFDEF, elseifdef, DF_NOEXPAND, DRT_CONDDIR, 0, P_86, CC_SYMARG)
res(ELSEIFNDEF, elseifndef, DF_NOEXPAND, DRT_CONDDIR, 0, P_86, CC_SYMARG)
res(ENDIF, endif, 0, DRT_CONDDIR, 0, P_86, 0)
/* assembly time loop directives, handled by preprocessor */
res(FOR, for, DF_NOEXPAND, DRT_LOOPDIR, 0, P_86, 0)
res(FORC, forc, DF_NOEXPAND, DRT_LOOPDIR, 0, P_86, 0)
res(IRP, irp, 0, DRT_LOOPDIR, 0, P_86, 0)
res(IRPC, irpc, 0, DRT_LOOPDIR, 0, P_86, 0)
res(REPEAT, repeat, 0, DRT_LOOPDIR, 0, P_86, 0)
res(REPT, rept, 0, DRT_LOOPDIR, 0, P_86, 0)
res(WHILE, while, 0, DRT_LOOPDIR, 0, P_86, 0)
/* other preprocessor directives */
res(MACRO, macro, DF_LABEL, DRT_MACRO, 0, P_86, 0)
res(EXITM, exitm, DF_STRPARM, DRT_MACINT, 0, P_86, 0)
res(ENDM, endm, 0, DRT_MACINT, 0, P_86, 0)
res(GOTO, goto, 0, DRT_MACINT, 0, P_86, 0)
res(PURGE, purge, 0, DRT_PURGE, 0, P_86, 0)
res(INCLUDE, include, DF_NOEXPAND|DF_NOCONCAT,DRT_INCLUDE,0, P_86, 0)
res(TEXTEQU, textequ, DF_STRPARM | DF_LABEL, DRT_CATSTR, 0, P_86, 0)
res(CATSTR, catstr, DF_STRPARM | DF_LABEL, DRT_CATSTR, 0, P_86, 0)
res(SUBSTR, substr, DF_STRPARM | DF_LABEL, DRT_SUBSTR, 0, P_86, 0)
/* INSTR and SIZESTR aren't true preprocessor directives */
res(INSTR, instr, DF_STRPARM | DF_LABEL, DRT_INSTR, 0, P_86, 0)
res(SIZESTR, sizestr, DF_STRPARM | DF_LABEL, DRT_SIZESTR, 0, P_86, 0)
/* data definition directives */
res(DB, db, DF_LABEL, DRT_DATADIR, 0, P_86, T_BYTE )
res(DW, dw, DF_LABEL, DRT_DATADIR, 0, P_86, T_WORD )
res(DD, dd, DF_LABEL, DRT_DATADIR, 0, P_86, T_DWORD)
res(DF, df, DF_LABEL, DRT_DATADIR, 0, P_86, T_FWORD)
res(DQ, dq, DF_LABEL, DRT_DATADIR, 0, P_86, T_QWORD)
res(DT, dt, DF_LABEL, DRT_DATADIR, 0, P_86, T_TBYTE)
#if AMD64_SUPPORT
res(DOT_ALLOCSTACK, .allocstack, 0, DRT_EXCFRAME, RWF_X64, P_64, 0)
res(DOT_ENDPROLOG, .endprolog, 0, DRT_EXCFRAME, RWF_X64, P_64, 0)
res(DOT_PUSHFRAME, .pushframe, 0, DRT_EXCFRAME, RWF_X64, P_64, 0)
res(DOT_PUSHREG, .pushreg, 0, DRT_EXCFRAME, RWF_X64, P_64, 0)
res(DOT_SAVEREG, .savereg, 0, DRT_EXCFRAME, RWF_X64, P_64, 0)
res(DOT_SAVEXMM128, .savexmm128, 0, DRT_EXCFRAME, RWF_X64, P_64, 0)
res(DOT_SETFRAME, .setframe, 0, DRT_EXCFRAME, RWF_X64, P_64, 0)
#endif
/* "type" directives */
res(STRUC, struc, DF_LABEL, DRT_STRUCT, 0, P_86, 0)
res(STRUCT, struct, DF_LABEL, DRT_STRUCT, 0, P_86, 0)
res(UNION, union, DF_LABEL, DRT_STRUCT, 0, P_86, 0)
res(TYPEDEF, typedef, DF_LABEL, DRT_TYPEDEF,0, P_86, 0)
res(RECORD, record, DF_LABEL, DRT_RECORD, 0, P_86, 0)
/* "global" directives */
res(COMM, comm, 0, DRT_COMM, 0, P_86, 0)
res(EXTERN, extern, 0, DRT_EXTERN, 0, P_86, 0)
res(EXTRN, extrn, 0, DRT_EXTERN, 0, P_86, 0)
res(EXTERNDEF, externdef, 0, DRT_EXTERNDEF,0, P_86, 0)
res(PUBLIC, public, 0, DRT_PUBLIC, 0, P_86, 0)
/* "proc" directives */
res(PROTO, proto, DF_LABEL, DRT_PROTO, 0, P_86, 0)
res(PROC, proc, DF_CGEN|DF_LABEL|DF_NOSTRUC|DF_STORE,DRT_PROC, 0, P_86, 0)
res(ENDP, endp, DF_LABEL|DF_NOSTRUC, DRT_ENDP, 0, P_86, 0)
res(LOCAL, local, 0, DRT_LOCAL, 0, P_86, 0)
res(LABEL, label, DF_LABEL|DF_NOSTRUC|DF_STORE, DRT_LABEL, 0, P_86, 0)
res(INVOKE, invoke, DF_CGEN|DF_NOSTRUC|DF_PROC|DF_STORE, DRT_INVOKE, 0, P_86, 0)
/* other directives */
/* token str len value bytval flags cpu sflags */
res(ORG, org, 0, DRT_ORG, 0, P_86, 0)
res(ALIGN, align, 0, DRT_ALIGN, 0, P_86, 0)
res(EVEN, even, 0, DRT_ALIGN, 0, P_86, 0)
res(SEGMENT, segment, DF_LABEL|DF_NOSTRUC|DF_PROC,DRT_SEGMENT, 0, P_86, 0)
/* v2.10: ENDS should not trigger prologue creation if it is to end a structure */
//res(ENDS, ends, DF_LABEL|DF_PROC, DRT_ENDS, 0, P_86, 0)
res(ENDS, ends, DF_LABEL, DRT_ENDS, 0, P_86, 0)
res(GROUP, group, DF_LABEL, DRT_GROUP, 0, P_86, 0)
res(ASSUME, assume, 0, DRT_ASSUME, 0, P_86, 0)
res(ALIAS, alias, 0, DRT_ALIAS, 0, P_86, 0)
res(ECHO, echo, DF_NOEXPAND|DF_NOCONCAT, DRT_ECHO, 0, P_86, 0)
res(END, end, DF_CGEN|DF_NOSTRUC|DF_STORE,DRT_END, 0, P_86, 0)
res(EQU, equ, DF_STRPARM|DF_LABEL, DRT_EQU, 0, P_86, 0)
#if INCBINSUPP
res(INCBIN, incbin, DF_NOSTRUC|DF_PROC|DF_STORE,DRT_INCBIN, 0, P_86, 0)
#endif
res(INCLUDELIB, includelib, DF_NOCONCAT, DRT_INCLIB, 0, P_86, 0)
res(NAME, name, 0, DRT_NAME, 0, P_86, 0)
res(OPTION, option, 0, DRT_OPTION, 0, P_86, 0)
res(POPCONTEXT, popcontext, 0, DRT_CONTEXT, 0, P_86, 0)
res(PUSHCONTEXT, pushcontext, 0, DRT_CONTEXT, 0, P_86, 0)

65
H/dirtype.h Normal file
View File

@ -0,0 +1,65 @@
/* DRT_ values ( directive types ) */
/* items CONDDIR ... INCLUDE must be first, INCLUDE the last of them.
* DATADIR must be the first non-preprocessor directive!
*/
res( CONDDIR, CondAsmDirective ) /* conditional assembly directive (IF, ELSE, ...) */
res( LOOPDIR, LoopDirective ) /* loop directive (FOR, REPEAT, WHILE, ...) */
res( PURGE, PurgeDirective ) /* PURGE directive */
res( INCLUDE, IncludeDirective ) /* INCLUDE directive */
res( MACRO, MacroDir ) /* MACRO directive */
res( CATSTR, CatStrDir ) /* TEXTEQU + CATSTR directives */
res( SUBSTR, SubStrDir ) /* SUBSTR directive */
res( MACINT, StubDir ) /* "internal macro" directives EXITM, ENDM, GOTO */
/* non-preprocessor directives */
res( DATADIR, StubDir ) /* "data" directives DB, DW, DD, ... */
res( END, EndDirective )
res( ERRDIR, ErrorDirective ) /* v2.05: no longer preprocessor directives */
res( CPU, CpuDirective )
res( LISTING, ListingDirective )
res( LISTMAC, ListMacroDirective )
res( SEGORDER, SegOrderDirective )
res( SIMSEG, SimplifiedSegDir )
res( HLLSTART, HllStartDir )
res( HLLEXIT, HllExitDir )
res( HLLEND, HllEndDir )
res( STARTEXIT, StartupExitDirective )
res( MODEL, ModelDirective )
res( RADIX, RadixDirective )
#if COFF_SUPPORT
res( SAFESEH, SafeSEHDirective )
#endif
res( INSTR, InStrDir )
res( SIZESTR, SizeStrDir )
#if AMD64_SUPPORT
res( EXCFRAME, ExcFrameDirective )
#endif
res( STRUCT, StructDirective )
res( TYPEDEF, TypedefDirective )
res( RECORD, RecordDirective )
res( COMM, CommDirective )
res( EXTERN, ExternDirective )
res( EXTERNDEF, ExterndefDirective )
res( PROTO, ProtoDirective )
res( PUBLIC, PublicDirective )
res( PROC, ProcDir )
res( ENDP, EndpDir )
res( LOCAL, LocalDir )
res( INVOKE, InvokeDirective )
res( ORG, OrgDirective )
res( ALIGN, AlignDirective )
res( SEGMENT, SegmentDir )
res( ENDS, EndsDir )
res( GROUP, GrpDir )
res( ASSUME, AssumeDirective )
res( LABEL, LabelDirective )
res( ALIAS, AliasDirective )
res( ECHO, EchoDirective )
res( EQU, EquDirective )
res( EQUALSGN, EqualSgnDirective ) /* '=' directive */
#if INCBINSUPP
res( INCBIN, IncBinDirective )
#endif
res( INCLIB, IncludeLibDirective )
res( NAME, NameDirective )
res( OPTION, OptionDirective )
res( CONTEXT, ContextDirective )

9
H/elf.h Normal file
View File

@ -0,0 +1,9 @@
/* prototypes of functions defined in elf.c */
#ifndef _ELF_H_INCLUDED_
#define _ELF_H_INCLUDED_
void elf_init( struct module_info * );
#endif // _ELF_H_INCLUDED_

667
H/elfspec.h Normal file
View File

@ -0,0 +1,667 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Executable and Linkable Format (ELF) definitions.
*
****************************************************************************/
#ifndef _ELFSPEC_H_INCLUDED_
#define _ELFSPEC_H_INCLUDED_
// the main header
#define EI_NIDENT 16
typedef struct {
uint_8 e_ident[EI_NIDENT]; // +0 signature & ID info
uint_16 e_type; // +16 file type (i.e. obj file, exe file)
uint_16 e_machine; // +18 required architecture
uint_32 e_version; // +20 version of the file
uint_32 e_entry; // +24 program entry point
uint_32 e_phoff; // +28 program header offset
uint_32 e_shoff; // +32 section header offset
uint_32 e_flags; // +36 processor specific flags
uint_16 e_ehsize; // +40 elf header size
uint_16 e_phentsize; // +42 program header entry size
uint_16 e_phnum; // +44 number of program header entries
uint_16 e_shentsize; // +46 section header entry size
uint_16 e_shnum; // +48 number of section header entries
uint_16 e_shstrndx; // +50 section name string table index.
} Elf32_Ehdr;
typedef struct {
uint_8 e_ident[EI_NIDENT]; // +0 signature & ID info
uint_16 e_type; // +16 file type (i.e. obj file, exe file)
uint_16 e_machine; // +18 required architecture
uint_32 e_version; // +20 version of the file
uint_64 e_entry; // +24 program entry point
uint_64 e_phoff; // +32 program header offset
uint_64 e_shoff; // +40 section header offset
uint_32 e_flags; // +48 processor specific flags
uint_16 e_ehsize; // +52 elf header size
uint_16 e_phentsize; // +54 program header entry size
uint_16 e_phnum; // +56 number of program header entries
uint_16 e_shentsize; // +58 section header entry size
uint_16 e_shnum; // +60 number of section header entries
uint_16 e_shstrndx; // +62 section name string table index.
} Elf64_Ehdr;
// e_ident field indicies
#define ELF_SIGNATURE "\177ELF"
#define ELF_SIGNATURE_LEN 4
#define ELFMAG0 '\177' // bytes of signature
#define ELFMAG1 'E' // bytes of signature
#define ELFMAG2 'L' // bytes of signature
#define ELFMAG3 'F' // bytes of signature
#define EI_MAG0 0 // signature bytes
#define EI_MAG1 1 // signature bytes
#define EI_MAG2 2 // signature bytes
#define EI_MAG3 3 // signature bytes
#define EI_CLASS 4 // "file class", i.e. 32-bit vs. 64-bit
#define EI_DATA 5 // data encoding (big-endian vs. little-endian)
#define EI_VERSION 6 // header version #
#define EI_OSABI 7 // OS/ABI identification
#define EI_ABIVERSION 8 // ABI version
#define EI_PAD 9 // start of padding bytes
// contents of the EI_CLASS field index
#define ELFCLASSNONE 0 // invalid class
#define ELFCLASS32 1 // 32-bit objects
#define ELFCLASS64 2 // 64-bit objects
// contents of the EI_DATA field index
#define ELFDATANONE 0 // invalid data encoding
#define ELFDATA2LSB 1 // "little-endian"
#define ELFDATA2MSB 2 // "big-endian"
// the current elf version number (EI_VERSION)
#define EV_CURRENT 1
// contents of the EI_OSABI field index
#define ELFOSABI_NONE 0 // No extensions or unspecified
#define ELFOSABI_HPUX 1 // Hewlett-Packard HP-UX
#define ELFOSABI_NETBSD 2 // NetBSD
#define ELFOSABI_LINUX 3 // Linux
#define ELFOSABI_SOLARIS 6 // Sun Solaris
#define ELFOSABI_AIX 7 // IBM AIX
#define ELFOSABI_IRIX 8 // SGI IRIX
#define ELFOSABI_FREEBSD 9 // FreeBSD
#define ELFOSABI_TRU64 10 // Compaq TRU64 UNIX
#define ELFOSABI_MODESTO 11 // Novell Modesto
#define ELFOSABI_OPENBSD 12 // Open BSD
#define ELFOSABI_OPENVMS 13 // Open VMS
#define ELFOSABI_NSK 14 // Hewlett-Packard Non-Stop Kernel
#define ELFOSABI_AROS 15 // Amiga Research OS
// elf object file types
#define ET_NONE 0 // no file type
#define ET_REL 1 // relocatable file
#define ET_EXEC 2 // executable file
#define ET_DYN 3 // shared object file
#define ET_CORE 4 // core file
#define ET_LOPROC 0xff00 // processor specific file types
#define ET_HIPROC 0xffff
// elf machine types
#define EM_NONE 0 // No machine
#define EM_386 3 // Intel 80386
#define EM_IA_64 50 // Intel IA-64 processor architecture
#define EM_X86_64 62 // AMD x86-64 architecture
// version number info
#define EV_NONE 0
#define EV_CURRENT 1
#define EV_WPIBM 2 // version identifier for extended ELF
// flags (machine specific)
//EM_M32
#define EF_M32_MAU 0x1
// special section indicies
#define SHN_UNDEF 0
#define SHN_LORESERVE 0xff00
#define SHN_LOPROC 0xff00 // reserved for processor-specific semantics
#define SHN_HIPROC 0xff1f
#define SHN_ABS 0xfff1 // references to this section are absolute
#define SHN_COMMON 0xfff2 // references to this section are common.
#define SHN_HIRESERVE 0xffff
// section header
typedef struct {
uint_32 sh_name; // +0 name of the section
uint_32 sh_type; // +4 section type
uint_32 sh_flags; // +8
uint_32 sh_addr; // +12 starting address of section in image
uint_32 sh_offset; // +16 start of section in file
uint_32 sh_size; // +20 size of section (in file if type != SHT_NOBITS)
uint_32 sh_link; // +24 multipurpose field (based on type)
uint_32 sh_info; // +28 another multipurpose field (based on type)
uint_32 sh_addralign; // +32 address alignment
uint_32 sh_entsize; // +36 entry size for sects with fixed sized entries
} Elf32_Shdr;
typedef struct {
uint_32 sh_name; // +0 name of the section
uint_32 sh_type; // +4 section type
uint_64 sh_flags; // +8
uint_64 sh_addr; // +16 starting address of section in image
uint_64 sh_offset; // +24 start of section in file
uint_64 sh_size; // +32 size of section (in file if type != SHT_NOBITS)
uint_32 sh_link; // +40 multipurpose field (based on type)
uint_32 sh_info; // +44 another multipurpose field (based on type)
uint_64 sh_addralign; // +48 address alignment
uint_64 sh_entsize; // +56 entry size for sects with fixed sized entries
} Elf64_Shdr;
// section types
#define SHT_NULL 0 // inactive
#define SHT_PROGBITS 1 // meaning defined by program
#define SHT_SYMTAB 2 // symbol table
#define SHT_STRTAB 3 // string table
#define SHT_RELA 4 // reloc entries with explicit addends
#define SHT_HASH 5 // symbol hash table
#define SHT_DYNAMIC 6 // dynamic linking information
#define SHT_NOTE 7 // comment information
#define SHT_NOBITS 8 // like PROGBITS but no space in file.
#define SHT_REL 9 // as RELA but no explicit addends
#define SHT_SHLIB 10 // reserved but evil
#define SHT_DYNSYM 11 // dynamic link symbol table
#define SHT_LOOS 0x60000000 /* reserved for environment specific use */
#define SHT_OS 0x60000001 // info to identify target OS
#define SHT_IMPORTS 0x60000002 // info on refs to external symbols
#define SHT_EXPORTS 0x60000003 // info on symbols exported by ordinal
#define SHT_RES 0x60000004 // read-only resource data.
#define SHT_PROGFRAGS 0x60001001 // similar to SHT_PROGBITS
#define SHT_IDMDLL 0x60001002 // symbol name demangling information
#define SHT_DEFLIB 0x60001003 // default static libraries
#define SHT_HIOS 0x6fffffff
#define SHT_LOPROC 0x70000000 // processor specific
#define SHT_X86_64_UNWIND 0x70000001 // contains entries for stack unwinding
#define SHT_HIPROC 0x7fffffff
#define SHT_LOUSER 0x80000000 // user defined sections
#define SHT_HIUSER 0xffffffff
// Old section types. Readers should handle these, writers must use the above
#define SHT_OS_O 12 // info to identify target OS
#define SHT_IMPORTS_O 13 // info on refs to external symbols
#define SHT_EXPORTS_O 14 // info on symbols exported by ordinal
#define SHT_RES_O 15 // read-only resource data.
/* sh_flags values */
#define SHF_WRITE 0x00000001 // 0 section writable during execution
#define SHF_ALLOC 0x00000002 // 1 section occupies space during exec.
#define SHF_EXECINSTR 0x00000004 // 2 section contains code.
#define SHF_MERGE 0x00000010 // 4 section can be merged
#define SHF_STRINGS 0x00000020 // 5 section contains asciiz strings
#define SHF_BEGIN 0x01000000 // 24 section to be placed at the beginning
// of like-named sections by static link
#define SHF_END 0x02000000 // 25 same, end.
#define SHF_MASKPROC 0xf0000000 // processor specific flags
#define SHF_X86_64_LARGE 0x1000000 // section with more than 2GB - value may be wrong!!!
#define SHF_ALPHA_GPREL 0x10000000
/* symbol table entry */
typedef struct {
uint_32 st_name; // symbol name index into string table
uint_32 st_value; // symbol "value"
uint_32 st_size; // symbol size
uint_8 st_info; // symbol's type and binding attribs.
uint_8 st_other; // no meaning yet.
uint_16 st_shndx; // section index
} Elf32_Sym;
typedef struct {
uint_32 st_name; // symbol name index into string table
uint_8 st_info; // symbol's type and binding attribs.
uint_8 st_other; // no meaning yet.
uint_16 st_shndx; // section index
uint_64 st_value; // symbol "value"
uint_64 st_size; // symbol size
} Elf64_Sym;
// symbol info field contents
#define ELF32_ST_BIND(i) ((i)>>4) // get the "bind" subfield
#define ELF32_ST_TYPE(i) ((i)&0xf) // get the type subfield
#define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf)) // make a new st_info
// the macros for 64bits are a guess only
#define ELF64_ST_BIND(i) ((i)>>4) // get the "bind" subfield
#define ELF64_ST_TYPE(i) ((i)&0xf) // get the type subfield
#define ELF64_ST_INFO(b,t) (((b)<<4)+((t)&0xf)) // make a new st_info
// bind subfield contents
#define STB_LOCAL 0 // symbol has local binding
#define STB_GLOBAL 1 // symbol has global binding
#define STB_WEAK 2 // symbol has weak binding
#define STB_ENTRY 12 // symbol is entry-point for the load module
#define STB_LOPROC 13 // processor specific semantics
#define STB_HIPROC 15
// type subfield contents
#define STT_NOTYPE 0 // not specified
#define STT_OBJECT 1 // symbol is a data object
#define STT_FUNC 2 // symbol is a code symbol
#define STT_SECTION 3 // symbol associated with a section
#define STT_FILE 4 // symbol gives name of the source file.
#define STT_COMMON 5 // symbol is common
#define STT_IMPORT 11 // reference to a symbol in another module
#define STT_LOPROC 13 // processor specific semantics
#define STT_HIPROC 15
// relocation entries
typedef struct {
uint_32 r_offset; // place to apply reloc (from begin of section)
uint_32 r_info; // symbol idx, and type of reloc
} Elf32_Rel;
typedef struct {
uint_32 r_offset; // place to apply reloc (from begin of section)
uint_32 r_info; // symbol idx, and type of reloc
int_32 r_addend; // value used as a basis for the reloc.
} Elf32_Rela;
typedef struct {
uint_64 r_offset; // place to apply reloc (from begin of section)
uint_64 r_info; // symbol idx, and type of reloc
} Elf64_Rel;
typedef struct {
uint_64 r_offset; // place to apply reloc (from begin of section)
uint_64 r_info; // symbol idx, and type of reloc
int_64 r_addend; // value used as a basis for the reloc.
} Elf64_Rela;
// r_info field contents
#define ELF32_R_SYM(i) ((i)>>8) // gets the symbol index
#define ELF32_R_TYPE(i) ((uint_8)(i)) // gets the symbol type
#define ELF32_R_INFO(s,t) (((s)<<8)+(uint_8)(t)) // make a new r_info
#define ELF64_R_SYM(i) ((i)>>32) // gets the symbol index
#define ELF64_R_TYPE(i) ((i)&0xffffffffL) // gets the symbol type
#define ELF64_R_INFO(s,t) ((((uint_64)s)<<32)+((t)&0xffffffffL)) // make a new r_info
// relocation types.
//386
enum elf32_relocations {
R_386_NONE = 0,
R_386_32 = 1, /* direct, S + A */
R_386_PC32 = 2, /* PC-relative, S + A - P */
R_386_GOT32 = 3, /* GOT entry, G + A */
R_386_PLT32 = 4, /* PLT entry, L + A - P */
R_386_COPY = 5,
R_386_GLOB_DAT = 6, /* create GOT entry, S */
R_386_JMP_SLOT = 7, /* create PLT entry, S */
R_386_RELATIVE = 8, /* rel. to program base, B + A */
R_386_GOTOFF = 9, /* offset to GOT, S + A - GOT */
R_386_GOTPC = 10, /* GOT + A - P */
R_386_32PLT = 11, /* L + A */
/* GNU extensions for LD */
R_386_16 = 20, /* 16-bit direct, S + A */
R_386_PC16 = 21, /* 16-bit PC-relative, S + A - P */
R_386_8 = 22, /* 8-bit direct, S + A */
R_386_PC8 = 23 /* 8-bit PC-relative, S + A - P */
};
//X86_64
enum elf64_relocations {
R_X86_64_NONE = 0,
R_X86_64_64 = 1, /* S + A */
R_X86_64_PC32 = 2, /* S + A - P */
R_X86_64_GOT32 = 3, /* G + A */
R_X86_64_PLT32 = 4, /* L + A - P */
R_X86_64_COPY = 5, /* */
R_X86_64_GLOB_DAT = 6, /* S */
R_X86_64_JUMP_SLOT = 7, /* S */
R_X86_64_RELATIVE = 8, /* B + A */
R_X86_64_GOTPCREL = 9, /* G + GOT + A - P */
R_X86_64_32 = 10, /* S + A */
R_X86_64_32S = 11, /* S + A */
R_X86_64_16 = 12, /* S + A */
R_X86_64_PC16 = 13, /* S + A - P */
R_X86_64_8 = 14, /* S + A */
R_X86_64_PC8 = 15, /* S + A - P */
R_X86_64_DPTMOD64 = 16,
R_X86_64_DTPOFF64 = 17,
R_X86_64_TPOFF64 = 18,
R_X86_64_TLSGD = 19,
R_X86_64_TLSLD = 20,
R_X86_64_DTPOFF32 = 21,
R_X86_64_GOTTPOFF = 22,
R_X86_64_TPOFF32 = 23,
R_X86_64_PC64 = 24, /* S + A - P */
R_X86_64_GOTOFF64 = 25, /* S + A - GOT */
R_X86_64_GOTPC32 = 26, /* GOT + A - P */
R_X86_64_SIZE32 = 32,
R_X86_64_SIZE64 = 33
};
// program header
typedef struct {
uint_32 p_type; // type of segment
uint_32 p_offset; // offset of segment from beginnning of file
uint_32 p_vaddr; // segment virtual address
uint_32 p_paddr; // segment physical address
uint_32 p_filesz; // size of segment in file
uint_32 p_memsz; // size of segment in memory
uint_32 p_flags;
uint_32 p_align; // segment align value (in mem & file)
} Elf32_Phdr;
// segment types
#define PT_NULL 0 // unused segment
#define PT_LOAD 1 // loadable segment
#define PT_DYNAMIC 2 // contains dynamic linking information
#define PT_INTERP 3 // reference to a program interpreter
#define PT_NOTE 4 // comments & auxiliary information
#define PT_SHLIB 5 // here be dragons
#define PT_PHDR 6 // address of prog. header in mem (for interp.)
#define PT_OS 0x60000001 // target os information
#define PT_RES 0x60000002 // read-only resource information
#define PT_LOPROC 0x70000000 // processor specific
#define PT_HIPROC 0x7fffffff
// Old segment types. Readers should handle these, writers must use the above
#define PT_OS_O 7 // target os information
#define PT_RES_O 9 // read-only resource information
// note entry format
typedef struct {
uint_32 n_namesz; // length of name
uint_32 n_descsz; // length of descriptor
uint_32 n_type; // user defined "type" of the note
//char name[]; // variable length name
//uint_32 desc[]; // descriptors go here
} Elf_Note;
// note types (used in core files)
#define NT_PRSTATUS 1 // process status
#define NT_FPREGSET 2 // floating point registers
#define NT_PRPSINFO 3 // process state info
// dynamic segment entry information.
typedef struct {
int_32 d_tag;
union {
uint_32 d_val;
uint_32 d_ptr;
} d_un;
} Elf32_Dyn;
// dynamic array tags
#define DT_NULL 0
#define DT_NEEDED 1 // name of a needed library
#define DT_PLTRELSZ 2 // size of reloc entries for PLT
#define DT_PLTGOT 3 // address with PLT or GOT
#define DT_HASH 4 // symbol hash table address
#define DT_STRTAB 5 // string table address
#define DT_SYMTAB 6 // symbol table address
#define DT_RELA 7 // address of reloc table with addends
#define DT_RELASZ 8 // size of the DT_RELA table
#define DT_RELAENT 9 // size of a DT_RELA entry
#define DT_STRSZ 10 // size of the string table
#define DT_SYMENT 11 // size of a symbol table entry
#define DT_SONAME 14 // shared object name
#define DT_REL 17 // address of reloc table without addends
#define DT_RELSZ 18 // size of the DT_REL table
#define DT_RELENT 19 // size of a DT_REL entry
#define DT_PLTREL 20 // type of reloc entry for PLT
#define DT_DEBUG 21 // for debugging information
#define DT_JMPREL 23 // reloc entries only with PLT
#define DT_EXPORT 0x60000001 // address of export table
#define DT_EXPORTSZ 0x60000002 // size of export table
#define DT_EXPENT 0x60000003 // size of export table entry
#define DT_IMPORT 0x60000004 // address of import table
#define DT_IMPORTSZ 0x60000005 // size of import table
#define DT_IMPENT 0x60000006 // size of import table entry
#define DT_IT 0x60000007 // init and term types for a DLL.
#define DT_ITPRTY 0x60000008 // relative priority of init and term to other functions
#define DT_INITTERM 0x60000009 // address of init and term function
#define DT_PPC_GOT 0x70000001 // address of Global Offset Table
#define DT_PPC_GOTSZ 0x70000002 // size of Global Offset Table
#define DT_PPC_PLTSZ 0x70000003 // size of Procedure Linkage Table
#define DT_LOPROC 0x70000000 // range of processor-defined tags
#define DT_HIPROC 0x7FFFFFFF
// Old dynamic tags. Readers should handle these, writers must use the above
#define DT_INIT_O 12 // address of initialization function
#define DT_FINI_O 13 // address of finialization function
#define DT_RPATH_O 15 // library search path
#define DT_SYMBOLIC_O 16 // affects dyn. linker's sym. resolution
#define DT_TEXTREL_O 22 // signal we might mod. a non-writable segment
#define DT_IT_O 24 // init and term types for a DLL.
#define DT_EXPORT_O 25 // address of export table
#define DT_EXPORTSZ_O 26 // size of export table
#define DT_IMPORT_O 27 // address of import table
#define DT_IMPORTSZ_O 28 // size of import table
#define DT_GOT_O 29 // address of Global Offset Table
#define DT_GOTSZ_O 30 // size of Global Offset Table
#define DT_PLTSZ_O 32 // size of Procedure Linkage Table
#define DT_ITPRTY_O 33 // relative priority of init and term to other functions
#define DT_LOUSER_O 0x60000000 // range of user-definable tags. will not
#define DT_HIUSER_O 0x6FFFFFFF // conflict with system-defined tags
// Ha Ha Ha!
// description of DT_IT tag:
// Describe type for initalization and termination of DLL
// Required if DT_INIT and DT_FINI also specified
#define ELF_32_IT_INIT(it) ((it) & 0x0f)
#define ELF_32_IT_TERM(it) (((it) >> 4) & 0x0f)
#define ELF_32_IT_INFO(i,t) (((i) & 0x0f)|(((t) & 0x0f) << 4))
#define IT_NONE 0 // no initialization or termination
#define IT_GLOBAL 1 // global init, term
#define IT_INSTANCE 2 // process init, term
#define IT_THREAD 3 // thread init, term
// DT_INITTERM function prototype
typedef unsigned long INITTERM ( unsigned long modhandle, unsigned long flag );
// elf segment flag bits
#define PF_X 0x1 // seg has execute permissions
#define PF_W 0x2 // seg has write permissions
#define PF_R 0x4 // seg has read permissions
#define PF_S 0x01000000 // segment is shared.
#define PF_MASKPROC 0xf0000000 // processor-specific flag mask
// operating system information
typedef struct {
uint_32 os_type;
uint_32 os_size;
} Elf32_Os;
#define EOS_NONE 0 // bad or unknown
#define EOS_PN 1 // IBM Microkernel personality neutral
#define EOS_SVR4 2 // UNIX System V Release 4
#define EOS_AIX 3 // IBM AIX
#define EOS_OS2 4 // IBM OS/2, 32 bit
#define EOS_NT 5 // Microsoft Windows NT, 32 bit
#define EOS_VMS 6 // DEC VMS/VAX
#define EOS_OS400 7 // IBM OS/400
#define EOS_NEXT 8 // NEXT
#define EOS_SYSTEM7 9 // Apple System 7
// OS/2-specific information
typedef struct {
unsigned char os2_sessiontype;
unsigned char os2_sessionflags;
unsigned char os2_reserved[14];
} Elf32_OS2Info;
// os2_sessiontype values
#define OS2_SES_NONE 0 // no session type. Only valid for DLL's
#define OS2_SES_FS 1 // Full Screen session.
#define OS2_SES_PM 2 // Presentation Manager session.
#define OS2_SES_VIO 3 // Windowed (character-mode) session
// import table entry
typedef struct {
uint_32 imp_ordinal;
uint_32 imp_name;
uint_32 imp_info;
uint_32 imp_reserved;
} Elf32_Import;
#define ELF32_IMP_TYPE(i) ((i) >> 24)
#define ELF32_IMP_DLL(i) ((i) & 0x00FFFFFF)
#define ELF32_IMP_INFO(t,d) (((t)<<24) | ((d) & 0x00FFFFFF)))
#define IMP_IGNORED 0 // This import entry to be ignored
#define IMP_STR_IDX 1 // Value is string table index to load module
#define IMP_DT_IDX 2 // Value is ref to DT_NEEDED in Dynamic Segment
// export table entry
typedef struct {
uint_32 exp_ordinal;
uint_32 exp_symbol;
uint_32 exp_name;
uint_32 exp_reserved;
} Elf32_Export;
// Resource header
#define RH_NIDENT 16
typedef struct {
unsigned char rh_ident[RH_NIDENT];
uint_32 rh_name;
uint_32 rh_itnum;
uint_32 rh_rhsize;
uint_32 rh_size;
uint_32 rh_strtab;
} Elf32_Rhdr;
// rh_ident field indices
#define ELFRESMAG0 '\002' // bytes of signature
#define ELFRESMAG1 'R' // bytes of signature
#define ELFRESMAG2 'E' // bytes of signature
#define ELFRESMAG3 'S' // bytes of signature
#define RH_MAG0 0 // signature bytes
#define RH_MAG1 1 // signature bytes
#define RH_MAG2 2 // signature bytes
#define RH_MAG3 3 // signature bytes
#define RH_CLASS 4 // class of resource collection
#define RH_DATA 5 // data encoding of resource collection
#define RH_VERSION 6 // version
#define RH_PAD 7 // start of padding bytes - set to 0
// contents of RH_CLASS field
#define RESCLASSNONE 0 // invalid class
#define RESCLASS32 2 // 32-bit architecture
#define RESCLASS64 3 // reserved for 64-bit architecture
// contents of RH_DATA field
#define RESDATANONE 0 // invalid data
#define RESDATA2LSB 1 // Little Endian data encoding
#define RESDATA2MSB 2 // Bit Endian data encoding
// contents of RH_VERSION field
#define RV_NONE 0 // invalid version
#define RV_CURRENT 1 // current version. will change in future.
// resource item
#define RI_NIDENT 4
typedef struct {
unsigned char ri_ident[RI_NIDENT];
uint_32 ri_type;
uint_32 ri_typename;
uint_32 ri_ordinal;
uint_32 ri_ordname;
uint_32 ri_data;
uint_32 ri_flags;
uint_32 ri_size;
uint_32 ri_reserved;
} Elf32_Ritem;
// ri_ident field indices
#define RI_VERSION 0 // version
#define RI_PAD 1 // start of padding bytes - set to 0
// contents of RI_VERSION field
#define IV_NONE 0 // invalid version
#define IV_CURRENT 1 // current version. will change in future
// demangle information structure
typedef struct {
uint_32 idm_dllname;
uint_32 idm_initparms;
} Elf32_Demangle;
// default library structure
typedef struct {
uint_32 lib_name;
} Elf32_Library;
#endif // _ELFSPEC_H_INCLUDED_

37
H/equate.h Normal file
View File

@ -0,0 +1,37 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: EQU and '=' directives interface
*
****************************************************************************/
#ifndef _EQUATE_H_INCLUDED
#define _EQUATE_H_INCLUDED
extern struct asym *CreateConstant( struct asm_tok[] );
extern struct asym *CreateVariable( const char *, int );
#endif

74
H/errmsg.h Normal file
View File

@ -0,0 +1,74 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Assembler message output interface.
* This file is included by globals.h.
*
****************************************************************************/
#ifndef _ERRMSG_H_INCLUDED
#define _ERRMSG_H_INCLUDED
/* error IDs */
#undef pick
#define pick( code, text ) code,
enum msgno {
#include "msgdef.h"
MSG_LAST
};
#undef pick
#ifdef DEBUG_OUT
extern void DoDebugMsg( const char *format, ... );
extern void DoDebugMsg1( const char *format, ... );
#define DebugMsg( x ) DoDebugMsg x
#define DebugMsg1( x ) DoDebugMsg1 x
#define DebugCmd( x ) x
#else
#define DebugMsg( x )
#define DebugMsg1( x )
#define DebugCmd( x )
#endif
#if defined( __UNIX__ ) || defined ( __SW_BD )
#define errout stderr
#else
#define errout stdout
#endif
extern void Fatal( int msgnum, ... );
extern int EmitError( int msgnum );
extern int EmitErr( int msgnum, ... );
extern void EmitWarn( int level, int msgnum, ... );
extern void PrintNote( int msgnum, ... );
extern char *ErrnoStr( void );
extern int write_logo( void );
extern void PrintUsage( void );
//extern void SeekError( void );
extern void WriteError( void );
#endif

139
H/expreval.h Normal file
View File

@ -0,0 +1,139 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: interface to expression evaluator
*
****************************************************************************/
#ifndef EXPREVAL_H
#define EXPREVAL_H
/* v2.11: EXPR_UNDEF changed to EXPR_ERROR, value -1 */
enum exprtype {
EXPR_EMPTY = EMPTY,
EXPR_ERROR = ERROR, /* undefined type when error occures or result is undefined */
EXPR_CONST = 0, /* constant; note that "label1 - label2" -> constant */
EXPR_ADDR, /* e.g. "foo", "seg foo" and "offset foo", also indirect mem ops */
EXPR_REG, /* register */
EXPR_FLOAT /* v2.05: float */
};
/* argument types accepted by unary operators */
enum oparg_types {
AT_TYPE = 0x01, /* type */
AT_LABEL = 0x02, /* label (direct memory) */
AT_IND = 0x04, /* indirect memory */
AT_REG = 0x08, /* register */
AT_FIELD = 0x10, /* struct field */
AT_NUM = 0x20, /* number */
AT_BF = 0x40, /* bitfield and record types */
AT_UNDEF = 0x80, /* undefined label */
AT_FLOAT = 0x100,/* float constant */
AT_CONST = AT_TYPE | AT_NUM,
AT_TL = AT_TYPE | AT_LABEL,
AT_TLN = AT_TYPE | AT_LABEL | AT_NUM,
AT_TLF = AT_TYPE | AT_LABEL | AT_FIELD,
AT_TLFN = AT_TYPE | AT_LABEL | AT_FIELD | AT_NUM,
AT_TBF = AT_TYPE | AT_BF,
AT_LF = AT_LABEL| AT_FIELD,
AT_LIF = AT_LABEL| AT_IND | AT_FIELD,
AT_LFN = AT_LABEL| AT_FIELD | AT_NUM,
AT_TLR = AT_TYPE | AT_LABEL | AT_REG,
AT_ALL = AT_TYPE | AT_LABEL | AT_IND | AT_REG | AT_FIELD | AT_NUM | AT_UNDEF | AT_BF | AT_FLOAT
};
/* expression, returned by expression evaluator */
struct expr {
union { /* value of expression */
struct {
int_32 value;
int_32 hvalue;
};
struct {
uint_64 llvalue;
uint_64 hlvalue;
};
uint_32 uvalue;
int_64 value64;
float fvalue;
int st_idx; /* EXPR_REG: index if reg is ST */
uint_8 chararray[16];
};
union {
struct asm_tok *quoted_string; /* for EXPR_CONST + quoted strings only */
struct asm_tok *float_tok; /* for EXPR_FLOAT only */
};
struct asm_tok *base_reg; /* EXPR_ADDR: base register token */
/* EXPR_REG: register token */
struct asm_tok *idx_reg; /* EXPR_ADDR: index register token */
union {
struct asm_tok *label_tok; /* token holding the label (EXPR_ADDR, used for overrides, inside expreval only) */
struct asm_tok *type_tok; /* v2.10: token if target type of a label (SYM_STACK, MT_PTR) is to be stored */
};
struct asm_tok *override; /* EXPR_ADDR: token holding the override label */
/* or segment register */
enum special_token instr; /* operator token */
enum exprtype kind; /* Type of expression */
enum memtype mem_type; /* memory type if expr is a memory ref. */
uint_8 scale; /* EXPR_ADDR: scaling factor 1, 2, 4, or 8 - 386 code only */
uint_8 Ofssize; /* 16,32,64 bit if MT_NEAR, MT_FAR */
union {
uint_8 flags1;
struct {
unsigned indirect : 1; /* indirect addressing used */
unsigned explicit : 1; /* Whether expression type explicitly given (to be removed!) */
unsigned is_abs : 1; /* external ABS */
unsigned is_type : 1; /* constant is a type */
unsigned is_opattr: 1; /* current operator is OPATTR */
unsigned negative : 1; /* for EXPR_FLOAT only */
//unsigned ftype : 1; /* for EXPR_FLOAT only (float type) */
unsigned assumecheck: 1;/* v2.07: for ASSUMEd std registers */
unsigned is_dot: 1; /* v2.10: see regression test dotop5.asm */
};
};
struct asym *sym; /* label used */
struct asym *mbr; /* struct member */
struct asym *type; /* for DOT operator. Must be last (see TokenAssign)! */
};
/* flags for last argument of EvalOperand() */
enum expr_flags {
EXPF_NOERRMSG = 1, /* suppress error messages */
EXPF_NOUNDEF = 2, /* don't accept or create undefined symbols */
EXPF_ONEOPND = 4, /* private flag, used inside expreval.c only */
EXPF_IN_SQBR = 8 /* private flag, used inside expreval.c only */
};
extern ret_code EvalOperand( int *, struct asm_tok[], int, struct expr *, uint_8 );
extern void ExprEvalInit( void );
extern ret_code EmitConstError( const struct expr * );
#endif

20
H/extern.h Normal file
View File

@ -0,0 +1,20 @@
/****************************************************************************
*
* Description: prototypes of extern.c
*
****************************************************************************/
#ifndef _EXTERN_H_
#define _EXTERN_H_
/*---------------------------------------------------------------------------*/
//extern struct asym *CreateExternal( struct asym *sym, const char *name, char weak );
extern struct asym *MakeExtern( const char *name, enum memtype type, struct asym * vartype, struct asym *, unsigned char );
//extern struct asym *CreateProto( int, const char * );
extern void AddPublicData( struct asym *sym );
//extern struct asym *GetPublicSymbols( void ** ); /* v2.11: obsolete */
extern void FreePubQueue( void );
#endif

90
H/fastpass.h Normal file
View File

@ -0,0 +1,90 @@
/* this is Public Domain.
fastpass.h defines structures and externals which are needed by the
"fast pass" feature. This feature speeds JWasm's assembly significantly
if huge header files containing declarations and definitions are used
(as it is the case with Win32Inc and Masm32), since the header files are
then scanned in pass one only.
*/
#if FASTPASS
/* equ_item: used for a linked list of assembly time variables. Any variable
which is defined or modified after SaveState() has been called is to be stored
here - once! */
struct equ_item {
struct equ_item *next;
struct asym *sym;
int lvalue;
int hvalue;
enum memtype mem_type; /* v2.07: added */
bool isdefined;
};
/* line_item: used for a linked list of preprocessed lines. After SaveState()
* has been called, all preprocessed lines are written in pass one and read
* in further passes
*/
struct line_item {
struct line_item *next;
uint_32 lineno:20, srcfile:12;
uint_32 list_pos; /* position .LST file */
char line[1];
};
extern struct line_item *LineStoreCurr;
/* mod_state: used to store the module state within SaveState()
*/
struct mod_state {
bool init; /* is this struct initialized? */
struct {
struct equ_item *head; /* the list of modified assembly time variables */
struct equ_item *tail;
} Equ;
uint_8 modinfo[ sizeof( struct module_info ) - sizeof( struct module_vars ) ];
};
/* source lines start to be "stored" when one of the following is detected:
* - an instruction
* - a data item (but not a struct field)
* - directives which "generate source": PROC, INVOKE, .IF, .WHILE, .REPEAT
* - directives ALIGN and ORG (which emit bytes and/or change $)
* - directive END (to ensure that there is at least 1 line)
* - directive ASSUME if operand is a forward reference
*/
//extern struct mod_state modstate;
extern bool StoreState; /* is 1 if states are to be stored in pass one */
/* UseSavedState: is TRUE if preprocessed lines are to be read in pass 2,3,...
* Currently, this flag is set DURING pass one! That's bad,
* because it means that the flag itself doesn't tell whether
* (preprocessed) lines are read.
* the fix proposal is: set the flag - conditionally - AFTER pass one.
* Also, rename the flag (perhaps UseSavedLines )!
*/
extern bool UseSavedState;
//void SaveState( void );
void FastpassInit( void );
void SegmentSaveState( void );
void AssumeSaveState( void );
void ContextSaveState( void );
void StoreLine( const char *, int, uint_32 );
void SkipSavedState( void );
struct line_item *RestoreState( void );
void SaveVariableState( struct asym *sym );
void FreeLineStore( void );
#define FStoreLine( flags ) if ( Parse_Pass == PASS_1 ) StoreLine( CurrSource, flags, 0 ); else
#else
#define FStoreLine( flags )
#endif

136
H/fixup.h Normal file
View File

@ -0,0 +1,136 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: fixup related variables and routines
*
****************************************************************************/
#ifndef FIXUP_H
#define FIXUP_H
/* RELOFF8 - RELOFF32 must be consecutive */
enum fixup_types {
FIX_VOID = 0, /* 0, fixup is to be ignored */
FIX_RELOFF8, /* 1, 1 byte */
FIX_RELOFF16, /* 2, 2 byte */
FIX_RELOFF32, /* 3, 4 byte */
FIX_OFF8, /* 4, 1 byte, OMF, BIN + GNU-ELF only */
FIX_OFF16, /* 5, 2 byte */
FIX_OFF32, /* 6, 4 byte */
#if AMD64_SUPPORT
FIX_OFF64, /* 7, 8 byte, COFF64, ELF64 + BIN only */
#endif
FIX_SEG = 8, /* 8, 2 byte */
FIX_PTR16, /* 9, 4 byte, OMF+BIN-MZ only */
FIX_PTR32, /* 10, 6 byte, OMF+BIN-MZ only */
FIX_HIBYTE, /* 11, 1 byte, OMF+BIN-MZ only */
FIX_OFF32_IMGREL, /* 12, 4 byte, COFF+ELF only */
FIX_OFF32_SECREL, /* 13, 4 byte, COFF+ELF only */
FIX_LAST
};
/* OMF: nothing (7, 12, 13 can't happen)
* COFF: set bit 1, 4, 9, 10, 11
* ELF: set bit 8, 9, 10, 11
*/
#if BIN_SUPPORT
#define BIN_DISALLOWED 0x0000
#endif
#define OMF_DISALLOWED 0x0000
#if COFF_SUPPORT
/* exclude RELOFF8, OFF8, PTR16, PTR32, HIBYTE */
#define COFF32_DISALLOWED 0x0E12
/* exclude RELOFF8, OFF8, PTR16, PTR32, HIBYTE */
#define COFF64_DISALLOWED 0x0E12
#endif
#if ELF_SUPPORT
/* exclude SEG, PTR16, PTR32, HIBYTE */
#define ELF32_DISALLOWED 0x0F00
/* exclude SEG, PTR16, PTR32, HIBYTE */
#define ELF64_DISALLOWED 0x0F00
#endif
/* fixups are also used for backpatching of forward references in pass one.
* the instructions which depend on the distance are CALL, JMP, PUSH <imm>.
* OPTJ_EXPLICIT: JMP SHORT <label> or Jcc SHORT <label>, size cannot change
* OPTJ_EXTEND: Jcc <label> for cpu < 80386, size may change (2 -> 5/7 or 8/10)
* OPTJ_JXX: Jcc <label> for cpu >= 80386, size may change (2 -> 5 )
* OPTJ_CALL: call <label>, may become push cs, call NEAR or call FAR
* OPTJ_PUSH: push <label>, assumed byte, may become variable or label.
*/
enum fixup_options {
OPTJ_NONE, /* normal jump */
OPTJ_EXPLICIT,
OPTJ_EXTEND,
OPTJ_JXX,
OPTJ_CALL,
OPTJ_PUSH /* PUSH */
};
struct fixup {
struct fixup *nextbp; /* PASS 1: linked list backpatch */
struct fixup *nextrlc; /* PASS >1: linked list relocs */
#ifdef TRMEM
uint_16 marker;
#endif
uint_32 offset; /* symbol's offset */
uint_32 locofs; /* location of fixup */
enum fixup_types type;
enum fixup_options option;
union {
uint_16 flags;
struct {
#if AMD64_SUPPORT
/* the IP relative addressing needs to know where the instruction ends.
* the result <end of instruction> - <fixup location> is stored here.
*/
uint_8 addbytes;
#endif
unsigned char loader_resolved:1; /* operator LROFFSET */
unsigned char orgoccured:1; /* v2.04 ORG occured behind this fix */
};
};
union {
struct {
int_8 frame_type; /* frame specifier (SEG=0,GRP=1,,...) */
uint_16 frame_datum; /* additional data, usually index */
};
struct asym *segment_var; /* symbol's segment if assembly time var */
};
struct dsym *def_seg; /* segment the fixup is in - pass 1 only */
struct asym *sym;
};
extern struct fixup *CreateFixup( struct asym *sym, enum fixup_types fixup_type, enum fixup_options fixup_option );
extern void SetFixupFrame( const struct asym *sym, char );
extern void FreeFixup( struct fixup * );
extern void store_fixup( struct fixup *, struct dsym *, int_32 * );
extern ret_code BackPatch( struct asym *sym );
#endif

8
H/fpfixup.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef _FPFIXUP_H_INCLUDED
#define _FPFIXUP_H_INCLUDED
extern void AddFloatingPointEmulationFixup( struct code_info * );
#endif

872
H/globals.h Normal file
View File

@ -0,0 +1,872 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: JWasm globals and limits.
*
****************************************************************************/
#ifndef _GLOBALS_H_INCLUDED
#define _GLOBALS_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h> /* needed for errno declaration ( "sometimes" it's defined in stdlib.h ) */
#if defined(__UNIX__) || defined(__CYGWIN__) || defined(__DJGPP__) /* avoid for MinGW! */
#define _stricmp strcasecmp
#ifndef __WATCOMC__
#define _memicmp strncasecmp
#endif
#define _ltoa ltoa
#define _strupr strupr
#elif defined(__POCC__)
#pragma warn(disable:2030) /* disable '=' used in a conditional expression */
#pragma warn(disable:2229) /* disable 'local x is potentially used without ...' */
#pragma warn(disable:2231) /* disable 'enum value x not handled in switch statement' */
#elif defined(__BORLANDC__) || defined(__OCC__)
#define _stricmp stricmp
#define _strnicmp strnicmp
#define _strupr strupr
#define _memicmp memicmp
#endif
#define MAX_LINE_LEN 600 /* no restriction for this number */
#define MAX_TOKEN MAX_LINE_LEN / 4 /* max tokens in one line */
#define MAX_STRING_LEN MAX_LINE_LEN - 32 /* must be < MAX_LINE_LEN */
#define MAX_ID_LEN 247 /* must be < MAX_LINE_LEN */
#define MAX_STRUCT_ALIGN 32
/* v2.06: obsolete */
//#define MAX_RESW_LEN 31 /* max length of a reserved word */
#define MAX_IF_NESTING 20 /* IFxx block nesting. Must be <=32, see condasm.c */
//#define MAX_TEXTMACRO_NESTING 20
#define MAX_SEG_NESTING 20 /* limit for segment nesting */
#ifdef __I86__
#define MAX_MACRO_NESTING 20
#else
#define MAX_MACRO_NESTING 40 /* macro call nesting */
#endif
#define MAX_STRUCT_NESTING 32 /* limit for "anonymous structs" only */
#define MAX_LNAME 255 /* OMF lnames - length must fit in 1 byte */
#define LNAME_NULL 0 /* OMF first entry in lnames array */
/* output format switches */
#ifndef BIN_SUPPORT
#define BIN_SUPPORT 1 /* support BIN output format */
#endif
#if BIN_SUPPORT
#ifndef MZ_SUPPORT
#define MZ_SUPPORT 1 /* support DOS MZ binary format */
#endif
#ifndef PE_SUPPORT
#define PE_SUPPORT 1 /* support PE32 + PE64 binary format */
#endif
#else
#define MZ_SUPPORT 0 /* both MZ and PE need BIN==1 */
#define PE_SUPPORT 0
#endif
#ifndef COFF_SUPPORT
#define COFF_SUPPORT 1 /* support COFF output format */
#endif
#ifndef DJGPP_SUPPORT
#define DJGPP_SUPPORT 0 /* support for Djgpp COFF variant */
#endif
#ifndef ELF_SUPPORT
#define ELF_SUPPORT 1 /* support ELF output format */
#endif
/* instruction set switches */
#define K3DSUPP 1 /* support K3D instruction set */
#define SSE3SUPP 1 /* support SSE3 instruction set */
#ifndef AMD64_SUPPORT
#define AMD64_SUPPORT 1 /* 1=support 64bit */
#endif
#ifndef VMXSUPP
#define VMXSUPP 1 /* support VMX extensions */
#endif
#ifndef SVMSUPP
#define SVMSUPP 0 /* support SVM (=AMD-V) extensions */
#endif
#ifndef SSSE3SUPP
#define SSSE3SUPP 1 /* support SSSE3 instruction set */
#endif
#ifndef SSE4SUPP
#define SSE4SUPP 1 /* support SSE4 instruction set */
#endif
#ifndef AVXSUPP
#define AVXSUPP 1 /* support AVX extensions */
#endif
#ifndef COMDATSUPP
#define COMDATSUPP 1 /* support COMDAT segment attribute */
#endif
/* other extension switches */
#define IMAGERELSUPP 1 /* support IMAGEREL operator (not for OMF) */
#define SECTIONRELSUPP 1 /* support SECTIONREL operator (not for OMF) */
#define FIELDALIGN 1 /* support OPTION FIELDALIGN:<const> */
#define PROCALIGN 1 /* support OPTION PROCALIGN:<const> */
#define LOHI32 1 /* support LOW32/HIGH32 operators */
#define XMMWORD 1 /* support MMWORD and XMMWORD types */
#define RENAMEKEY 1 /* support OPTION RENAMEKEYWORD:<old>,new */
#define MACROLABEL 1 /* support LABEL qualifier for macro arg */
#define BACKQUOTES 1 /* allow IDs enclosed in ` */
#define FPIMMEDIATE 1 /* allow float immediates: mov eax,1.0 */
#define INCBINSUPP 1 /* support INCBIN directive */
#define INTELMOVQ 0 /* 1=MOVQ moves to/from 64-bit registers */
#ifndef OWFC_SUPPORT
#define OWFC_SUPPORT 1 /* support OW fastcall flavor */
#endif
#ifndef DLLIMPORT
#define DLLIMPORT 1 /* support OPTION DLLIMPORT */
#endif
#ifndef CVOSUPP
#define CVOSUPP 1 /* support OPTION CODEVIEW */
#endif
#define MASM_SSE_MEMX 1 /* support 2 mem types for mmx/xmm */
#define PERCENT_OUT 1 /* 1=support %OUT directive */
#ifndef STACKBASESUPP
#define STACKBASESUPP 1 /* support OPTION STACKBASE */
#endif
#define VARARGML 1 /* multi line vararg for macros */
/* old Wasm extensions */
#define PAGE4K 0 /* support 4kB-page OMF segment alignment */
#define BUILD_TARGET 0 /* support "build target" (obsolete) */
#define COCTALS 0 /* allow C form of octals */
#define CHEXPREFIX 0 /* accept "0x" as hex number prefix */
#define MANGLERSUPP 0 /* support Wasm's "mangler" extension */
/* internal assembler optimizations */
#ifndef FASTPASS
#define FASTPASS 1 /* don't scan full source if pass > 1 */
#endif
#ifndef FASTMEM
#define FASTMEM 1 /* fast memory allocation */
#endif
#include "inttype.h"
#include "bool.h"
#include "errmsg.h" /* must be located AFTER #defines lines */
#include "queue.h"
/* JWasm version info */
#define _JWASM_VERSION_STR_ "2.12"
#define _JWASM_VERSION_INT_ 212
#define _JWASM_VERSION_SUFFIX_ "pre"
#define _JWASM_VERSION_ _JWASM_VERSION_STR_ _JWASM_VERSION_SUFFIX_
#define NULLC '\0'
//#define NULLS ""
#define is_valid_id_char( ch ) ( isalnum(ch) || ch=='_' || ch=='@' || ch=='$' || ch=='?' )
#define is_valid_id_first_char( ch ) ( isalpha(ch) || ch=='_' || ch=='@' || ch=='$' || ch=='?' || (ch == '.' && ModuleInfo.dotname == TRUE ))
/* function return values */
typedef enum {
EMPTY = -2,
ERROR = -1,
NOT_ERROR = 0,
STRING_EXPANDED = 1
} ret_code;
enum {
PASS_1 = 0,
PASS_2
};
/* enumerations */
/* output formats. Order must match formatoptions[] in assemble.c */
enum oformat {
#if BIN_SUPPORT
OFORMAT_BIN, /* used by -bin, -mz and -pe */
#endif
OFORMAT_OMF,
#if COFF_SUPPORT
OFORMAT_COFF,/* used by -coff, -djgpp and -win64 */
#endif
#if ELF_SUPPORT
OFORMAT_ELF, /* used by -elf and elf64 */
#endif
};
enum sformat {
SFORMAT_NONE,
#if MZ_SUPPORT
SFORMAT_MZ, /* MZ binary */
#endif
#if PE_SUPPORT
SFORMAT_PE, /* PE (32- or 64-bit) binary */
#endif
#if COFF_SUPPORT
#if DJGPP_SUPPORT
SFORMAT_DJGPP, /* Djgpp variant of COFF */
#endif
#endif
#if COFF_SUPPORT || ELF_SUPPORT
#if AMD64_SUPPORT
SFORMAT_64BIT, /* 64bit COFF or ELF */
#endif
#endif
};
enum fpo {
FPO_NO_EMULATION, /* -FPi87 (default) */
FPO_EMULATION /* -FPi */
};
/* language vaules.
* the order cannot be changed, it's
* returned by OPATTR and used in user-defined prologue/epilogue.
*/
enum lang_type {
LANG_NONE = 0,
LANG_C = 1,
LANG_SYSCALL = 2,
LANG_STDCALL = 3,
LANG_PASCAL = 4,
LANG_FORTRAN = 5,
LANG_BASIC = 6,
LANG_FASTCALL = 7
};
/* Memory model type.
* the order cannot be changed, it's
* the value of the predefined @Model symbol.
*/
enum model_type {
MODEL_NONE = 0,
MODEL_TINY = 1,
MODEL_SMALL = 2,
MODEL_COMPACT = 3,
MODEL_MEDIUM = 4,
MODEL_LARGE = 5,
MODEL_HUGE = 6,
MODEL_FLAT = 7,
};
#define SIZE_DATAPTR 0x68 /* far for COMPACT, LARGE, HUGE */
#define SIZE_CODEPTR 0x70 /* far for MEDIUM, LARGE, HUGE */
enum seg_order {
SEGORDER_SEQ = 0, /* .SEQ (default) */
SEGORDER_DOSSEG, /* .DOSSEG */
SEGORDER_ALPHA /* .ALPHA */
};
/* .NOLISTMACRO, .LISTMACRO and .LISTMACROALL directives setting */
enum listmacro {
LM_NOLISTMACRO,
LM_LISTMACRO,
LM_LISTMACROALL
};
/* assume values are used as index in codegen.c / invoke.c.
* Order must match the one in special.h. Don't change!
*/
enum assume_segreg {
ASSUME_NOTHING = EMPTY,
ASSUME_ES = 0,
ASSUME_CS,
ASSUME_SS,
ASSUME_DS,
ASSUME_FS,
ASSUME_GS
};
enum cpu_info {
/* bit count from left:
* bit 0-2: Math coprocessor
* bit 3: privileged?
* bit 4-7: cpu type
* bit 8-15; extension set
*/
P_NO87 = 0x0001, /* no FPU */
P_87 = 0x0002, /* 8087 */
P_287 = 0x0003, /* 80287 */
P_387 = 0x0004, /* 80387 */
P_PM = 0x0008, /* privileged opcode */
P_86 = 0x0000, /* 8086, default */
P_186 = 0x0010, /* 80186 */
P_286 = 0x0020, /* 80286 */
P_386 = 0x0030, /* 80386 */
P_486 = 0x0040, /* 80486 */
P_586 = 0x0050, /* pentium */
P_686 = 0x0060, /* ppro */
#if AMD64_SUPPORT
P_64 = 0x0070, /* x64 cpu */
#endif
P_286p = P_286 | P_PM, /* 286, priv mode */
P_386p = P_386 | P_PM, /* 386, priv mode */
P_486p = P_486 | P_PM, /* 486, priv mode */
P_586p = P_586 | P_PM, /* 586, priv mode */
P_686p = P_686 | P_PM, /* 686, priv mode */
#if AMD64_SUPPORT
P_64p = P_64 | P_PM, /* x64, priv mode */
#endif
P_MMX = 0x0100, /* MMX extension instructions */
#if K3DSUPP
P_K3D = 0x0200, /* 3DNow extension instructions */
#endif
P_SSE1 = 0x0400, /* SSE1 extension instructions */
P_SSE2 = 0x0800, /* SSE2 extension instructions */
P_SSE3 = 0x1000, /* SSE3 extension instructions */
#if SSSE3SUPP
P_SSSE3 = 0x2000, /* SSSE3 extension instructions */
#if SSE4SUPP
P_SSE4 = 0x4000, /* SSE4 extension instructions */
#if AVXSUPP
P_AVX = 0x8000, /* AVX extension instructions */
#endif
#endif
#endif
/* all SSE extension instructions */
#if SSSE3SUPP
#if SSE4SUPP
#if AVXSUPP
P_SSEALL = P_SSE1 | P_SSE2 | P_SSE3 | P_SSSE3 | P_SSE4 | P_AVX,
#else
P_SSEALL = P_SSE1 | P_SSE2 | P_SSE3 | P_SSSE3 | P_SSE4,
#endif
#else
P_SSEALL = P_SSE1 | P_SSE2 | P_SSE3 | P_SSSE3,
#endif
#else
P_SSEALL = P_SSE1 | P_SSE2 | P_SSE3,
#endif
NO_OPPRFX = P_MMX | P_SSEALL,
P_FPU_MASK = 0x0007,
P_CPU_MASK = 0x00F0,
#if K3DSUPP
P_EXT_MASK = P_MMX | P_K3D | P_SSEALL,
P_EXT_ALL = P_MMX | P_K3D | P_SSEALL
#else
P_EXT_MASK = P_MMX | P_SSEALL,
P_EXT_ALL = P_MMX | P_SSEALL
#endif
};
/* the MASM compatible @CPU value flags: */
enum masm_cpu {
M_8086 = 0x0001, /* 8086 */
M_186 = 0x0002, /* 186 */
M_286 = 0x0004, /* 286 */
M_386 = 0x0008, /* 386 */
M_486 = 0x0010, /* 486 */
M_586 = 0x0020, /* Pentium */
M_686 = 0x0040, /* PPro */
M_CPUMSK = 0x007F,
M_PROT = 0x0080, /* protected instructions ok */
M_8087 = 0x0100, /* 8087 */
M_287 = 0x0400, /* 287 */
M_387 = 0x0800 /* 387 */
};
#if MANGLERSUPP
enum naming_types {
NC_DO_NOTHING,
/* put uscores on the front of labels & the back of procedures.
* this is what the OW compiler does with /3r
*/
NC_ADD_USCORES,
/* assume that the user manually put uscores as described above
* into the assembly file and take them off
*/
NC_REMOVE_USCORES
};
#endif
enum segofssize {
USE_EMPTY = 0xFE,
USE16 = 0, /* don't change values of USE16,USE32,USE64! */
USE32 = 1,
#if AMD64_SUPPORT
USE64 = 2
#endif
};
/* fastcall types. if order is to be changed or entries
* added, also adjust tables in proc.c, mangle.c and probably invoke.c!
*/
enum fastcall_type {
FCT_MSC, /* MS 16-/32-bit fastcall (ax,dx,cx / ecx,edx) */
#if OWFC_SUPPORT
FCT_WATCOMC, /* OW register calling convention (eax, ebx, ecx, edx) */
#endif
#if AMD64_SUPPORT
FCT_WIN64 /* Win64 fastcall convention (rcx, rdx, r8, r9) */
#endif
};
enum stdcall_decoration {
STDCALL_FULL,
STDCALL_NONE,
STDCALL_HALF
};
struct qitem {
void *next;
char value[1];
};
/* file extensions. Order must match first entries in enum opt_names! */
enum file_extensions {
ASM, /* must be first; see SetFilenames() in assembly.c */
OBJ,
LST,
ERR,
NUM_FILE_TYPES
};
/* first 4 entries must match enum file_extensions! */
enum opt_names {
OPTN_ASM_FN,
OPTN_OBJ_FN, /* -Fo option */
OPTN_LST_FN, /* -Fl option */
OPTN_ERR_FN, /* -Fr option */
#if DLLIMPORT
OPTN_LNKDEF_FN, /* -Fd option */
#endif
OPTN_MODULE_NAME, /* -nm option */
OPTN_TEXT_SEG, /* -nt option */
OPTN_DATA_SEG, /* -nd option */
OPTN_CODE_CLASS, /* -nc option */
#if BUILD_TARGET
OPTN_BUILD_TARGET, /* -bt option */
#endif
#if MANGLERSUPP
OPTN_DEFNAME_MANGLER,
#endif
OPTN_LAST
};
/* queues to store multiple cmdline switch values */
enum opt_queues {
OPTQ_FINCLUDE, /* -Fi option values */
OPTQ_MACRO, /* -D option values */
OPTQ_INCPATH, /* -I option values */
OPTQ_LAST
};
enum prologue_epilogue_mode {
PEM_DEFAULT, /* must be value 0 */
PEM_MACRO,
PEM_NONE
};
/* Stack distance */
enum dist_type {
//STACK_NONE,
STACK_NEAR,
STACK_FAR,
};
/* Type of operating system */
enum os_type {
OPSYS_DOS,
OPSYS_OS2,
};
enum offset_type {
OT_GROUP = 0, /* OFFSET:GROUP (default, must be 0) */
OT_FLAT, /* OFFSET:FLAT */
OT_SEGMENT /* OFFSET:SEGMENT */
};
enum line_output_flags {
LOF_LISTED = 1, /* line written to .LST file */
#if FASTPASS
LOF_SKIPPOS = 2, /* suppress setting list_pos */
//LOF_STORED = 2 /* line stored in line buffer for FASTPASS */
#endif
};
/* flags for win64_flags */
enum win64_flag_values {
W64F_SAVEREGPARAMS = 0x01, /* 1=save register params in shadow space on proc entry */
W64F_AUTOSTACKSP = 0x02, /* 1=calculate required stack space for arguments of INVOKE */
W64F_STACKALIGN16 = 0x04, /* 1=stack variables are 16-byte aligned; added in v2.12 */
W64F_ALL = W64F_SAVEREGPARAMS | W64F_AUTOSTACKSP | W64F_STACKALIGN16, /* all valid flags */
};
/* codeview debug info extend */
enum cvex_values {
CVEX_MIN = 0, /* globals */
CVEX_REDUCED = 1, /* globals and locals */
CVEX_NORMAL = 2, /* globals, locals and types */
CVEX_MAX = 3, /* globals, locals, types and constants */
};
/* codeview debug info option flags */
enum cvoption_flags {
CVO_STATICTLS = 1, /* handle static tls */
};
enum seg_type {
SEGTYPE_UNDEF,
SEGTYPE_CODE,
SEGTYPE_DATA,
SEGTYPE_BSS,
SEGTYPE_STACK,
SEGTYPE_ABS,
#if PE_SUPPORT
SEGTYPE_HDR, /* only used in bin.c for better sorting */
SEGTYPE_CDATA, /* only used in bin.c for better sorting */
SEGTYPE_RELOC, /* only used in bin.c for better sorting */
SEGTYPE_RSRC, /* only used in bin.c for better sorting */
SEGTYPE_ERROR, /* must be last - an "impossible" segment type */
#endif
};
struct global_options {
bool quiet; /* -q option */
bool line_numbers; /* -Zd option */
uint_8 debug_symbols; /* -Zi option */
uint_8 debug_ext; /* -Zi option numeric argument */
enum fpo floating_point; /* -FPi, -FPi87 */
/* error handling stuff */
int error_limit; /* -e option */
uint_8 no_error_disp; /* -eq option */
uint_8 warning_level; /* -Wn option */
bool warning_error; /* -WX option */
#ifdef DEBUG_OUT
bool debug; /* -dt option */
bool nobackpatch; /* -nbp option */
#if FASTPASS
bool nofastpass; /* -nfp option */
bool print_linestore; /* -ls option */
#endif
uint_16 max_passes; /* -pm option */
bool skip_preprocessor; /* -sp option */
bool log_all_files; /* -af option */
bool dump_reswords; /* -dr option */
bool dump_reswords_hash; /* -drh option */
bool dump_symbols; /* -ds option */
bool dump_symbols_hash; /* -dsh option */
#endif
char *names[OPTN_LAST];
struct qitem *queues[OPTQ_LAST];
#if COCTALS
bool allow_c_octals; /* -o option */
#endif
bool no_comment_data_in_code_records; /* -zlc option */
bool no_opt_farcall; /* -zld option */
// bool no_dependencies; /* -zld option */
#if COFF_SUPPORT
bool no_file_entry; /* -zlf option */
bool no_static_procs; /* -zlp option */
bool no_section_aux_entry; /* -zls option */
#endif
bool no_cdecl_decoration; /* -zcw & -zcm option */
uint_8 stdcall_decoration; /* -zt<0|1|2> option */
bool no_export_decoration; /* -zze option */
bool entry_decorated; /* -zzs option */
bool write_listing; /* -Fl option */
bool write_impdef; /* -Fd option */
bool case_sensitive; /* -C<p|x|u> options */
bool convert_uppercase; /* -C<p|x|u> options */
bool preprocessor_stdout; /* -EP option */
bool masm51_compat; /* -Zm option */
bool strict_masm_compat; /* -Zne option */
bool masm_compat_gencode; /* -Zg option */
bool masm8_proc_visibility; /* -Zv8 option */
bool listif; /* -Sx, -Sa option */
bool list_generated_code; /* -Sg, -Sa option */
enum listmacro list_macro; /* -Sa option */
bool no_symbol_listing; /* -Sn option */
bool first_pass_listing; /* -Sf option */
bool all_symbols_public; /* -Zf option */
bool safeseh; /* -safeseh option */
uint_8 ignore_include; /* -X option */
enum oformat output_format; /* -bin, -omf, -coff, -elf options */
enum sformat sub_format; /* -mz, -pe, -win64, -elf64 options */
uint_8 fieldalign; /* -Zp option */
enum lang_type langtype; /* -Gc|d|z option */
enum model_type model; /* -mt|s|m|c|l|h|f option */
enum cpu_info cpu; /* -0|1|2|3|4|5|6 & -fp{0|2|3|5|6|c} option */
enum fastcall_type fctype; /* -zf0 & -zf1 option */
bool syntax_check_only; /* -Zs option */
#if MANGLERSUPP
enum naming_types naming_convention; /* OW naming peculiarities */
#endif
};
#if MZ_SUPPORT
/* if the structure changes, option.c, SetMZ() might need adjustment! */
struct MZDATA {
uint_16 ofs_fixups; /* offset start fixups */
uint_16 alignment; /* header alignment: 16,32,64,128,256,512 */
uint_16 heapmin;
uint_16 heapmax;
};
#endif
#if DLLIMPORT
struct dll_desc {
struct dll_desc *next;
int cnt; /* a function of this dll was used by INVOKE */
char name[1];
};
#endif
/* Information about the module */
struct src_item;
struct hll_item;
struct context;
struct fname_item {
char *fname;
//char *fullname; /* v2.11: removed */
//time_t mtime; /* v2.11: removed */
#ifdef DEBUG_OUT
unsigned included;
uint_32 lines;
#endif
};
struct module_info;
struct module_vars {
unsigned error_count; /* total of errors so far */
unsigned warning_count; /* total of warnings so far */
unsigned num_segs; /* number of segments in module */
/* v2.07: GlobalQueue is obsolete */
//struct qdesc GlobalQueue; /* GLOBAL items ( =externdefs ) */
struct qdesc PubQueue; /* PUBLIC items */
struct qdesc LnameQueue; /* LNAME items (segments, groups and classes) */
#if COFF_SUPPORT
struct qdesc SafeSEHQueue; /* list of safeseh handlers */
#endif
struct qdesc LibQueue; /* includelibs */
/* v2.11: AltQueue is obsolete */
//struct symbol_queue AltQueue; /* weak externals */
//struct qdesc AltQueue; /* weak externals */
#if DLLIMPORT
struct dll_desc *DllQueue; /* dlls of OPTION DLLIMPORT */
#endif
#if PE_SUPPORT || DLLIMPORT
char *imp_prefix;
#endif
FILE *curr_file[NUM_FILE_TYPES]; /* ASM, ERR, OBJ and LST */
char *curr_fname[NUM_FILE_TYPES];
struct fname_item *FNames; /* array of input files */
unsigned cnt_fnames; /* items in FNames array */
char *IncludePath;
struct qdesc line_queue; /* line queue */
struct src_item *src_stack; /* source item (files & macros) stack */
union {
struct fixup *start_fixup; /* OMF only */
struct asym *start_label; /* non-OMF only: start label */
};
uint_32 start_displ; /* OMF only, optional displ for start label */
struct hll_item *HllStack; /* for .WHILE, .IF, .REPEAT */
struct hll_item *HllFree; /* v2.06: stack of free <struct hll>-items */
struct context *ContextStack;
struct context *ContextFree; /* v2.10: "free items" heap implemented. */
#if FASTPASS
struct context *SavedContexts;
int cntSavedContexts;
#endif
/* v2.10: moved here from module_info due to problems if @@: occured on the very first line */
unsigned anonymous_label; /* "anonymous label" counter */
#if STACKBASESUPP
struct asym *StackBase;
struct asym *ProcStatus;
#endif
ret_code (* WriteModule)( struct module_info * );
ret_code (* EndDirHook)( struct module_info * );
ret_code (* Pass1Checks)( struct module_info * );
#if PE_SUPPORT
uint_8 pe_flags; /* for PE */
#endif
};
struct format_options;
struct module_info {
struct module_vars g;
char *proc_prologue; /* prologue macro if PEM_MACRO */
char *proc_epilogue; /* epilogue macro if PEM_MACRO */
#if DLLIMPORT
struct dll_desc *CurrDll; /* OPTION DLLIMPORT dll */
#endif
const struct format_options *fmtopt; /* v2.07: added */
unsigned hll_label; /* hll directive label counter */
enum dist_type distance; /* stack distance */
enum model_type model; /* memory model */
enum lang_type langtype; /* language */
enum os_type ostype; /* operating system */
enum sformat sub_format; /* sub-output format */
enum fastcall_type fctype; /* fastcall type */
enum seg_order segorder; /* .alpha, .seq, .dosseg */
enum offset_type offsettype; /* OFFSET:GROUP|FLAT|SEGMENT */
short cpu; /* cpu setting (value @cpu symbol); */
enum cpu_info curr_cpu; /* cpu setting (OW stylex); */
unsigned char radix; /* current .RADIX setting */
unsigned char fieldalign; /* -Zp, OPTION:FIELDALIGN setting */
unsigned char line_flags; /* current line has been printed */
#if PROCALIGN
unsigned char procalign; /* current OPTION:PROCALIGN setting */
#endif
enum listmacro list_macro; /* current .LISTMACRO setting */
unsigned char Ofssize; /* current offset size (USE16,USE32,USE64) */
unsigned char defOfssize; /* default segment offset size (16,32 [,64]-bit) */
unsigned char wordsize; /* current word size (2,4,8) */
unsigned char inside_comment; /* v2.10: moved from tokenize.c */
unsigned case_sensitive:1; /* option casemap */
unsigned convert_uppercase:1; /* option casemap */
unsigned procs_private:1; /* option proc:private */
unsigned procs_export:1; /* option proc:export */
unsigned dotname:1; /* option dotname */
unsigned ljmp:1; /* option ljmp */
unsigned m510:1; /* option m510 */
unsigned scoped:1; /* option scoped */
unsigned oldstructs:1; /* option oldstructs */
unsigned emulator:1; /* option emulator */
unsigned setif2:1; /* option setif2 */
unsigned list:1; /* .list/.nolist */
unsigned cref:1; /* .cref/.nocref */
unsigned listif:1; /* .listif/.nolistif */
unsigned list_generated_code:1; /* .listall, -Sa, -Sg */
unsigned StartupDirectiveFound:1;
unsigned EndDirFound:1;
#if AMD64_SUPPORT
unsigned frame_auto:1; /* win64 only */
#endif
unsigned NoSignExtend:1; /* option nosignextend */
#if ELF_SUPPORT || AMD64_SUPPORT || MZ_SUPPORT
union {
#if ELF_SUPPORT || AMD64_SUPPORT
struct {
#if ELF_SUPPORT
uint_8 elf_osabi; /* for ELF */
#endif
#if AMD64_SUPPORT
uint_8 win64_flags; /* for WIN64 + PE(32+) */
#endif
};
#endif
#if MZ_SUPPORT
struct MZDATA mz_data; /* for MZ */
#endif
};
#endif
unsigned char simseg_init; /* simplified segm dir flags */
unsigned char simseg_defd; /* v2.09: flag if seg was defined before simseg dir */
unsigned char PhaseError; /* phase error flag */
unsigned char CommentDataInCode;/* OMF: emit coment records about data in code segs */
unsigned char prologuemode; /* current PEM_ enum value for OPTION PROLOGUE */
unsigned char epiloguemode; /* current PEM_ enum value for OPTION EPILOGUE */
unsigned char invoke_exprparm; /* flag: forward refs for INVOKE params ok? */
#if CVOSUPP
unsigned char cv_opt; /* option codeview */
#endif
unsigned srcfile; /* main source file - is an index for FNames[] */
struct dsym *currseg; /* currently active segment */
struct dsym *flat_grp; /* magic FLAT group */
uint_8 *pCodeBuff;
unsigned int GeneratedCode; /* nesting level generated code */
/* input members */
char *currsource; /* current source line */
char *CurrComment; /* current comment */
struct asm_tok *tokenarray; /* start token buffer */
char *stringbufferend;/* start free space in string buffer */
int token_count; /* number of tokens in curr line */
#if STACKBASESUPP
unsigned basereg[3]; /* stack base register (16-, 32-, 64-bit */
#endif
char name[FILENAME_MAX];/* name of module */
};
#define CurrSource ModuleInfo.currsource
#define Token_Count ModuleInfo.token_count
#define StringBufferEnd ModuleInfo.stringbufferend
#define CurrFile ModuleInfo.g.curr_file
#define CurrFName ModuleInfo.g.curr_fname
#define CurrSeg ModuleInfo.currseg
#define CurrWordSize ModuleInfo.wordsize
struct format_options {
void (*init)( struct module_info * );
short invalid_fixup_type;
const char formatname[6];
};
/* global variables */
extern struct global_options Options;
extern struct module_info ModuleInfo;
extern unsigned int Parse_Pass; /* assembly pass */
//extern unsigned int GeneratedCode; /* v2.10: moved to struct module_info */
extern uint_8 MacroLevel; /* macro nesting level */
extern bool write_to_file; /* 1=write the object module */
/* Information about source, object, listing and error files */
//extern FILE *CurrFile[]; /* ASM, ERR, OBJ and LST */
//extern char *CurrFName[]; /* ASM, ERR, OBJ and LST */
/* functions in assemble.c */
struct fixup;
extern void OutputByte( unsigned char );
//extern void OutputCodeByte( unsigned char );
extern void FillDataBytes( unsigned char, int len );
extern void OutputBytes( const unsigned char *, int len, struct fixup * );
#ifdef __SW_BD
extern int __stdcall AssembleModule( const char * );
#else
extern int AssembleModule( const char * );
#endif
extern void AddLinnumDataRef( unsigned, uint_32 );
extern void SetMasm510( bool );
extern void close_files( void );
extern char *myltoa( uint_32 value, char *buffer, unsigned radix, bool sign, bool addzero );
#if COFF_SUPPORT || PE_SUPPORT
extern char *ConvertSectionName( const struct asym *, enum seg_type *pst, char *buffer );
#endif
#endif

17
H/hll.h Normal file
View File

@ -0,0 +1,17 @@
/****************************************************************************
*
* Description: hll constructs .IF, ...
*
****************************************************************************/
#ifndef _HLL_H_
#define _HLL_H_
extern void HllInit( int ); /* reset counter for hll labels */
#if FASTMEM==0
extern void HllFini( void );
#endif
extern void HllCheckOpen( void );
#endif

97
H/input.h Normal file
View File

@ -0,0 +1,97 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: prototypes for input queueing/processing procedures
*
****************************************************************************/
#ifndef _INPUT_H_INCLUDED
#define _INPUT_H_INCLUDED
struct macro_instance {
struct srcline *currline;
struct srcline *startline;
uint_32 localstart;
char * *parm_array;
struct asym *macro;
unsigned parmcnt;
};
/* for line numbers, the source files have to be stored
* in a list in the very same order as they appear in
* the input stream.
*/
struct file_seq {
struct file_seq *next;
uint_16 file; /* index of file in FNames */
};
struct input_status {
char *token_stringbuf;
char *currsource;
char *CurrComment;
int token_count;
char line_flags;/* v2.08: added */
#ifdef __I86__
char *stringbufferend;
struct asm_tok *tokenarray;
#endif
};
extern uint_32 GetLineNumber( void );
//#define LineNumber GetLineNumber()
extern const char *GetFNamePart( const char *fname );
extern char *GetExtPart( const char *fname );
extern FILE *SearchFile( const char *path, bool );
extern char *GetTextLine( char *buffer );
extern void PushMacro( struct macro_instance * );
extern void SetLineNumber( unsigned );
#if FASTMEM==0
extern bool MacroInUse( struct dsym * );
#endif
extern void AddStringToIncludePath( const char *string );
extern void InputInit( void );
extern void InputPassInit( void );
extern void InputFini( void );
extern struct asm_tok *PushInputStatus( struct input_status * );
extern void PopInputStatus( struct input_status * );
extern int GetCurrSrcPos( char * );
extern void ClearSrcStack( void );
extern unsigned get_curr_srcfile( void );
#if FASTPASS
extern void set_curr_srcfile( unsigned, uint_32 );
#endif
extern const struct fname_item *GetFName( unsigned );
#ifdef DEBUG_OUT
extern char *GetTopLine( char * );
extern char *GetTopSrcName( void );
#endif
#define GetAlignedPointer( x, size ) ( x + ( ( size + 1 + sizeof(void *) - 1 ) & ~( sizeof(void *) - 1 ) ) )
#endif

48
H/instr64.h Normal file
View File

@ -0,0 +1,48 @@
/****************************************************************************
*
* Description: instructions which are to be replaced in long-mode
*
****************************************************************************/
/* tok (suffix) op1-3 byte1_info opnd_dir rm_info opcode rm_byte cpu prefix */
#if AMD64_SUPPORT
ins (CALL, call, OpCls( I32, NONE, NONE ), 0, 0, no_RM, 0xE8, 0x00, P_64, 0)
insn(CALL, 1, OpCls( R64_M64, NONE, NONE ), 0, 0, no_WDS, 0xFF, 0x10, P_64, 0)
//insn(CALL, 2, OpCls( M64, NONE, NONE ), 0, 0, no_WDS, 0xFF, 0x10, P_64, 0)
/* FAR call */
insm(CALL, 3, OpCls( M32, NONE, NONE ), F_16, 0, no_WDS, 0xFF, 0x18, P_64, 0)
insn(CALL, 4, OpCls( M48, NONE, NONE ), 0, 0, no_WDS, 0xFF, 0x18, P_64, 0)
insn(CALL, 5, OpCls( M80, NONE, NONE ), F_48, 0, no_WDS, 0xFF, 0x18, P_64, 0)
ins (JMP, jmp, OpCls( I8, NONE, NONE ), 0, 0, no_RM, 0xEB, 0x00, P_86, 0)
insn(JMP, 1, OpCls( I32, NONE, NONE ), 0, 0, no_RM, 0xE9, 0x00, P_64, 0)
insn(JMP, 2, OpCls( R64_M64, NONE, NONE ), 0, 0, no_WDS, 0xFF, 0x20, P_64, 0)
//insn(JMP, 3, OpCls( M64, NONE, NONE ), 0, 0, no_WDS, 0xFF, 0x20, P_64, 0)
/* FAR jmp */
insm(JMP, 4, OpCls( M32, NONE, NONE ), F_16, 0, no_WDS, 0xFF, 0x28, P_64, 0)
insn(JMP, 5, OpCls( M48, NONE, NONE ), 0, 0, no_WDS, 0xFF, 0x28, P_64, 0)
insn(JMP, 6, OpCls( M80, NONE, NONE ), F_48, 0, no_WDS, 0xFF, 0x28, P_64, 0)
ins (LGDT, lgdt, OpCls( M80, NONE, NONE ), F_0F, 0, no_WDS, 0x01, 0x10, P_64, 0)
ins (LIDT, lidt, OpCls( M80, NONE, NONE ), F_0F, 0, no_WDS, 0x01, 0x18, P_64, 0)
#if 1
ins (SLDT, sldt, OpCls( RGT8, NONE, NONE ), F_0F, 0, no_WDS, 0x00, 0x00, P_64, 0)
insn(SLDT, 1, OpCls( M16, NONE, NONE ), F_0FNO66,0, no_WDS, 0x00, 0x00, P_286, 0)
ins (SMSW, smsw, OpCls( RGT8, NONE, NONE ), F_0F, 0, no_WDS, 0x01, 0x20, P_64, 0)
insn(SMSW, 1, OpCls( M16, NONE, NONE ), F_0FNO66,0, no_WDS, 0x01, 0x20, P_286, 0)
ins (STR, str, OpCls( RGT8, NONE, NONE ), F_0F, 0, no_WDS, 0x00, 0x08, P_64, 0)
insn(STR, 1, OpCls( M16, NONE, NONE ), F_0FNO66,0, no_WDS, 0x00, 0x08, P_286, 0)
#endif
/* v2.06: POP/PUSH added */
ins (POP, pop, OpCls( R16_R64, NONE, NONE ), 0, 0, R_in_OP,0x58, 0x00, P_86, 0)
insn(POP, 1, OpCls( M16_M64, NONE, NONE ), 0, 0, 0, 0x8F, 0x00, P_86, 0)
insn(POP, 2, OpCls( SR386, NONE, NONE ), F_0F, 1, R_in_OP,0x81, 0x00, P_386, 0)
ins (PUSH, push, OpCls( R16_R64, NONE, NONE ), 0, 0, R_in_OP,0x50, 0x00, P_86, 0)
insn(PUSH, 1, OpCls( I8, NONE, NONE ), 0, 0, no_RM, 0x6A, 0x00, P_186, 0)
insn(PUSH, 2, OpCls( I, NONE, NONE ), 0, 0, no_RM, 0x68, 0x00, P_186, 0)
insn(PUSH, 3, OpCls( M16_M64, NONE, NONE ), 0, 0, 0, 0xFF, 0x30, P_86, 0)
insn(PUSH, 4, OpCls( SR386, NONE, NONE ), F_0F, 1, R_in_OP,0x80, 0x00, P_386, 0)
#if VMXSUPP /* v2.09: added */
ins (VMREAD, vmread, OpCls( R64_M64, R64, NONE ), F_0F, 0, no_WDS, 0x78, 0x00, P_686p, 0)
ins (VMWRITE, vmwrite, OpCls( R64, R64_M64, NONE ), F_0F, 1, no_WDS, 0x79, 0x00, P_686p, 0)
#endif
#endif

264
H/instravx.h Normal file
View File

@ -0,0 +1,264 @@
/****************************************************************************
*
* Description: AVX instructions with VEX prefix
*
****************************************************************************/
#if AVXSUPP
/* tok cpu */
/* format: xmm|ymm, xmm|ymm|mem */
avxins (ADDPD, vaddpd, P_AVX, VX_L ) /* L, s */
avxins (ADDPS, vaddps, P_AVX, VX_L ) /* L, s */
avxins (ADDSD, vaddsd, P_AVX, 0 ) /* -, s */
avxins (ADDSS, vaddss, P_AVX, 0 ) /* -, s */
avxins (DIVPD, vdivpd, P_AVX, VX_L ) /* L, s */
avxins (DIVPS, vdivps, P_AVX, VX_L ) /* L, s */
avxins (DIVSD, vdivsd, P_AVX, 0 ) /* -, s */
avxins (DIVSS, vdivss, P_AVX, 0 ) /* -, s */
avxins (MAXPD, vmaxpd, P_AVX, VX_L ) /* L, s */
avxins (MAXPS, vmaxps, P_AVX, VX_L ) /* L, s */
avxins (MAXSD, vmaxsd, P_AVX, 0 ) /* -, s */
avxins (MAXSS, vmaxss, P_AVX, 0 ) /* -, s */
avxins (MINPD, vminpd, P_AVX, VX_L ) /* L, s */
avxins (MINPS, vminps, P_AVX, VX_L ) /* L, s */
avxins (MINSD, vminsd, P_AVX, 0 ) /* -, s */
avxins (MINSS, vminss, P_AVX, 0 ) /* -, s */
avxins (MULPD, vmulpd, P_AVX, VX_L ) /* L, s */
avxins (MULPS, vmulps, P_AVX, VX_L ) /* L, s */
avxins (MULSD, vmulsd, P_AVX, 0 ) /* -, s */
avxins (MULSS, vmulss, P_AVX, 0 ) /* -, s */
avxins (SQRTPD, vsqrtpd, P_AVX, VX_L ) /* L, s */
avxins (SQRTPS, vsqrtps, P_AVX, VX_L ) /* L, s */
avxins (SQRTSD, vsqrtsd, P_AVX, 0 ) /* -, s */
avxins (SQRTSS, vsqrtss, P_AVX, 0 ) /* -, s */
avxins (SUBPD, vsubpd, P_AVX, VX_L ) /* L, s */
avxins (SUBPS, vsubps, P_AVX, VX_L ) /* L, s */
avxins (SUBSD, vsubsd, P_AVX, 0 ) /* -, s */
avxins (SUBSS, vsubss, P_AVX, 0 ) /* -, s */
avxins (CMPPD, vcmppd, P_AVX, VX_L ) /* L, s */
avxins (CMPPS, vcmpps, P_AVX, VX_L ) /* L, s */
avxins (CMPSD, vcmpsd, P_AVX, 0 ) /* -, s */
avxins (CMPSS, vcmpss, P_AVX, 0 ) /* -, s */
/* format: xmm|ymm, xmm|ymm|mem */
avxins (ANDPD, vandpd, P_AVX, VX_L ) /* L, s */
avxins (ANDPS, vandps, P_AVX, VX_L ) /* L, s */
avxins (ANDNPD, vandnpd, P_AVX, VX_L ) /* L, s */
avxins (ANDNPS, vandnps, P_AVX, VX_L ) /* L, s */
avxins (ORPD, vorpd, P_AVX, VX_L ) /* L, s */
avxins (ORPS, vorps, P_AVX, VX_L ) /* L, s */
avxins (COMISD, vcomisd, P_AVX, VX_NND ) /* -, ns */
avxins (COMISS, vcomiss, P_AVX, VX_NND ) /* -, ns */
avxins (XORPD, vxorpd, P_AVX, VX_L ) /* L, s */
avxins (XORPS, vxorps, P_AVX, VX_L ) /* L, s */
/* format: xmm|ymm, xmm|ymm|mem */
avxins (CVTDQ2PD, vcvtdq2pd, P_AVX, VX_L|VX_NND|VX_HALF ) /* L, ns, 64->128 */
avxins (CVTDQ2PS, vcvtdq2ps, P_AVX, VX_L|VX_NND ) /* L, ns */
//avxins (CVTPD2DQ, vcvtpd2dq, P_AVX, VX_L|VX_NND ) /* L, ns */
//avxins (CVTTPD2DQ,vcvttpd2dq, P_AVX, VX_L|VX_NND ) /* L, ns */
//avxins (CVTPD2PS, vcvtpd2ps, P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (CVTPS2DQ, vcvtps2dq, P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (CVTTPS2DQ,vcvttps2dq, P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (CVTPS2PD, vcvtps2pd, P_AVX, VX_L|VX_NND|VX_HALF ) /* L, ns, 64->128 */
avxins (CVTSD2SI, vcvtsd2si, P_AVX, VX_NND ) /* -, ns, W */
avxins (CVTTSD2SI,vcvttsd2si, P_AVX, VX_NND ) /* -, ns, W */
avxins (CVTSD2SS, vcvtsd2ss, P_AVX, 0 ) /* -, s */
avxins (CVTSI2SD, vcvtsi2sd, P_AVX, 0 ) /* -, s, W */
avxins (CVTSI2SS, vcvtsi2ss, P_AVX, 0 ) /* -, s, W */
avxins (CVTSS2SD, vcvtss2sd, P_AVX, 0 ) /* -, s */
avxins (CVTSS2SI, vcvtss2si, P_AVX, VX_NND ) /* -, ns, W */
avxins (CVTTSS2SI,vcvttss2si, P_AVX, VX_NND ) /* -, ns, W */
/* format: xmm|ymm, xmm|ymm|mem [, i8] */
avxins (ADDSUBPD, vaddsubpd, P_AVX, VX_L ) /* L, s */
avxins (ADDSUBPS, vaddsubps, P_AVX, VX_L ) /* L, s */
avxins (BLENDPD , vblendpd , P_AVX, VX_L ) /* L, s */
avxins (BLENDPS , vblendps , P_AVX, VX_L ) /* L, s */
avxins (DPPD , vdppd , P_AVX, 0 ) /* -, s */
avxins (DPPS , vdpps , P_AVX, VX_L ) /* L, s */
avxins (EXTRACTPS,vextractps, P_AVX, VX_NND ) /* -, ns! */ /* format: reg|mem32, xmm|ymm, i8 */
avxins (HADDPD , vhaddpd , P_AVX, VX_L ) /* L, s */
avxins (HADDPS , vhaddps , P_AVX, VX_L ) /* L, s */
avxins (HSUBPD , vhsubpd , P_AVX, VX_L ) /* L, s */
avxins (HSUBPS , vhsubps , P_AVX, VX_L ) /* L, s */
avxins (INSERTPS, vinsertps, P_AVX, 0 ) /* -, s */
avxins (LDDQU , vlddqu , P_AVX, VX_L|VX_NND ) /* L, ns */ /* format: xmm|ymm, mem */
avxins (LDMXCSR , vldmxcsr , P_AVX, 0 ) /* -, ns */ /* format: mem32 */
avxins (STMXCSR , vstmxcsr , P_AVX, 0 ) /* -, ns */ /* format: mem32 */
avxins (MASKMOVDQU,vmaskmovdqu, P_AVX, VX_NND ) /* -, ns */
avxins (MOVAPD , vmovapd , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVAPS , vmovaps , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVD , vmovd , P_AVX, VX_NND ) /* -, ns */
avxins (MOVQ , vmovq , P_AVX, VX_NND ) /* -, ns */
avxins (MOVDQA , vmovdqa , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVDQU , vmovdqu , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVHLPS , vmovhlps , P_AVX, 0 ) /* -, s */
avxins (MOVLHPS , vmovlhps , P_AVX, 0 ) /* -, s */
avxins (MOVHPD , vmovhpd , P_AVX, VX_NMEM ) /* -, s/ns! */
avxins (MOVHPS , vmovhps , P_AVX, VX_NMEM ) /* -, s/ns! */
avxins (MOVLPD , vmovlpd , P_AVX, VX_NMEM ) /* -, s/ns! */
avxins (MOVLPS , vmovlps , P_AVX, VX_NMEM ) /* -, s/ns! */
avxins (MOVSD , vmovsd , P_AVX, VX_NMEM ) /* -, s/ns! */ /* special case, see parser.c */
avxins (MOVSS , vmovss , P_AVX, VX_NMEM ) /* -, s/ns! */ /* special case, see parser.c */
/* v2.11: now handled in instruct.h */
//avxins (MOVMSKPD, vmovmskpd, P_AVX, VX_L|VX_NND ) /* L, ns */
//avxins (MOVMSKPS, vmovmskps, P_AVX, VX_L|VX_NND ) /* L, ns */
/* v2.11: VX_L flag added */
//avxins (MOVNTDQ , vmovntdq , P_AVX, VX_NND ) /* -, ns */
//avxins (MOVNTPD , vmovntpd , P_AVX, VX_NND ) /* -, ns */
//avxins (MOVNTPS , vmovntps , P_AVX, VX_NND ) /* -, ns */
avxins (MOVNTDQ , vmovntdq , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVNTDQA, vmovntdqa, P_AVX, VX_NND ) /* -, ns */
avxins (MOVNTPD , vmovntpd , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVNTPS , vmovntps , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVSHDUP, vmovshdup, P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVSLDUP, vmovsldup, P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVUPD , vmovupd , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MOVUPS , vmovups , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (MPSADBW , vmpsadbw , P_AVX, 0 ) /* -, s */
avxins (PABSB , vpabsb , P_AVX, VX_NND ) /* -, ns */
avxins (PABSW , vpabsw , P_AVX, VX_NND ) /* -, ns */
avxins (PABSD , vpabsd , P_AVX, VX_NND ) /* -, ns */
avxins (PACKSSWB, vpacksswb, P_AVX, 0 ) /* -, s */
avxins (PACKSSDW, vpackssdw, P_AVX, 0 ) /* -, s */
avxins (PACKUSWB, vpackuswb, P_AVX, 0 ) /* -, s */
avxins (PACKUSDW, vpackusdw, P_AVX, 0 ) /* -, s */
avxins (PADDB , vpaddb , P_AVX, 0 ) /* -, s */
avxins (PADDW , vpaddw , P_AVX, 0 ) /* -, s */
avxins (PADDD , vpaddd , P_AVX, 0 ) /* -, s */
avxins (PADDQ , vpaddq , P_AVX, 0 ) /* -, s */
avxins (PADDSB , vpaddsb , P_AVX, 0 ) /* -, s */
avxins (PADDSW , vpaddsw , P_AVX, 0 ) /* -, s */
avxins (PADDUSB , vpaddusb , P_AVX, 0 ) /* -, s */
avxins (PADDUSW , vpaddusw , P_AVX, 0 ) /* -, s */
avxins (PALIGNR , vpalignr , P_AVX, 0 ) /* -, s */
avxins (PAND , vpand , P_AVX, 0 ) /* -, s */
avxins (PANDN , vpandn , P_AVX, 0 ) /* -, s */
avxins (PAVGB , vpavgb , P_AVX, 0 ) /* -, s */
avxins (PAVGW , vpavgw , P_AVX, 0 ) /* -, s */
avxins (PBLENDW , vpblendw , P_AVX, 0 ) /* -, s */
avxins (PCMPESTRI,vpcmpestri, P_AVX, VX_NND ) /* -, ns! */
avxins (PCMPESTRM,vpcmpestrm, P_AVX, VX_NND ) /* -, ns! */
avxins (PCMPISTRI,vpcmpistri, P_AVX, VX_NND ) /* -, ns! */
avxins (PCMPISTRM,vpcmpistrm, P_AVX, VX_NND ) /* -, ns! */
avxins (PCMPEQB ,vpcmpeqb , P_AVX, 0 ) /* -, s */
avxins (PCMPEQW ,vpcmpeqw , P_AVX, 0 ) /* -, s */
avxins (PCMPEQD ,vpcmpeqd , P_AVX, 0 ) /* -, s */
avxins (PCMPEQQ ,vpcmpeqq , P_AVX, 0 ) /* -, s */
avxins (PCMPGTB ,vpcmpgtB , P_AVX, 0 ) /* -, s */
avxins (PCMPGTW ,vpcmpgtw , P_AVX, 0 ) /* -, s */
avxins (PCMPGTD ,vpcmpgtd , P_AVX, 0 ) /* -, s */
avxins (PCMPGTQ ,vpcmpgtq , P_AVX, 0 ) /* -, s */
avxins (PEXTRB ,vpextrb , P_AVX, VX_NND ) /* -, ns! */
avxins (PEXTRW ,vpextrw , P_AVX, VX_NND ) /* -, ns! */
avxins (PEXTRD ,vpextrd , P_AVX, VX_NND ) /* -, ns! */
avxins (PINSRB ,vpinsrb , P_AVX, 0 ) /* -, s */
avxins (PINSRW ,vpinsrw , P_AVX, 0 ) /* -, s */
avxins (PINSRD ,vpinsrd , P_AVX, 0 ) /* -, s */
#if AMD64_SUPPORT
avxins (PEXTRQ ,vpextrq , P_AVX, VX_NND ) /* -, ns! */
avxins (PINSRQ ,vpinsrq , P_AVX, 0 ) /* -, s */
#endif
avxins (PHADDW ,vphaddw , P_AVX, 0 ) /* -, s */
avxins (PHADDD ,vphaddd , P_AVX, 0 ) /* -, s */
avxins (PHADDSW ,vphaddsw , P_AVX, 0 ) /* -, s */
avxins (PHMINPOSUW,vphminposuw, P_AVX, VX_NND ) /* -, ns */
avxins (PHSUBW ,vphsubw , P_AVX, 0 ) /* -, s */
avxins (PHSUBD ,vphsubd , P_AVX, 0 ) /* -, s */
avxins (PHSUBSW ,vphsubsw , P_AVX, 0 ) /* -, s */
avxins (PMADDWD ,vpmaddwd , P_AVX, 0 ) /* -, s */
avxins (PMADDUBSW,vpmaddubsw, P_AVX, 0 ) /* -, s */
avxins (PMAXSB ,vpmaxsb , P_AVX, 0 ) /* -, s */
avxins (PMAXSW ,vpmaxsw , P_AVX, 0 ) /* -, s */
avxins (PMAXSD ,vpmaxsd , P_AVX, 0 ) /* -, s */
avxins (PMAXUB ,vpmaxub , P_AVX, 0 ) /* -, s */
avxins (PMAXUW ,vpmaxuw , P_AVX, 0 ) /* -, s */
avxins (PMAXUD ,vpmaxud , P_AVX, 0 ) /* -, s */
avxins (PMINSB ,vpminsb , P_AVX, 0 ) /* -, s */
avxins (PMINSW ,vpminsw , P_AVX, 0 ) /* -, s */
avxins (PMINSD ,vpminsd , P_AVX, 0 ) /* -, s */
avxins (PMINUB ,vpminub , P_AVX, 0 ) /* -, s */
avxins (PMINUW ,vpminuw , P_AVX, 0 ) /* -, s */
avxins (PMINUD ,vpminud , P_AVX, 0 ) /* -, s */
avxins (PMOVMSKB ,vpmovmskb , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVSXBW ,vpmovsxbw , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVSXBD ,vpmovsxbd , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVSXBQ ,vpmovsxbq , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVSXWD ,vpmovsxwd , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVSXWQ ,vpmovsxwq , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVSXDQ ,vpmovsxdq , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVZXBW ,vpmovzxbw , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVZXBD ,vpmovzxbd , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVZXBQ ,vpmovzxbq , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVZXWD ,vpmovzxwd , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVZXWQ ,vpmovzxwq , P_AVX, VX_NND ) /* -, ns */
avxins (PMOVZXDQ ,vpmovzxdq , P_AVX, VX_NND ) /* -, ns */
avxins (PMULHUW ,vpmulhuw , P_AVX, 0 ) /* -, s */
avxins (PMULHRSW ,vpmulhrsw , P_AVX, 0 ) /* -, s */
avxins (PMULHW ,vpmulhw , P_AVX, 0 ) /* -, s */
avxins (PMULLW ,vpmullw , P_AVX, 0 ) /* -, s */
avxins (PMULLD ,vpmulld , P_AVX, 0 ) /* -, s */
avxins (PMULUDQ ,vpmuludq , P_AVX, 0 ) /* -, s */
avxins (PMULDQ ,vpmuldq , P_AVX, 0 ) /* -, s */
avxins (POR ,vpor , P_AVX, 0 ) /* -, s */
avxins (PSADBW ,vpsadbw , P_AVX, 0 ) /* -, s */
avxins (PSHUFB ,vpshufb , P_AVX, 0 ) /* -, s */
avxins (PSHUFD ,vpshufd , P_AVX, VX_NND ) /* -, ns! */
avxins (PSHUFHW ,vpshufhw , P_AVX, VX_NND ) /* -, ns! */
avxins (PSHUFLW ,vpshuflw , P_AVX, VX_NND ) /* -, ns! */
avxins (PSIGNB ,vpsignb , P_AVX, 0 ) /* -, s */
avxins (PSIGNW ,vpsignw , P_AVX, 0 ) /* -, s */
avxins (PSIGND ,vpsignd , P_AVX, 0 ) /* -, s */
avxins (PSLLDQ ,vpslldq , P_AVX, VX_DST ) /* -, d */
avxins (PSRLDQ ,vpsrldq , P_AVX, VX_DST ) /* -, d */
avxins (PSLLW ,vpsllw , P_AVX, VX_DST ) /* -, d/s */
avxins (PSLLD ,vpslld , P_AVX, VX_DST ) /* -, d/s */
avxins (PSLLQ ,vpsllq , P_AVX, VX_DST ) /* -, d/s */
avxins (PSRAW ,vpsraw , P_AVX, VX_DST ) /* -, d/s */
avxins (PSRAD ,vpsrad , P_AVX, VX_DST ) /* -, d/s */
avxins (PSRLW ,vpsrlw , P_AVX, VX_DST ) /* -, d/s */
avxins (PSRLD ,vpsrld , P_AVX, VX_DST ) /* -, d/s */
avxins (PSRLQ ,vpsrlq , P_AVX, VX_DST ) /* -, d/s */
/* */
avxins (PTEST ,vptest , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (PSUBB ,vpsubb , P_AVX, 0 ) /* -, s */
avxins (PSUBW ,vpsubw , P_AVX, 0 ) /* -, s */
avxins (PSUBD ,vpsubd , P_AVX, 0 ) /* -, s */
avxins (PSUBQ ,vpsubq , P_AVX, 0 ) /* -, s */
avxins (PSUBSB ,vpsubsb , P_AVX, 0 ) /* -, s */
avxins (PSUBSW ,vpsubsw , P_AVX, 0 ) /* -, s */
avxins (PSUBUSB ,vpsubusb , P_AVX, 0 ) /* -, s */
avxins (PSUBUSW ,vpsubusw , P_AVX, 0 ) /* -, s */
avxins (PUNPCKHBW ,vpunpckhbw, P_AVX, 0 ) /* -, s */
avxins (PUNPCKHWD ,vpunpckhwd, P_AVX, 0 ) /* -, s */
avxins (PUNPCKHDQ ,vpunpckhdq, P_AVX, 0 ) /* -, s */
avxins (PUNPCKHQDQ,vpunpckhqdq, P_AVX, 0 ) /* -, s */
avxins (PUNPCKLBW ,vpunpcklbw, P_AVX, 0 ) /* -, s */
avxins (PUNPCKLWD ,vpunpcklwd, P_AVX, 0 ) /* -, s */
avxins (PUNPCKLDQ ,vpunpckldq, P_AVX, 0 ) /* -, s */
avxins (PUNPCKLQDQ,vpunpcklqdq, P_AVX, 0 ) /* -, s */
avxins (PXOR ,vpxor , P_AVX, 0 ) /* -, s */
avxins (RCPPS ,vrcpps , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (RCPSS ,vrcpss , P_AVX, 0 ) /* -, s */
avxins (RSQRTPS ,vrsqrtps , P_AVX, VX_L|VX_NND ) /* L, ns */
avxins (RSQRTSS ,vrsqrtss , P_AVX, 0 ) /* -, s */
avxins (ROUNDPD ,vroundpd , P_AVX, VX_L|VX_NND ) /* L, ns! */
avxins (ROUNDPS ,vroundps , P_AVX, VX_L|VX_NND ) /* L, ns! */
avxins (ROUNDSD ,vroundsd , P_AVX, 0 ) /* -, s */
avxins (ROUNDSS ,vroundss , P_AVX, 0 ) /* -, s */
avxins (SHUFPD ,vshufpd , P_AVX, VX_L ) /* L, s */
avxins (SHUFPS ,vshufps , P_AVX, VX_L ) /* L, s */
avxins (UCOMISD ,vucomisd , P_AVX, VX_NND ) /* -, ns */
avxins (UCOMISS ,vucomiss , P_AVX, VX_NND ) /* -, ns */
avxins (UNPCKHPD ,vunpckhpd , P_AVX, VX_L ) /* L, s */
avxins (UNPCKHPS ,vunpckhps , P_AVX, VX_L ) /* L, s */
avxins (UNPCKLPD ,vunpcklpd , P_AVX, VX_L ) /* L, s */
avxins (UNPCKLPS ,vunpcklps , P_AVX, VX_L ) /* L, s */
#endif
//avxins (PCLMULQDQ,vpclmulqdq, P_AVX, 0 )

1312
H/instruct.h Normal file

File diff suppressed because it is too large Load Diff

86
H/inttype.h Normal file
View File

@ -0,0 +1,86 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: uint and int type declarations.
* This file is included by globals.h
*
****************************************************************************/
#ifndef _INTTYPE_H_INCLUDED_
#define _INTTYPE_H_INCLUDED_
/* v2.12: 'uint' removed ( replaced by 'unsigned') */
//typedef unsigned uint;
/* assumptions:
* - [unsigned] char is 8-bit
* - [unsigned] short is 16-bit
* - [unsigned] int is either 16- or 32-bit
* - [unsigned] long is either 32- or 64-bit
*/
typedef unsigned char uint_8;
typedef signed char int_8;
typedef unsigned short uint_16;
typedef signed short int_16;
#if defined(LONG_IS_64BITS) || defined(__LP64__)
typedef unsigned int uint_32;
typedef signed int int_32;
typedef unsigned long uint_64;
typedef signed long int_64;
#else
typedef unsigned long uint_32;
typedef signed long int_32;
#if defined(LLONG_MAX) || defined(__GNUC__)
typedef unsigned long long uint_64;
typedef signed long long int_64;
#else
typedef unsigned __int64 uint_64;
#ifdef __OCC__
typedef __int64 int_64;
#else
typedef signed __int64 int_64;
#endif
#endif
#endif
/* 32-bit integer format specifier */
#ifdef __I86__
#define I32_SPEC "l"
#else
#define I32_SPEC ""
#endif
/* 64-bit integer format specifier */
#if defined(LONG_IS_64BITS) || defined(__LP64__)
#define I64_SPEC "l"
#elif defined(__UNIX__) || defined(__CYGWIN__) || defined(__DJGPP__)
#define I64_SPEC "ll"
#else
#define I64_SPEC "I64"
#endif
#endif

13
H/jwasm.rc Normal file
View File

@ -0,0 +1,13 @@
// This file usually isn't used. See USERESOURCES in msgtext.c for details.
#include "globals.h"
STRINGTABLE
BEGIN
#undef pick
#define pick( code, text ) code, text
#include "msgdef.h"
END

40
H/label.h Normal file
View File

@ -0,0 +1,40 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: label routines prototypes
*
****************************************************************************/
#ifndef _LABEL_H_
#define _LABEL_H_
struct qualified_type;
extern void LabelInit( void );
extern char *GetAnonymousLabel( char *, int );
extern struct asym *CreateLabel( const char *, enum memtype, struct qualified_type *, bool );
#endif

24
H/linnum.h Normal file
View File

@ -0,0 +1,24 @@
/* internal line number information used if -Zd or -Zi is set */
struct line_num_info {
struct line_num_info *next;
uint_32 number; /* source line number (v2.06: changed to 32-bit */
union {
uint_32 offset;
/* the next struct is set if sym is != NULL ( COFF only ) */
struct {
uint_32 line_number:20,
file:12;
};
};
union {
unsigned srcfile;
struct asym *sym; /* used if number is 0 ( COFF only ) */
};
};
void LinnumInit( void );
void LinnumFini( void );
void QueueDeleteLinnum( struct qdesc * );

33
H/listing.h Normal file
View File

@ -0,0 +1,33 @@
/****************************************************************************
*
* Description: listing interface.
*
****************************************************************************/
#ifndef _LISTING_H_INCLUDED
#define _LISTING_H_INCLUDED
enum lsttype {
LSTTYPE_DATA,
LSTTYPE_CODE,
LSTTYPE_EQUATE,
LSTTYPE_TMACRO,
LSTTYPE_DIRECTIVE,
LSTTYPE_MACRO,
LSTTYPE_STRUCT,
LSTTYPE_LABEL,
LSTTYPE_MACROLINE,
};
extern void LstInit( void );
extern void LstWrite( enum lsttype, uint_32 ofs, void * sym );
extern void LstWriteSrcLine( void );
extern void LstWriteCRef( void );
extern void LstPrintf( const char *format, ... );
extern void LstNL( void );
#if FASTPASS
extern void LstSetPosition( void );
#endif
#endif

15
H/lqueue.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef _LQUEUE_H_INCLUDED
#define _LQUEUE_H_INCLUDED
/* v2.11: line queue functions moved from input.c to lqueue.c */
extern void DeleteLineQueue( void );
extern void AddLineQueue( const char *line );
extern void AddLineQueueX( const char *fmt, ... );
extern void RunLineQueue( void );
//v2.11: replaced by macro
//extern bool is_linequeue_populated( void );
#define is_linequeue_populated() ModuleInfo.g.line_queue.head
#endif

78
H/ltext.h Normal file
View File

@ -0,0 +1,78 @@
/* text constants for listing */
ltext(BYTE, "Byte" )
ltext(WORD, "Word" )
ltext(DWORD, "DWord" )
ltext(FWORD, "FWord" )
ltext(QWORD, "QWord" )
ltext(TBYTE, "TByte" )
ltext(PARA, "Para" )
ltext(OWORD, "XmmWord")
ltext(PAGE, "Page" )
/* [L]NEAR|FAR[16|32|64] variants must be consecutive */
ltext(NEAR, "Near" )
ltext(NEAR16, "Near16" )
ltext(NEAR32, "Near32" )
#if AMD64_SUPPORT
ltext(NEAR64, "Near64" )
#endif
ltext(FAR, "Far" )
ltext(FAR16, "Far16" )
ltext(FAR32, "Far32" )
#if AMD64_SUPPORT
ltext(FAR64, "Far64" )
#endif
ltext(LNEAR, "L Near" )
ltext(LNEAR16, "L Near16")
ltext(LNEAR32, "L Near32")
#if AMD64_SUPPORT
ltext(LNEAR64, "L Near64")
#endif
ltext(LFAR, "L Far" )
ltext(LFAR16, "L Far16" )
ltext(LFAR32, "L Far32" )
#if AMD64_SUPPORT
ltext(LFAR64, "L Far64" )
#endif
ltext(PTR, "Ptr" )
ltext(PROC, "Proc" )
ltext(FUNC, "Func" )
ltext(NUMBER, "Number" )
ltext(PRIVATE, "Private")
ltext(STACK, "Stack" )
ltext(PUBLIC, "Public" )
ltext(COMMON, "Common" )
ltext(EXTERNAL, "External" )
ltext(UNDEFINED,"Undefined")
ltext(GROUP, "GROUP" )
ltext(NOSEG, "No Seg" )
ltext(TEXT, "Text" )
ltext(ALIAS, "Alias" )
ltext(ABS, "Abs" )
ltext(COMM, "COMM" )
ltext(VARARG, "VARARG" )
/* language order must match enum lang_type in globals.h */
ltext(VOID, "" )
ltext(C, "C" )
ltext(SYSCALL, "SYSCALL")
ltext(STDCALL, "STDCALL")
ltext(PASCAL, "PASCAL" )
ltext(FORTRAN, "FORTRAN")
ltext(BASIC, "BASIC" )
ltext(FASTCALL, "FASTCALL")
ltext( TXT_MACROS, "Macros:" )
ltext( TXT_MACROCAP, " N a m e Type" )
ltext( TXT_STRUCTS, "Structures and Unions:" )
ltext( TXT_STRUCTCAP, " N a m e Size/Ofs Type" )
ltext( TXT_RECORDS, "Records:" )
ltext( TXT_RECORDCAP, " N a m e Width # fields\n" " Shift Width Mask Initial" )
ltext( TXT_TYPEDEFS, "Types:" )
ltext( TXT_TYPEDEFCAP, " N a m e Size Attr" )
ltext( TXT_SEGS, "Segments and Groups:" )
ltext( TXT_SEGCAP, " N a m e Size Length Align Combine Class" )
ltext( TXT_PROCS, "Procedures, parameters and locals:" )
ltext( TXT_PROCCAP, " N a m e Type Value Segment Length" )
ltext( TXT_SYMBOLS, "Symbols:" )
ltext( TXT_SYMCAP, " N a m e Type Value Attr")

76
H/macro.h Normal file
View File

@ -0,0 +1,76 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: prototypes for macro stuff
*
****************************************************************************/
#ifndef _MACRO_H_
#define _MACRO_H_
#define PLACEHOLDER_CHAR '\n' /* "escape" char for macro placeholders */
enum macro_flags {
#if MACROLABEL
MF_LABEL = 0x01, /* a label exists at pos 0 */
#endif
MF_NOSAVE = 0x02, /* no need to save/restore input status */
MF_IGNARGS = 0x04 /* ignore additional arguments (for FOR directive) */
};
/* functions in expans.c */
extern int GetLiteralValue( char *, const char * );
extern int RunMacro( struct dsym *, int, struct asm_tok[], char *, int, bool * );
extern ret_code ExpandText( char *, struct asm_tok[], unsigned int );
extern int ExpandLineItems( char *, int, struct asm_tok[], int, int );
extern ret_code ExpandLine( char *, struct asm_tok[] );
extern void ExpandLiterals( int i, struct asm_tok[] );
/* functions in macro.c */
extern struct dsym *CreateMacro( const char * );/* create a macro symbol */
extern void ReleaseMacroData( struct dsym * );
extern void fill_placeholders( char *, const char *, unsigned, unsigned, char * * );
extern void SkipCurrentQueue( struct asm_tok[] );
extern ret_code StoreMacro( struct dsym *, int, struct asm_tok[], bool ); /* store macro content */
extern ret_code MacroInit( int );
#ifdef DEBUG_OUT
extern void MacroFini( void );
#endif
/* functions in string.c */
extern struct asym *SetTextMacro( struct asm_tok[], struct asym *, const char *, const char * ); /* EQU for texts */
extern struct asym *AddPredefinedText( const char *, const char * );
extern int TextItemError( struct asm_tok * );
extern void StringInit( void );
#ifdef DEBUG_OUT
extern void StringFini( void );
#endif
#endif

37
H/mangle.h Normal file
View File

@ -0,0 +1,37 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Declaration for mangler routines (=name decoration)
*
****************************************************************************/
#ifndef _MANGLE_H_
#define _MANGLE_H_
extern int Mangle( struct asym *, char * );
extern void SetMangler( struct asym *, int, const char * );
#endif

74
H/memalloc.h Normal file
View File

@ -0,0 +1,74 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Memory allocation prototypes.
*
****************************************************************************/
#ifndef _MEMALLOC_H_
#define _MEMALLOC_H_
extern void MemInit( void );
extern void MemFini( void );
extern void *MemAlloc( size_t size );
extern void *MemRealloc( void *ptr, size_t size );
extern void MemFree( void *ptr );
#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__OCC__)
#define myalloca alloca
#include <malloc.h>
#elif defined(__GNUC__) || defined(__TINYC__)
#define myalloca alloca
#ifndef __FreeBSD__ /* added v2.08 */
#include <malloc.h> /* added v2.07 */
#endif
#elif defined(__PCC__)
#define myalloca _alloca
#include <malloc.h>
#else
#define myalloca _alloca
#endif
/* LclAlloc() and LclFree() are fast variants, which
* are to be used for all allocations which aren't "global"
*/
extern void *LclAlloc( size_t );
#if FASTMEM
/* be careful not to use a function call as argument for LclFree()! */
#define LclFree( p ) ;
#else
extern void LclFree( void * );
#endif
#endif

358
H/msgdef.h Normal file
View File

@ -0,0 +1,358 @@
/* message texts.
* since msg numbers shouldn't change, new ids must be added at the end -
* unless a free entry is reused (search for "_unused"!)
* This file is included by globals.h.
* v2.06: Japanese texts removed.
* v2.07: listing texts moved to ltext.h
*/
pick( MSG_USAGE, "usage: JWasm [ options ] filelist [@env_var]\n" "Run \"JWasm -?\" or \"JWasm -h\" for more info\n" )
pick( MSG_ASSEMBLY_RESULTS, "%s: %lu lines, %u passes, %u ms, %u warnings, %u errors" )
pick( MSG_JWASM, "JWasm v" _JWASM_VERSION_ ", " __DATE__ )
pick( MSG_JWASM2, "Masm-compatible assembler.\n" "Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.\n" "Source code is available under the Sybase Open Watcom Public License.\n" )
pick( MSG_ERROR_PREFIX, "Error" )
pick( MSG_WARNING_PREFIX, "Warning" )
pick( MSG_FATAL_PREFIX, "Fatal error" )
/* segment attribute text constants for error SEGDEF_CHANGED */
pick( TXT_READONLY, "readonly" )
pick( TXT_ALIGNMENT, "alignment" )
pick( TXT_COMBINE, "combine" )
pick( TXT_SEG_WORD_SIZE, "segment word size" )
pick( TXT_CLASS, "class" )
pick( TXT_CHARACTERISTICS, "characteristics" )
pick( TXT_ALIASNAME, "alias" ) /* v2.10: added */
/* error/warning message text constants */
pick( msg_unused2, "" )
pick( msg_unused3, "" )
pick( msg_unused4, "" )
pick( msg_unused5, "" )
pick( msg_unused6, "" )
pick( msg_unused7, "" )
pick( msg_unused8, "" )
pick( msg_unused9, "" )
pick( msg_unused10, "" )
pick( msg_unused11, "" )
#if COMDATSUPP
pick( VALUE_NOT_WITHIN_ALLOWED_RANGE, "Value not within allowed range %s" )
pick( INVALID_ASSOCIATED_SEGMENT, "Invalid associated segment: %s" )
#else
pick( msg_filler20, "" )
pick( msg_filler21, "" )
#endif
#if MANGLERSUPP
pick( UNKNOWN_MANGLER, "Unknown symbol class '%s'" )
pick( CONFLICTING_MANGLER, "Symbol class for '%s' already established" )
#else
pick( msg_filler16, "" )
pick( msg_filler17, "" )
#endif
pick( INSTRUCTION_PREFIX_NOT_ALLOWED, "Instruction prefix not allowed" )
pick( MULTIPLE_BASE_REGISTERS_NOT_ALLOWED, "Multiple base registers not allowed" )
pick( INSTRUCTION_OR_REGISTER_NOT_ACCEPTED_IN_CURRENT_CPU_MODE, "Instruction or register not accepted in current CPU mode" )
pick( INVALID_ADDRESSING_MODE_WITH_CURRENT_CPU_SETTING, "invalid addressing mode with current CPU setting" )
pick( CANNOT_USE_TRN_TO_TRM_WITH_CURRENT_CPU_SETTING, "Cannot use TR%u-TR%u with current CPU setting" )
pick( MUST_BE_INDEX_OR_BASE_REGISTER, "Must be index or base register" )
pick( MULTIPLE_INDEX_REGISTERS_NOT_ALLOWED, "Multiple index registers not allowed" )
pick( TOO_FEW_BITS_IN_RECORD, "Too few bits in RECORD: %s" )
pick( SCALE_FACTOR_MUST_BE_1_2_4_OR_8, "Scale factor must be 1, 2, 4 or 8" )
pick( CANNOT_BE_USED_AS_INDEX_REGISTER, "Cannot be used as index register: %s" )
#if AMD64_SUPPORT
pick( CANNOT_MIX_16_AND_32_BIT_REGISTERS, "Base and index register differ in size" )
#else
pick( CANNOT_MIX_16_AND_32_BIT_REGISTERS, "Cannot mix 16 and 32-bit registers" )
#endif
pick( EXPECTING_COMMA, "Expecting comma: %s" )
pick( ORG_NEEDS_A_CONSTANT_OR_LOCAL_OFFSET, "ORG needs a constant or local offset" )
pick( POP_CS_IS_NOT_ALLOWED, "POP CS is not allowed" )
pick( ONLY_MOV_CAN_USE_SPECIAL_REGISTER, "Only MOV can use special register" )
pick( CANNOT_USE_SHORT_WITH_CALL, "Cannot use SHORT with CALL" )
pick( ONLY_SHORT_JUMP_DISTANCE_IS_ALLOWED, "Only SHORT jump distance is allowed" )
pick( SYNTAX_ERROR, "Syntax error" )
pick( PREFIX_MUST_BE_FOLLOWED_BY_AN_INSTRUCTION, "Prefix must be followed by an instruction" )
pick( SYNTAX_ERROR_UNEXPECTED_COLON, "Syntax error: Unexpected colon" )
pick( OPERANDS_MUST_BE_THE_SAME_SIZE, "Operands must be the same size: %u - %u" )
pick( INVALID_INSTRUCTION_OPERANDS, "Invalid instruction operands" )
pick( JUMP_DISTANCE_NOT_POSSIBLE, "Jump distance not possible in current CPU mode" )
pick( IMMEDIATE_DATA_OUT_OF_RANGE, "Immediate data out of range" )
pick( CANNOT_USE_SHORT_OR_NEAR, "Can not use short or near modifiers with this instruction" )
pick( JUMP_OUT_OF_RANGE, "Jump out of range by %d byte(s)" )
pick( DISPLACEMENT_OUT_OF_RANGE, "Displacement out of range: 0x%" I64_SPEC "X" )
pick( INITIALIZER_OUT_OF_RANGE, "Initializer value too large" )
pick( SYMBOL_ALREADY_DEFINED, "Symbol already defined: %s" )
pick( OFFSET_MAGNITUDE_TOO_LARGE, "Offset magnitude too large for specified size" )
pick( MAGNITUDE_OF_OFFSET_EXCEEDS_16BIT, "Magnitude of offset exceeds 16 bit" )
pick( OP2_TOO_BIG, "Operand 2 too big" )
pick( OP1_TOO_SMALL, "Operand 1 too small" )
pick( LINE_TOO_LONG, "Line too long" )
pick( TOO_MANY_TOKENS, "Too many tokens in a line" )
pick( MEMBER_NOT_DEFINED, "Symbol not defined : %s.%s" )
pick( EXPRESSION_EXPECTED, "Expression expected: %s" )
pick( CONSTANT_EXPECTED, "Constant expected" )
pick( CONSTANT_OPERAND_EXPECTED, "Constant operand is expected" )
pick( DOT_ELSE_CLAUSE_ALREADY_OCCURED_IN_THIS_DOT_IF_BLOCK, ".ELSE clause already occured in this .IF block" )
pick( MULTIPLE_OVERRIDES, "Multiple overrides" )
pick( SEGMENT_GROUP_OR_SEGREG_EXPECTED, "Segment, group or segment register expected" )
pick( IDENTIFIER_TOO_LONG, "Identifier too long" )
pick( INVALID_OPERAND_SIZE, "Invalid operand size for instruction" )
pick( NOT_SUPPORTED, "Not supported: %s" )
pick( SIZE_NOT_SPECIFIED_ASSUMING, "Size not specified, assuming: %s" )
pick( FP_INITIALIZER_IGNORED, "Floating-point initializer ignored" )
pick( ONLY_SHORT_AND_NEAR_JUMP_DISTANCE_IS_ALLOWED, "Only SHORT and NEAR jump distance is allowed" )
pick( MAGNITUDE_TOO_LARGE_FOR_SPECIFIED_SIZE, "Initializer magnitude too large for specified size" )
pick( SEGMENT_ATTRIBUTE_DEFINED_ALREADY, "Segment attribute is defined already: %s" )
pick( SEGDEF_CHANGED, "Segment definition changed: %s, %s" )
pick( CLASS_NAME_TOO_LONG, "Class name too long" )
pick( BLOCK_NESTING_ERROR, "Block nesting error: %s" )
pick( UNKNOWN_SEGMENT_ATTRIBUTE, "Segment attribute is unknown: %s" )
pick( MUST_BE_IN_SEGMENT_BLOCK, "Must be in segment block" )
pick( SEGMENT_NOT_DEFINED, "Segment not defined: %s" )
pick( COLON_EXPECTED, "Colon is expected" )
pick( INVALID_QUALIFIED_TYPE, "Invalid qualified type: %s" )
pick( QUALIFIED_TYPE_EXPECTED, "Qualified type is expected" )
pick( MISSING_MACRO_ARGUMENT_2, "Missing macro argument: iteration %u" )
pick( LIBRARY_NAME_MISSING, "Library name is missing" )
pick( CANNOT_ACCESS_LABEL_THROUGH_SEGMENT_REGISTERS, "Cannot access label through segment registers: %s" )
pick( EXPANDED_LINE_TOO_LONG, "Line too long after expansion: %40s" )
pick( LANG_MUST_BE_SPECIFIED, "Language type must be specified" )
pick( PROC_MACRO_MUST_PRECEDE_LOCAL, "PROC, MACRO or macro loop directive must precede LOCAL" )
pick( CANNOT_NEST_PROCEDURES, "Cannot nest procedures" )
pick( VARARG_REQUIRES_C_CALLING_CONVENTION, "VARARG requires C calling convention" )
pick( MODEL_DECLARED_ALREADY, "Multiple .MODEL directives, .MODEL ignored" )
pick( MODEL_IS_NOT_DECLARED, "Model is not declared" )
pick( BACKQUOTE_MISSING, "Backquote missing: `%s" )
pick( COMMENT_DELIMITER_EXPECTED, "COMMENT delimiter expected" )
pick( END_DIRECTIVE_REQUIRED, "END directive required at end of file" )
pick( NESTING_LEVEL_TOO_DEEP, "Nesting level too deep" )
pick( MACRO_NESTING_LEVEL_TOO_DEEP,"Macro nesting level too deep" )
pick( SYMBOL_NOT_DEFINED, "Symbol not defined : %s" )
pick( LANGUAGE_ATTRIBUTE_CONFLICT, "Language attribute conflict: %s" )
pick( NO_FILENAME_SPECIFIED, "No filename specified." )
pick( OUT_OF_MEMORY, "Out of Memory" )
pick( CANNOT_OPEN_FILE, "Cannot open file: \"%s\" [%s]" )
pick( CANNOT_CLOSE_FILE, "Cannot close file: %s [%u]" )
pick( FILE_WRITE_ERROR, "File write error: %s [%u]" )
pick( INVALID_CMDLINE_OPTION, "Invalid command-line option: %s" )
pick( INTERNAL_ERROR, "Internal error in %s(%u)\n" ) /* terminating LF is intended */
pick( EXPECTED_CL_SQ_BRACKET, "Expecting closing square bracket" )
pick( EXPECTED_FILE_NAME, "Expecting file name" )
pick( TOO_MANY_ERRORS, "Too many errors" )
pick( FORCED_ERR, "forced error%s" )
pick( FORCED_NOT_ZERO, "forced error: Value not equal to 0: %d%s" )
pick( FORCED_EQUAL, "forced error: Value equal to 0: %d%s" )
pick( FORCED_DEF, "forced error: symbol defined: %s" )
pick( FORCED_NOT_DEF, "forced error: symbol not defined: %s" )
pick( FORCED_BLANK, "forced error: string blank : <%s>%s" )
pick( FORCED_NOT_BLANK, "forced error: string not blank : <%s>%s" )
pick( FORCED_DIF, "forced error: strings not equal : <%s> : <%s>%s" )
pick( FORCED_IDN, "forced error: strings equal : <%s> : <%s>%s" )
pick( NOTE_INCLUDED_BY, "%*s%s(%" I32_SPEC "u): Included by" )
pick( NOTE_MACRO_CALLED_FROM, "%*s%s(%" I32_SPEC "u)[%s]: Macro called from" )
pick( NOTE_ITERATION_MACRO_CALLED_FROM, "%*s%s(%" I32_SPEC "u): iteration %" I32_SPEC "u: Macro called from" )
pick( NOTE_MAIN_LINE_CODE, "%*s%s(%" I32_SPEC "u): Main line code" )
pick( EXTENDING_JUMP, "Extending jump" )
pick( DIRECTIVE_IGNORED, "Directive ignored: %s" )
pick( POWER_OF_2, "number must be a power of 2: %" I32_SPEC "u" )
pick( ALIGN_TOO_HIGH, "Incompatible with segment alignment: %s" )
pick( SEGMENT_EXPECTED, "Segment expected: %s" )
pick( INCOMPATIBLE_CPU_MODE_FOR_XXBIT_SEGMENT, "Incompatible CPU mode for %u-bit segment" )
pick( CALL_FAR_TO_NEAR, "Far call is converted to near call." )
pick( CPU_OPTION_INVALID, "CPU option %s is not valid for selected CPU." )
pick( SEGMENT_IN_ANOTHER_GROUP, "Segment '%s' is in another group already" )
pick( SYMBOL_TYPE_CONFLICT, "Symbol type conflict: %s" )
pick( CONFLICTING_PARAMETER_DEFINITION, "Conflicting parameter definition: %s" )
pick( PROC_AND_PROTO_CALLING_CONV_CONFLICT, "PROC and PROTO calling convention conflict" )
pick( NON_BENIGN_XXX_REDEFINITION, "Non-benign %s redefinition: %s" )
pick( TOO_MANY_BITS_IN_RECORD, "Too many bits in RECORD: %s" )
pick( STATEMENT_NOT_ALLOWED_INSIDE_STRUCTURE_DEFINITION, "Statement not allowed inside structure definition" )
pick( UNMATCHED_BLOCK_NESTING, "Unmatched block nesting: %s" )
pick( SYMBOL_REDEFINITION, "Symbol redefinition: %s" )
pick( TEXT_ITEM_REQUIRED, "Text item required" )
pick( INVOKE_ARGUMENT_TYPE_MISMATCH, "INVOKE argument type mismatch: argument %u" )
pick( TOO_FEW_ARGUMENTS_TO_INVOKE, "Too few arguments to INVOKE: %s" )
pick( VARARG_PARAMETER_MUST_BE_LAST, "VARARG parameter must be last" )
#if MACROLABEL
pick( LABEL_PARAMETER_MUST_BE_FIRST, "LABEL parameter must be first" )
#else
pick( msg_filler1, "" )
#endif
pick( TOO_MANY_ARGUMENTS_IN_MACRO_CALL, "Too many arguments in macro call: %s: %s" )
pick( MISSING_OPERATOR_IN_EXPRESSION, "Missing operator in expression" )
pick( UNEXPECTED_LITERAL_FOUND_IN_EXPRESSION, "Unexpected literal found in expression: %s" )
pick( INITIALIZER_MUST_BE_A_STRING_OR_SINGLE_ITEM, "Initializer must be a string or single item: %s" )
pick( TOO_MANY_INITIAL_VALUES_FOR_STRUCTURE, "Too many initial values for structure: %s" )
pick( TOO_MANY_INITIAL_VALUES_FOR_ARRAY, "Too many initial values for array: %s" )
pick( STRING_OR_TEXT_LITERAL_TOO_LONG, "String or text literal too long" )
pick( PROLOGUE_MUST_BE_MACRO_FUNC, "PROLOGUE must be macro function" )
pick( EPILOGUE_MUST_BE_MACRO_PROC, "EPILOGUE must be macro procedure: %s" )
pick( RESERVED_WORD_EXPECTED, "Reserved word expected" )
pick( INVOKE_REQUIRES_PROTOTYPE, "INVOKE requires prototype for procedure" )
pick( INVALID_TYPE_FOR_DATA_DECLARATION, "Invalid type for data declaration: %s" )
pick( OPERAND_MUST_BE_RECORD, "Operand must be RECORD type or field" )
pick( UNMATCHED_MACRO_NESTING, "Unmatched macro nesting" )
pick( EMPTY_STRING, "Empty (null) string" )
pick( SEGMENT_MISSING_FOR_FIXUP, "No segment information to create fixup: %s" )
pick( REGISTER_VALUE_OVERWRITTEN_BY_INVOKE, "Register value overwritten by INVOKE" )
pick( MISSING_QUOTATION_MARK_IN_STRING, "Missing quotation mark in string" )
pick( DIVIDE_BY_ZERO_IN_EXPR, "Divide by zero in expression" )
pick( GENERAL_FAILURE, "General Failure" )
pick( CANNOT_HAVE_IMPLICIT_FAR_JUMP_OR_CALL_TO_NEAR_LABEL, "Cannot have implicit far jump or call to near label" )
pick( INVALID_USE_OF_REGISTER, "Invalid use of register" )
pick( DISTANCE_INVALID, "Distance invalid for current segment" )
pick( INITIALIZER_MAGNITUDE_TOO_LARGE, "Initializer magnitude too large: %s" )
pick( CANNOT_ADD_TWO_RELOCATABLE_LABELS, "Cannot add two relocatable labels" )
pick( CANNOT_DEFINE_AS_PUBLIC_OR_EXTERNAL, "Cannot define as public or external: %s" )
pick( POSITIVE_VALUE_EXPECTED, "Positive value expected" )
pick( FAR_NOT_ALLOWED_IN_FLAT_MODEL_COMM_VARIABLES, "FAR not allowed in FLAT model COMM variables" )
pick( TOO_MANY_ARGUMENTS_TO_INVOKE, "Too many arguments to INVOKE" )
pick( DIRECTIVE_MUST_APPEAR_INSIDE_A_MACRO, "Directive must appear inside a macro" )
pick( INVALID_TYPE_EXPRESSION, "Invalid type expression" )
pick( CANNOT_DECLARE_SCOPED_CODE_LABEL_AS_PUBLIC, "Cannot declare scoped code label as PUBLIC: %s" )
pick( INVALID_RADIX_TAG, "Invalid radix tag" )
pick( INSTRUCTION_OPERAND_MUST_HAVE_SIZE,"Instruction operand must have size" )
pick( USE_OF_REGISTER_ASSUMED_TO_ERROR, "Use of register assumed to ERROR" )
pick( INITIALIZED_DATA_NOT_SUPPORTED_IN_SEGMENT, "Instructions and initialized data not supported in %s segments" )
pick( LITERAL_EXPECTED_AFTER_EQ, "Literal expected after '='" )
#if PAGE4K
pick( NO_4KPAGE_ALIGNED_SEGMENTS_IN_MS386,"No 4k Page-aligned segments in MS386 OMF" )
#else
pick( msg_filler25, "" )
#endif
pick( LINNUM_INFO_FOR_SEGMENT_WITHOUT_CLASS_CODE, "Line number information for segment without class 'CODE': %s" )
pick( OPERAND_MUST_BE_RELOCATABLE, "Operand must be relocatable" )
pick( CONSTANT_OR_RELOCATABLE_LABEL_EXPECTED, "Constant or relocatable label expected" )
pick( IF2_NOT_ALLOWED, "[ELSE]IF2/.ERR2 not allowed, single-pass assembler" )
pick( EXPR_TOO_COMPLEX_FOR_UNTILCXZ, "Expression too complex for UNTILCXZ" )
pick( OPERANDS_MUST_BE_IN_SAME_SEGMENT, "Operands must be in same segment" )
pick( INVALID_USE_OF_EXTERNAL_SYMBOL, "Invalid use of external symbol: %s" )
#if COFF_SUPPORT
pick( LEADING_UNDERSCORE_REQUIRED_FOR_START_LABEL, "For -coff leading underscore required for start label: %s" )
#else
pick( msg_filler2, "" )
#endif
pick( INVALID_CMDLINE_VALUE, "Invalid command-line value, default is used: -%s" )
pick( UNKNOWN_FIXUP_TYPE, "Unknown fixup type: %u at %s.%lX" )
pick( UNSUPPORTED_FIXUP_TYPE, "Unsupported fixup type for %s: %s" )
pick( INVALID_FIXUP_TYPE, "Invalid fixup type for %s: %u at location %s.%lX" )
pick( SYNTAX_ERROR_IN_CONTROL_FLOW_DIRECTIVE, "Syntax error in control-flow directive" )
pick( INVALID_MODEL_PARAM_FOR_FLAT, "Invalid .model parameter for flat model" )
#if BIN_SUPPORT
pick( FORMAT_DOESNT_SUPPORT_EXTERNALS, "Output format doesn't support externals: %s" )
pick( START_LABEL_INVALID, "Invalid start label for -bin" )
#if MZ_SUPPORT
pick( NO_START_LABEL, "No start label defined" )
pick( NO_STACK, "No stack defined" )
pick( INVALID_HEADER_ALIGNMENT, "Invalid alignment - value must be 2^n (n=4..15)" )
#else
pick( msg_filler11, "" )
pick( msg_filler12, "" )
pick( msg_filler13, "" )
#endif
#else
pick( msg_filler11, "" )
pick( msg_filler12, "" )
pick( msg_filler13, "" )
pick( msg_filler14, "" )
pick( msg_filler15, "" )
#endif
pick( INDEX_VALUE_PAST_END_OF_STRING, "Index value past end of string: %d" )
pick( COUNT_VALUE_TOO_LARGE, "Count value too large" )
pick( COUNT_MUST_BE_POSITIVE_OR_ZERO, "Count must be positive or zero" )
pick( SYNTAX_ERROR_EX, "Syntax error: %s" )
#if AMD64_SUPPORT
pick( TOO_MANY_UNWIND_CODES_IN_FRAME_PROC,"Too many unwind codes in FRAME procedure" )
#else
pick( msg_filler26, "" )
#endif
#if PE_SUPPORT
pick( MODEL_MUST_BE_FLAT, "Model must be FLAT" )
#else
pick( msg_filler24, "" )
#endif
pick( MUST_USE_FLOAT_INITIALIZER, "Must use floating-point initializer" )
pick( ORG_NOT_ALLOWED_IN_UNIONS, "ORG directive not allowed in unions" )
pick( STRUCT_ALIGN_TOO_HIGH, "Struct alignment must be 1, 2, 4, 8, 16 or 32" )
pick( STRUCT_CANNOT_BE_INSTANCED, "Structure cannot be instanced" )
pick( MISSING_ANGLE_BRACKET_OR_BRACE_IN_LITERAL, "Missing angle bracket or brace in literal" )
pick( NONDIGIT_IN_NUMBER, "Nondigit in number: %s" )
pick( WORD_FIXUP_FOR_32BIT_LABEL, "16bit fixup for 32bit label: %s" )
pick( TOO_MANY_MACRO_PLACEHOLDERS, "Too many macro placeholders" )
pick( MISSING_MACRO_ARGUMENT, "Missing macro argument: %s, parameter %u" )
pick( DOES_NOT_WORK_WITH_32BIT_SEGMENTS, "Doesn't work with 32-bit segments: %s" )
pick( SEGMENT_EXCEEDS_64K_LIMIT, "Segment exceeds 64k limit: %s" )
pick( NOT_SUPPORTED_WITH_OMF_FORMAT, "Not supported with OMF format: %s" )
pick( NOT_SUPPORTED_WITH_CURR_FORMAT, "Not supported with current output format: %s" )
pick( UNKNOWN_DEFAULT_PROLOGUE_ARGUMENT, "Unknown default prologue argument: %s" )
pick( LOADDS_IGNORED_IN_FLAT_MODEL, "LOADDS ignored in flat model" )
pick( MISSING_RIGHT_PARENTHESIS_IN_EXPRESSION, "Missing right parenthesis in expression" )
pick( INVALID_OPERAND_FOR_OPERATOR, "Invalid operand for %s: %s" )
pick( STRUCTURE_IMPROPERLY_INITIALIZED, "Structure improperly initialized: %s" )
pick( EXPECTED, "Expected: %s" )
pick( INVALID_DATA_INITIALIZER, "Invalid data initializer: %s" )
pick( EXPECTED_DATA_LABEL, "Expected data label" )
pick( EXPRESSION_MUST_BE_A_CODE_ADDRESS, "Expression must be a code address" )
pick( N_OPTION_NEEDS_A_NAME_PARAMETER, "-n Option needs a valid name parameter" )
pick( CONSTANT_VALUE_TOO_LARGE, "Constant value too large: %" I64_SPEC "Xh" )
pick( TEXT_MACRO_USED_PRIOR_TO_DEFINITION, "Text macro used prior to definition: %s" )
pick( OFFSET_SIZE_MISMATCH, "Offset size incompatible with current segment" )
pick( INSTRUCTION_FORM_REQUIRES_80386, "Instruction form requires 80386" )
pick( GROUP_SEGMENT_SIZE_CONFLICT, "Group/Segment offset size conflict: %s - %s" )
pick( ASSEMBLY_PASSES, "Assembly passes reached: %u" )
pick( FILENAME_MUST_BE_ENCLOSED_IN_QUOTES_OR_BRACKETS, "Filename parameter must be enclosed in <> or quotes" )
pick( START_ADDRESS_IGNORED, "Start address on END directive ignored with .STARTUP" )
pick( INVALID_SYMBOL_TYPE_IN_EXPRESSION, "Invalid symbol type in expression: %s" )
pick( MISSING_RIGHT_PARENTHESIS, "Missing right parenthesis" )
pick( DIRECTIVE_MUST_BE_IN_CONTROL_BLOCK,"Directive must be in control block" )
pick( EXPECTED_MEMORY_MODEL, "Expected: memory model" )
pick( TYPE_IS_WRONG_SIZE_FOR_REGISTER, "Type is wrong size for register" )
pick( IFDEF_EXPECTS_SYMBOL_ARGUMENT, "IF[n]DEF expects a plain symbol as argument: %s" )
pick( JUMP_DESTINATION_MUST_SPECIFY_A_LABEL, "Jump destination must specify a label" )
pick( TOKEN_IGNORED, "Ignored: %s" )
pick( MISSING_ARGUMENT_FOR_CMDLINE_OPTION, "Missing argument for cmdline option" )
pick( INVALID_COPROCESSOR_REGISTER, "Invalid coprocessor register" )
#if AMD64_SUPPORT
pick( INVALID_USAGE_OF_AHBHCHDH, "Registers AH-DH may not be used with SPL-DIL or R8-R15" )
pick( ENDPROLOG_FOUND_BEFORE_EH_DIRECTIVES, ".ENDPROLOG found before EH directives" )
pick( MISSING_FRAME_IN_PROC, "Missing FRAME in PROC, no unwind code will be generated" )
pick( BAD_ALIGNMENT_FOR_OFFSET_IN_UNWIND_CODE, "Bad alignment for offset in unwind code" )
pick( NONZERO_VALUE_EXPECTED, "Nonzero value expected" )
pick( SIZE_OF_PROLOG_TOO_BIG, "Size of prolog too big, must be < 256 bytes" )
pick( MISSING_ENDPROLOG, "Missing .ENDPROLOG: %s" )
#else
pick( msg_filler4, "" )
pick( msg_filler5, "" )
pick( msg_filler6, "" )
pick( msg_filler7, "" )
pick( msg_filler8, "" )
pick( msg_filler9, "" )
pick( msg_filler10, "" )
#endif
#if COFF_SUPPORT
pick( SAFESEH_ARGUMENT_MUST_BE_A_PROC, ".SAFESEH argument must be a PROC" )
pick( DIRECTIVE_IGNORED_WITHOUT_X, "Directive ignored without -%s switch" )
#else
pick( msg_filler22, "" )
pick( msg_filler23, "" )
#endif
#if ELF_SUPPORT
pick( ELF_GNU_EXTENSIONS_USED, "ELF GNU extensions (8/16-bit relocations) used" )
#else
pick( msg_filler3, "" )
#endif
pick( SYNTAX_ERROR_IN_EXPRESSION, "Syntax error in expression" )
pick( MACRO_LABEL_NOT_DEFINED, "Macro label not defined: %s" )
pick( PROCEDURE_ARGUMENT_OR_LOCAL_NOT_REFERENCED, "Procedure argument or local not referenced: %s" )
pick( GROUP_DEFINITION_TOO_LARGE, "Group definition too large, truncated: %s" )
pick( COMM_VAR_EXCEEDS_64K, "COMM variable exceeds 64K: %s" )
pick( MUST_BE_PUBLIC_OR_EXTERNAL, "Must be public or external: %s" )
pick( PARAM_IS_RESERVED_WORD, "parameter/local name is reserved word: %s" )
pick( REAL_OR_BCD_NUMBER_NOT_ALLOWED, "real or BCD number not allowed" )
pick( STRUCTURE_FIELD_EXPECTED, "structure field expected" )
pick( CONSTANT_VALUE_TOO_LARGE_EX, "Constant value too large: %" I64_SPEC "X%016" I64_SPEC "Xh" )
pick( ELSE_CLAUSE_ALREADY_OCCURED_IN_THIS_IF_BLOCK, "ELSE clause already occured in this IF block" )
pick( ILLEGAL_USE_OF_SEGMENT_REGISTER, "Illegal use of segment register" )
pick( GROUP_EXCEEDS_64K, "Group exceeds 64K: %s" )
pick( EXPORT_MUST_BE_FAR, "EXPORT must be FAR: %s" )

13
H/msgtext.h Normal file
View File

@ -0,0 +1,13 @@
/****************************************************************************
*
* Description: msgtext.c interface
*
****************************************************************************/
#ifndef _MSGTEXT_H_
#define _MSGTEXT_H_
//extern const char *MsgGet( int, char * );
extern const char *MsgGetEx( int ); /* doesn't need a buffer */
#endif

45
H/myassert.h Normal file
View File

@ -0,0 +1,45 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Internal error handling macros.
*
****************************************************************************/
#ifndef MYASSERT_H
#define MYASSERT_H
#ifdef NDEBUG
#define myassert(expr) ((void)0)
#else
#if defined( __WATCOMC__ )
#pragma aux InternalError aborts;
#endif
extern int InternalError( const char *file, unsigned line );
#define myassert(expr) ((void)((expr) ? 0 : InternalError(__FILE__,__LINE__)))
#endif
#endif

22
H/omf.h Normal file
View File

@ -0,0 +1,22 @@
/* interface to OMF format output functions */
#ifndef _OMF_H_INCLUDED_
#define _OMF_H_INCLUDED_
/* max size of LEDATA data is 1024 - (1+2+1/2+2/4+1) = 1014 */
#define MAX_LEDATA_THRESHOLD (1024 - 10)
struct line_num_info;
void omf_init( struct module_info * );
void omf_set_filepos( void );
//void omf_write_ledata( struct dsym * );
void omf_OutSelect( bool );
void omf_FlushCurrSeg( void );
void omf_check_flush( const struct line_num_info * );
#endif // _OMF_H_INCLUDED_

182
H/omfint.h Normal file
View File

@ -0,0 +1,182 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: OMF internal definitions.
*
****************************************************************************/
#ifndef OMFINT_H
#define OMFINT_H 1
#define WriteU16(p,n) (*(uint_16*)(p) = (uint_16)(n))
#define WriteU32(p,n) (*(uint_32*)(p) = (uint_32)(n))
//#define WriteS16(p,n) (*(int_16*)(p) = (int_16)(n))
//#define WriteS32(p,n) (*(int_32*)(p) = (int_32)(n))
/* v2.11: max object record size reduced to 0xFF0 so the buffer may
* be located on the stack as a local variable.
* for 8086, size reduced to 1024. This should only affect GRPDEF
* records, since all other record types are already ensured not to
* exceed 1024.
*/
#ifdef __I86__
#define OBJ_BUFFER_SIZE 0x0400
#else
#define OBJ_BUFFER_SIZE 0x0FF0
#endif
/*-----------------------------------------------------*/
/* A COMENT record needs additional data to be attached. */
struct coment_info {
uint_8 attr; /* attribute field from coment record */
uint_8 cmt_class; /* class field from coment record */
};
struct modend_info {
uint_8 main_module; /* module is a main module */
uint_8 start_addrs; /* module has start address */
};
/*
* LNAMES, EXTDEFs, and COMDEFs all use this structure. The actual
* LNAMES/etc are in the data attached to the record.
*/
struct lnames_info {
uint_16 first_idx; /* index of first name in this record */
uint_16 num_names; /* number of names in this record */
};
/* the group's segments are attached */
struct grpdef_info {
uint_16 idx; /* index of this grpdef record */
};
struct physref {
uint_16 frame; /* frame number of physical reference */
uint_32 offset; /* offset into reference */
};
struct segdef_info {
uint_16 idx; /* index for this segment */
uint_8 use_32; /* use_32 for this segment */
uint_8 align; /* align field (see omfspec.h) */
uint_8 combine; /* combine field (see omfspec.h) */
//uint_8 access_valid; /* does next field have valid value */
//uint_8 access_attr; /* PharLab Easy OMF access attributes */
struct physref abs; /* (conditional) absolute physical reference*/
uint_32 seg_length; /* length of this segment */
uint_16 seg_lname_idx; /* segment's name lname index */
uint_16 class_lname_idx;/* segment's class lname index */
uint_16 ovl_lname_idx; /* segment's overlay lname index */
};
/* the contents of the LEDATA is attached */
struct ledata_info {
uint_16 idx; /* index of segment the data belongs to */
uint_32 offset; /* offset into segment of start of data */
};
/* base info is supplied by PUBDEF, LINNUM and COMDAT */
struct base_info {
uint_16 grp_idx; /* index of the group base */
uint_16 seg_idx; /* index of the segment */
uint_16 frame; /* used if grp_idx == 0 && seg_idx == 0 */
};
/* line number info - the items itself are attached */
struct linnum_info {
struct base_info base;
};
/* public info - the items itself are attached */
struct pubdef_info {
struct base_info base;
};
#if COMDATSUPP
/* the data that comprises the record is attached. */
struct comdat_info {
uint_8 flags; /* see COMDAT flags in omfspec.h */
uint_8 attributes; /* see COMDAT allocation type + selection criteria in omfspec.h */
uint_8 align; /* see COMDAT alignment in omfspec.h */
uint_32 offset; /* may be 16- or 32-bit */
uint_16 type_idx; /* type index field, usually 0 */
struct base_info base; /* used only if allocation type is COMDAT_EXPLICIT */
uint_16 public_lname_idx; /* the COMDAT's public name (lname index) */
};
/* the line number info is attached. */
struct linsym_info {
uint_8 flags;
uint_16 public_lname_idx; /* the COMDAT's public name (lname index) */
};
#endif
struct omf_rec {
unsigned length; /* # of bytes in 'data' (PRIVATE) */
unsigned curoff; /* curr. pos in 'data' (PRIVATE) */
uint_8 *data; /* data for this record (PRIVATE) */
uint_8 command; /* the command field for this record */
uint_8 is_32; /* a Microsoft 32bit record? */
union {
struct coment_info coment; /* CMD_COMENT */
struct modend_info modend; /* CMD_MODEND */
struct lnames_info lnames; /* CMD_LNAMES */
struct lnames_info extdef; /* CMD_EXTDEF */
struct lnames_info comdef; /* CMD_COMDEF */
struct grpdef_info grpdef; /* CMD_GRPDEF */
struct segdef_info segdef; /* CMD_SEGDEF */
struct ledata_info ledata; /* CMD_LEDATA */
struct linnum_info linnum; /* CMD_LINNUM */
struct pubdef_info pubdef; /* CMD_PUBDEF */
#if COMDATSUPP
struct comdat_info comdat; /* CMD_COMDAT */
struct linsym_info linsym; /* CMD_LINSYM */
#endif
#if 0 /* not used */
struct lnames_info llnames; /* CMD_LLNAMES */
struct lnames_info cextdf; /* CMD_CEXTDEF */
struct ledata_info lidata; /* CMD_LIDATA */
#endif
} d; /* data depending on record type */
};
extern void omf_write_record( const struct omf_rec * );
#define FIX_GEN_MAX 11 /* max size needed for OmfFixGenFix() */
#define FIX_GEN_MODEND_MAX 9 /* max size needed for OmfFixGenFixModend() */
enum fixgen_types {
FIX_GEN_INTEL,
FIX_GEN_MS386
};
extern unsigned OmfFixGenFix( const struct fixup *fix, uint_32 start_loc, uint_8 *buf, enum fixgen_types type );
extern unsigned OmfFixGenFixModend( const struct fixup *, uint_8 *buf, uint_32, enum fixgen_types type );
#endif

396
H/omfspec.h Normal file
View File

@ -0,0 +1,396 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: OMF basics
*
****************************************************************************/
#ifndef OMFSPEC_H
#define OMFSPEC_H 1
#if 0
/*
* INTEL Segment Alignment Specifiers - A field
*/
enum segment_alignment_specifiers {
ALIGN_ABS = 0, /* absolute segment - no alignment */
ALIGN_BYTE = 1, /* relocatable seg - byte aligned */
ALIGN_WORD = 2, /* relocatable seg - word aligned */
ALIGN_PARA = 3, /* relocatable seg - para aligned */
ALIGN_PAGE = 4, /* relocatable seg - page aligned */
ALIGN_DWORD = 5, /* relocatable seg - dword aligned */
ALIGN_LTRELOC = 6, /* load-time relocatable segment */
#if PAGE4K /* PharLab Easy OMF */
ALIGN_4KPAGE = 6, /* relocatable seg - 4k page aligned*/
ALIGN_PAGE4K = 6, /* relocatable seg - 4k page aligned*/
#endif
/* this currently not supported by the linker. */
//ALIGN_UNABS = 5, /* unnamed absolute segment */
};
#endif
enum segdef_align_values {
SEGDEF_ALIGN_ABS = 0,/* absolute segment - no alignment */
SEGDEF_ALIGN_BYTE = 1,/* relocatable seg - byte aligned */
SEGDEF_ALIGN_WORD = 2,/* - word aligned */
SEGDEF_ALIGN_PARA = 3,/* - para aligned */
SEGDEF_ALIGN_PAGE = 4,/* - page aligned */
SEGDEF_ALIGN_DWORD = 5,/* - dword aligned */
#if PAGE4K
SEGDEF_ALIGN_4KPAGE = 6 /* - 4k page aligned */
#endif
};
/*
* INTEL Segment Combination Attributes - C field
* JWasm uses COMB_INVALID, COMB_ADDOFF, COMB_STACK & COMB_COMMON
*/
enum combine_attributes {
COMB_INVALID = 0, /* PRIVATE attribute */
COMB_ABOVEALL = 1, /* marked as "reserved" */
COMB_ADDOFF = 2, /* PUBLIC attribute */
COMB_BAD = 3, /* marked as "reserved" */
COMB_FOUR = 4, /* comment: same as 2 */
COMB_STACK = 5, /* STACK attribute */
COMB_COMMON = 6, /* COMMON attribute */
COMB_ALIGNTOP = 7, /* comment: same as 2 */
};
#if 0
#define SEGATTR_A( a ) (ALIGN_##a << 5)
#define SEGATTR_C( a ) (COMB_##a << 2)
enum {
SEGATTR_BIG = 1<< 1, /* exactly 64k or 2**32 */
SEGATTR_P = 1, /* use 32 */
};
#endif
/*
* INTEL Frame Specifiers
* FRAME_ABS[WD] not supported according to TIS OMF docs.
* FRAME_NONE should never appear in object modules, it's just
* a void used by jwasm internally.
*/
enum frame_methods {
FRAME_SEG = 0, /* segment index */
FRAME_GRP = 1, /* group index */
FRAME_EXT = 2, /* external index */
//FRAME_ABS = 3, /* absolute frame number */
FRAME_LOC = 4, /* segment index of last LEDATA */
FRAME_TARG = 5, /* frame same as target */
FRAME_NONE = 6, /* no frame */
};
/*
* INTEL Target Specifiers
* TARGET_ABS[WD] is supported for THREAD sub-records only, according to TIS OMF docs;
* Since JWasm won't write THREAD sub-records, those methods are invalid.
*/
enum target_methods {
TARGET_SEGWD = 0, /* segment index with displacement */
TARGET_GRPWD = 1, /* group index with displacement */
TARGET_EXTWD = 2, /* external index with displacement */
//TARGET_ABSWD = 3, /* abs frame num with displacement */
TARGET_SEG = 4, /* segment index, no displacement */
TARGET_GRP = 5, /* group index, no displacement */
TARGET_EXT = 6, /* external index, no displacement */
//TARGET_ABS = 7, /* abs frame num, no displacement */
TARGET_WITH_DISPL = ~4, /* frame with displacement */
};
/* Bits in FIXUPP records */
enum {
FIXUPP_FIXUP = 0x80,
FIXDAT_FTHREAD = 0x80,
FIXDAT_TTHREAD = 8,
FIXDAT_PBIT = 4,
FIXDAT_MBIT = 0x40,
TRDDAT_DBIT = 0x40,
/*
* INTEL Group Specifiers
*/
GRP_SEGIDX = 0xff, /* group segment index */
GRP_EXTIDX = 0xfe, /* group external index */
GRP_FULLNAME = 0xfd, /* full name indices */
GRP_LTLDATA = 0xfb, /* load time data info */
GRP_ADDR = 0xfa, /* load time addr for the group */
};
/*
* INTEL Object Record Types
*/
enum cmd_omf {
#if 0 /* these cmds aren't used (and ignored by MS link) */
CMD_MIN_CMD = 0x6e, /* minimum cmd enum */
CMD_RHEADR = 0x6e, /* R-Module Header */
CMD_REGINT = 0x70, /* Register Initialization */
CMD_REDATA = 0x72, /* Relocatable Enumerated Data */
CMD_RIDATA = 0x74, /* Relocatable Iterated Data */
CMD_OVLDEF = 0x76, /* Overlay Definition */
CMD_ENDREC = 0x78, /* End */
CMD_BLKDEF = 0x7a, /* block definition */
//CMD_BLKD32 = 0x7b, /* weird extension for QNX MAX assembler */
CMD_BLKEND = 0x7c, /* block end */
//CMD_BLKE32 = 0x7d, /* _might_ be used by QNX MAX assembler */
CMD_DEBSYM = 0x7e, /* Debug Symbols */
#else
CMD_MIN_CMD = 0x80, /* minimum cmd enum */
#endif
CMD_THEADR = 0x80, /* translator header */
CMD_LHEADR = 0x82, /* library header */
// CMD_PEDATA = 0x84, /* physical enumerated data */
// CMD_PIDATA = 0x86, /* physical iterated data */
CMD_COMENT = 0x88, /* comment record */
CMD_MODEND = 0x8a, /* end of module record */
CMD_EXTDEF = 0x8c, /* import names record */
CMD_TYPDEF = 0x8e, /* type definition record */
CMD_PUBDEF = 0x90, /* public names record */
// CMD_LOCSYM = 0x92, /* local symbols */
CMD_LINNUM = 0x94, /* line number record */
CMD_LNAMES = 0x96, /* list of names record */
CMD_SEGDEF = 0x98, /* segment definition record */
CMD_GRPDEF = 0x9a, /* group definition record */
CMD_FIXUPP = 0x9c, /* relocation record */
CMD_LEDATA = 0xa0, /* logical enumerated data */
CMD_LIDATA = 0xa2, /* logical iterated data */
// CMD_LIBHED = 0xa4, /* library header */
// CMD_LIBNAM = 0xa6, /* library module names */
// CMD_LIBLOC = 0xa8, /* library module locations */
// CMD_LIBDIC = 0xaa, /* library dictionary */
CMD_COMDEF = 0xb0, /* communal definition */
CMD_BAKPAT = 0xb2, /* backpatch record (for Quick C) */
/* the following types are used to make local names known to the linker */
CMD_LEXTDEF = 0xb4, /* local import names record */
CMD_STATIC_EXTDEF = 0xb4,
CMD_LPUBDEF = 0xb6, /* local public names def record */
CMD_LCOMDEF = 0xb8, /* local communal names def record */
CMD_STATIC_COMDEF = 0xb8,
CMD_CEXTDEF = 0xbc, /* external reference to a COMDAT */
CMD_COMDAT = 0xc2, /* initialized communal data record */
CMD_LINSYM = 0xc4, /* symbol line numbers */
CMD_ALIAS = 0xc6, /* alias definition record */
CMD_NBKPAT = 0xc8, /* named backpatch record (quick c?) */
CMD_LLNAMES = 0xca, /* a "local" lnames */
CMD_MAX_CMD = 0xca, /* maximum cmd enum */
#if 0
CMD_VERNUM = 0xcc, /* TIS version number record */
CMD_VENDEXT = 0xce, /* TIS vendor extension record */
CMD_MAX_CMD = 0xce, /* maximum cmd enum */
#endif
#if 0 /* 32-bit versions */
CMD_MODE32 = CMD_MODEND+1,
CMD_PUBD32 = CMD_PUBDEF+1,
CMD_LINN32 = CMD_LINNUM+1,
CMD_SEGD32 = CMD_SEGDEF+1,
CMD_FIXU32 = CMD_FIXUP+1,
CMD_LEDA32 = CMD_LEDATA+1,
CMD_LIDA32 = CMD_LIDATA+1,
CMD_BAKP32 = CMD_BAKPAT+1,
CMD_LEXTDEF32 = CMD_LEXTDEF+1,
CMD_STATIC_EXTD32 = CMD_STATIC_EXTDEF+1,
CMD_LPUBDEF32 = CMD_LPUBDEF+1,
CMD_COMD32 = CMD_COMDAT+1,
CMD_LINS32 = CMD_LINSYM+1,
CMD_NBKP32 = CMD_NBKPAT+1,
#endif
};
/* OMF fixup types; 4-bit-"location"-field in FIXUP sub-records; see omffixup.c.
*/
enum omf_fixup_types {
LOC_OFFSET_LO = 0, /* 8-bit (lowbyte) offset */
LOC_OFFSET = 1, /* 16-bit offset */
LOC_BASE = 2, /* segment (always 16-bit) */
LOC_BASE_OFFSET = 3, /* 16-bit offset & 16-bit segment */
LOC_OFFSET_HI = 4, /* 8-bit (hibyte) offset */
#if 0
LOC_PL_OFFSET_32 = 5, /* 32-bit offset (PharLab) */
LOC_PL_BASE_OFFSET_32 = 6, /* 32-bit offset & 16-bit segment (PharLab) */
#endif
LOC_MS_LINK_OFFSET = 5, /* 16-bit "loader-resolved" offset (MS) */
LOC_MS_OFFSET_32 = 9, /* 32-bit offset (MS) */
LOC_MS_BASE_OFFSET_32= 11, /* 32-bit offset & 16-bit segment (MS) */
LOC_MS_LINK_OFFSET_32= 13 /* 32-bit "loader-resolved" offset (MS) */
};
/* Comment Type */
enum {
CMT_TNP = 0x80, /* no purge bit */
CMT_TNL = 0x40, /* no list bit */
};
/*
* Comment classes. JWasm uses:
* - CMT_DOSSEG : dosseg directive
* - CMT_DEFAULT_LIBRARY : includelib directive
* - CMT_OMF_EXT : PROC's EXPORT attribute
* - CMT_MS_OMF : codeview debug info version
* - CMT_MS_END_PASS_1 : end of pass one
* - CMT_WKEXT : extern directive with altname
* - CMT_DEPENDENCY : include directive, Borland specific
* - CMT_DISASM_DIRECTIVE : wdis special
* - CMT_LINKER_DIRECTIVE : wlink specials
*/
enum omf_comment_classes {
//CMT_LANGUAGE_TRANS = 0x00, /* Language translator comment */
//CMT_INTEL_COPYRIGHT = 0x01, /* INTEL Copyright record */
//CMT_MS_PADDING = 0x01, /* Microsoft uses this for padding */
//CMT_WAT_PROC_MODEL = 0x9b, /* Watcom processor & model info */
//CMT_MS_DOS_VERSION = 0x9c, /* obsolete */
//CMT_MS_PROC_MODEL = 0x9d, /* Microsoft processor & model info */
CMT_DOSSEG = 0x9e, /* DOSSEG directive */
CMT_DEFAULT_LIBRARY = 0x9f, /* Default library cmd */
CMT_OMF_EXT = 0xa0, /* OMF extension */
CMT_MS_OMF = 0xa1, /* MS codeview debug info included */
CMT_MS_END_PASS_1 = 0xa2, /* MS end of linker pass 1 */
//CMT_LIBMOD = 0xa3, /* Record specifying name of object */
//CMT_EXESTR = 0xa4, /* Executable string */
//CMT_INCERR = 0xa6, /* Incremental Compilation Error */
//CMT_NOPAD = 0xa7, /* No segment padding */
CMT_WKEXT = 0xa8, /* Weak external record */
//CMT_LZEXT = 0xa9, /* Lazy external record */
//CMT_EASY_OMF = 0xaa, /* Easy OMF signature record */
CMT_SRCFILE = 0xe8, /* Borland source file record */
CMT_DEPENDENCY = 0xe9, /* Borland dependency record */
CMT_DISASM_DIRECTIVE= 0xfd, /* Directive to disassemblers */
CMT_LINKER_DIRECTIVE= 0xfe, /* Linker directive */
//CMT_COMPILER_OPTIONS= 0xff, /* Microsoft: incremental compiler opts */
//CMT_SOURCE_NAME = 0xff /* name of the source file */
};
/*
* Comment Class Subtype for CMT_OMF_EXT
*/
enum omf_ext_subtype {
CMT_EXT_IMPDEF = 0x01, /* Subtype IMPDEF of OMF extension class */
CMT_EXT_EXPDEF = 0x02, /* Subtype EXPDEF of OMF extension class */
CMT_EXT_INCDEF = 0x03, /* Subtype INCDEF of OMF extension class */
CMT_EXT_PMLIB = 0x04, /* Protected Memory Library (OMF extension) */
CMT_EXT_LNKDIR = 0x05, /* Subtype LNKDIR of OMF extension class */
CMT_EXT_BIGEND = 0x06,
CMT_EXT_PRECOMP = 0x07,
};
//#define EASY_OMF_SIGNATURE "80386"
/*
* Linker directives ( CMT_LINKER_DIRECTIVE - mostly WLINK directives )
* JWasm uses LDIR_OPT_FAR_CALLS only
*/
enum linker_directives {
LDIR_SOURCE_LANGUAGE= 'D', /* dbg maj/min and source language */
LDIR_DEFAULT_LIBRARY= 'L', /* default library cmd */
LDIR_OPT_FAR_CALLS = 'O', /* optimize far calls/jmps for this seg */
//LDIR_OPT_UNSAFE = 'U', /* far call optimization unsafe for fixup*/
//LDIR_VF_TABLE_DEF = 'V', /* virtual function table lazy extdef */
//LDIR_VF_PURE_DEF = 'P', /* as above for pure functions */
//LDIR_VF_REFERENCE = 'R', /* virtual function reference */
//LDIR_PACKDATA = '7', /* amount to pack far data */
//LDIR_FLAT_ADDRS = 'F', /* debug addresses are flat */
//LDIR_OBJ_TIMESTAMP = 'T' /* file timestamp of object in a library */
};
/*
* Disasm directives ( CMT_DISASM_DIRECTIVE )
* this is a feature supported by OW WDis.
*/
enum disasm_directives {
/*
* DDIR_SCAN_TABLE is used by the code generator to indicate data in a
* code segment. i.e., scan tables generated for switch()s, floating point
* constants and string constants. The 'S' is followed by a segment index,
* then the start and end+1 offsets into the segment which are 16-bit in
* regular object files, and 32-bit in EasyOMF and Microsoft 386.
* If the segment index is zero, then it is followed by a LNAME index which
* identifies the COMDAT symbol that the scan table belongs to.
*/
DDIR_SCAN_TABLE_32 = 'S',
DDIR_SCAN_TABLE = 's'
};
/*
* COMDEF types
*/
enum comdef_types {
COMDEF_FAR = 0x61, /* FAR variable */
COMDEF_NEAR = 0x62, /* NEAR variable */
COMDEF_LEAF_SIZE = 0x80, /* bit set if size > 0x7f */
COMDEF_LEAF_2 = 0x81, /* 2 byte size field */
COMDEF_LEAF_3 = 0x84, /* 3 byte size field */
COMDEF_LEAF_4 = 0x88 /* 4 byte size field */
};
/* COMDAT (initialized communal data);
* record type 0xC2/0xC3;
* MS extension introduced for MSC 7.
*/
enum comdat_flags {
/*
* COMDAT flags
*/
COMDAT_CONTINUE = 0x01, /* continuation of previous COMDAT */
COMDAT_ITERATED = 0x02, /* LIDATA form of COMDAT */
COMDAT_LOCAL = 0x04, /* COMDAT is local to this module */
COMDAT_DATAINCODE = 0x08, /* data in code segment */
/*
* COMDAT allocation type ( low-order 4 bits of attributes field )
*/
COMDAT_ALLOC_MASK = 0x0f,
COMDAT_EXPLICIT = 0x00, /* in given segment ( base grp, seg and frame ) */
COMDAT_FAR_CODE = 0x01, /* allocate CODE use16 segment */
COMDAT_FAR_DATA = 0x02, /* allocate DATA use16 segment */
COMDAT_CODE32 = 0x03, /* allocate CODE use32 segment */
COMDAT_DATA32 = 0x04, /* allocate DATA use32 segment */
/*
* COMDAT selection criteria ( high-order 4 bits of attributes field )
*/
COMDAT_MATCH_MASK = 0xf0,
COMDAT_MATCH_NONE = 0x00, /* don't match anyone - only 1 instance allowed */
COMDAT_MATCH_ANY = 0x10, /* pick any instance */
COMDAT_MATCH_SAME = 0x20, /* must be same size - or linker will emit an error */
COMDAT_MATCH_EXACT = 0x30, /* pick any instance - but checksums must match */
/*
* COMDAT alignment
*/
COMDAT_ALIGN_SEG = 0x00, /* align from SEGDEF */
COMDAT_ALIGN_BYTE = 0x01,
COMDAT_ALIGN_WORD = 0x02,
COMDAT_ALIGN_PARA = 0x03,
COMDAT_ALIGN_4K = 0x04,
COMDAT_ALIGN_DWORD = 0x05
};
#endif

157
H/operands.h Normal file
View File

@ -0,0 +1,157 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: parser/code generator operand definitions.
* This file is included by parser.h
*
****************************************************************************/
#ifndef OPERANDS_H
#define OPERANDS_H
/* v1.96: OP_J32 (for far CALL/JMP) has been removed, now used for OP_I64.
* v2.04: 2 bits freed ( OP_CR, OP_DR and OP_TR replaced by OP_SPECREG )
* Also OP_SPECREG, OP_SRxx and OP_STxx moved just behind the other
* register operands.
* Note: register-related flags must be in bits 0-15, because register items
* in SpecialTable[] have these bits stored in a uint field (JWASMR!).
*/
enum operand_type {
OP_NONE = 0,
OP_R8 = 0x00000001,
OP_R16 = 0x00000002,
OP_R32 = 0x00000004,
#if AMD64_SUPPORT
OP_R64 = 0x00000008,
#endif
OP_MMX = 0x00000010, /* MMx register */
OP_XMM = 0x00000020, /* XMMx register */
#if AVXSUPP
OP_YMM = 0x00000040, /* YMMx register */
#endif
OP_A = 0x00000080, /* AL, AX, EAX, RAX registers */
OP_CL_ONLY = 0x00000100, /* CL register */
OP_DX_ONLY = 0x00000200, /* DX register */
OP_RSPEC = 0x00000400, /* CRx, DRx, TRx registers */
OP_SR86 = 0x00000800, /* CS, DS, ES, SS registers */
OP_SR386 = 0x00001000, /* FS, GS registers */
OP_ST = 0x00002000, /* ST0 register */
OP_ST_REG = 0x00004000, /* ST1-ST7 registers */
OP_AL = ( OP_A | OP_R8 ),
OP_AX = ( OP_A | OP_R16 ),
OP_EAX = ( OP_A | OP_R32 ),
#if AMD64_SUPPORT
OP_RAX = ( OP_A | OP_R64 ),
#endif
OP_CL = ( OP_CL_ONLY | OP_R8 ),
OP_DX = ( OP_DX_ONLY | OP_R16 ),
#if AMD64_SUPPORT
OP_RGT8 = ( OP_R16 | OP_R32 | OP_R64 ),
OP_RGT16 = ( OP_R32 | OP_R64 ),
OP_R = ( OP_R8 | OP_R16 | OP_R32 | OP_R64 ),
#else
OP_RGT8 = ( OP_R16 | OP_R32 ),
OP_RGT16 = ( OP_R32 ),
OP_R = ( OP_R8 | OP_R16 | OP_R32 ),
#endif
// OP_RMX = ( OP_MMX | OP_XMM ),
OP_SR = ( OP_SR86 | OP_SR386 ),
OP_STI = ( OP_ST | OP_ST_REG ),
OP_I8 = 0x00010000,
OP_I16 = 0x00020000,
OP_I32 = 0x00040000,
#if AMD64_SUPPORT
OP_I64 = 0x00080000,
#endif
OP_I48 = 0x00100000, /* used for immediate FAR call/jmp */
/* OP_I_1, OP_I_3 and OP_I8_U aren't flags. They are
* used as values in SWITCH statements only. It's possible to
* "compress" them if room for another flag is needed
*/
OP_I_1 = ( 0x00200000 | OP_I8 ),
OP_I_3 = ( 0x00400000 | OP_I8 ),
OP_I8_U = ( 0x00800000 | OP_I8 | OP_I16 | OP_I32 ),
OP_I = ( OP_I8 | OP_I16 | OP_I32 ),
OP_IGE8 = ( OP_I8 | OP_I16 | OP_I32 ),
OP_IGE16 = ( OP_I16 | OP_I32 ),
#if AMD64_SUPPORT
OP_I_ANY = ( OP_I | OP_I64 | OP_I48 ),
#else
OP_I_ANY = ( OP_I | OP_I48 ),
#endif
OP_M08 = 0x01000000,
OP_M16 = 0x02000000,
OP_M32 = 0x04000000,
OP_M64 = 0x08000000,
OP_M128 = 0x10000000,
#if AVXSUPP
OP_M256 = 0x20000000,
#endif
OP_M48 = 0x40000000,
OP_M80 = 0x80000000,
#if AMD64_SUPPORT
OP_MGT8 = ( OP_M16 | OP_M32 | OP_M64 ),
OP_MGT16 = ( OP_M32 | OP_M64 ),
#else
OP_MGT8 = ( OP_M16 | OP_M32 ),
OP_MGT16 = ( OP_M32 ),
#endif
OP_MFPTR = ( OP_M32 | OP_M48 | OP_M80 ),
#if AVXSUPP
OP_M_ANY = ( OP_M08 | OP_M16 | OP_M32 | OP_M64 | OP_M128 | OP_M256 | OP_M48 | OP_M80 ),
#else
OP_M_ANY = ( OP_M08 | OP_M16 | OP_M32 | OP_M64 | OP_M128 | OP_M48 | OP_M80 ),
#endif
/* OP_M without M80 will make some instr (i.e. FBSTP [esp]) fail! */
//OP_M = ( OP_M08 | OP_M16 | OP_M32 | OP_M64 | OP_M128 ),
OP_M = ( OP_M08 | OP_M16 | OP_M32 | OP_M64 | OP_M80 | OP_M128 ),
/* v2.06: items in instruction table now use OP_MS instead of OP_M */
OP_MS = ( OP_M08 | OP_M16 | OP_M32 | OP_M64 ),
};
/* since v2.06, this is a 8-bit field. Previously it was 4-bit only. */
enum operand3_type {
OP3_NONE = 0, /* must be 0, identical to OP_NONE */
OP3_CL,
OP3_I8_U, /* this is also used for signed values (IMUL) */
OP3_XMM0, /* v2.01: introduced with SSE4.1 */
OP3_I, /* v2.06: added to avoid the IMUL hack */
OP3_HID, /* hidden data ( CMPxxx[PD|PS|SD|SS] ) */
#if AVXSUPP
OP3_XMM = OP3_XMM0, /* for VEX encoding only */
OP3_YMM = OP3_XMM0, /* for VEX encoding only */
#endif
};
#endif

231
H/opndcls.h Normal file
View File

@ -0,0 +1,231 @@
/* operand classes. Introduced with v2.06, when the operand types were removed
* from the instruction table and replaced by a class index.
* As a result, it's easier and won't bloat the instruction table if the
* third operand is extended or a 4th operand ( for AVX ) is added.
*/
OpCls( NONE, NONE, NONE )
OpCls( AX, NONE, NONE ) /* FSTSW */
OpCls( I, NONE, NONE )
OpCls( I16, NONE, NONE )
OpCls( I32, NONE, NONE )
OpCls( I48, NONE, NONE )
OpCls( I8, NONE, NONE )
OpCls( I8_U, NONE, NONE )
OpCls( I_3, NONE, NONE )
OpCls( M08, NONE, NONE )
OpCls( M16, NONE, NONE )
OpCls( M16_M32, NONE, NONE )
#if AMD64_SUPPORT
OpCls( M16_M64, NONE, NONE )
#endif
OpCls( M32, NONE, NONE )
OpCls( M48, NONE, NONE )
OpCls( M64, NONE, NONE )
OpCls( M80, NONE, NONE )
#if AMD64_SUPPORT
OpCls( M128, NONE, NONE )
#endif
OpCls( MGT8, NONE, NONE )
OpCls( MS, NONE, NONE )
OpCls( M_ANY, NONE, NONE )
OpCls( R, NONE, NONE )
OpCls( R16_M16, NONE, NONE )
OpCls( R16_R32, NONE, NONE )
OpCls( R32, NONE, NONE )
#if AMD64_SUPPORT
OpCls( R64, NONE, NONE )
OpCls( R64_M64, NONE, NONE )
OpCls( R16_R64, NONE, NONE )
#endif
OpCls( R8_M08, NONE, NONE )
OpCls( RGT16, NONE, NONE )
OpCls( RGT8, NONE, NONE )
OpCls( SR, NONE, NONE )
OpCls( SR86, NONE, NONE )
#if AMD64_SUPPORT
OpCls( SR386, NONE, NONE )
#endif
OpCls( STI, NONE, NONE )
OpCls( A, DX_ONLY, NONE )
OpCls( A, I, NONE )
OpCls( A, I8_U, NONE )
OpCls( A, MS, NONE )
OpCls( A, RGT8, NONE )
OpCls( DX_ONLY, A, NONE )
OpCls( DX_ONLY, M08, NONE )
OpCls( DX_ONLY, M16, NONE )
OpCls( DX_ONLY, M32, NONE )
OpCls( DX_ONLY, MS, NONE )
OpCls( I16, I8_U, NONE )
OpCls( I8_U, A, NONE )
OpCls( M08, DX_ONLY, NONE )
OpCls( M08, M08, NONE )
OpCls( M16, DX_ONLY, NONE )
OpCls( M16, M16, NONE )
OpCls( M32, DX_ONLY, NONE )
OpCls( M32, M32, NONE )
OpCls( M32, XMM, NONE )
#if AMD64_SUPPORT
OpCls( M64, M64, NONE )
#endif
OpCls( M64, MMX, NONE )
OpCls( M64, XMM, NONE )
OpCls( M128, XMM, NONE )
#if AVXSUPP
OpCls( M256, YMM, NONE )
#endif
OpCls( MGT16, RGT16, NONE )
OpCls( MGT8, I8, NONE )
OpCls( MGT8, I8_U, NONE )
OpCls( MGT8, RGT8, NONE )
OpCls( MMX, I8_U, NONE )
OpCls( MMX, MMX, NONE )
OpCls( MMX, MMX_M64, NONE )
#if MASM_SSE_MEMX
OpCls( MMX, MMX_M64_08, NONE )
OpCls( MMX, MMX_M64_16, NONE )
OpCls( MMX, MMX_M64_32, NONE )
#endif
OpCls( MMX, RMGT16, NONE ) /* MOVD, CVTSI2SD, CVTSI2SS */
OpCls( MMX, XMM, NONE )
OpCls( MMX, XMM_M64, NONE )
OpCls( MMX, XMM_M128, NONE )
OpCls( MS, A, NONE )
OpCls( MS, DX_ONLY, NONE )
OpCls( MS, I, NONE )
OpCls( MS, MS, NONE )
OpCls( MS, R, NONE )
OpCls( MS, SR, NONE )
OpCls( R, I, NONE )
OpCls( R, MS, NONE )
OpCls( R, R, NONE )
OpCls( R, R_MS, NONE )
OpCls( R16_M16, R16, NONE )
OpCls( R16_R32, I, NONE )
#if AMD64_SUPPORT
OpCls( R64, I, NONE )
OpCls( R64, I64, NONE )
OpCls( R64, R32_M32, NONE )
#endif
OpCls( R8, I, NONE )
OpCls( RGT16, MMX, NONE )
OpCls( RGT16, R8_M08, NONE )
OpCls( RGT16, RGT8_MS, NONE )
OpCls( RGT16, RSPEC, NONE )
OpCls( RGT16, XMM, NONE )
#if AVXSUPP
OpCls( RGT16, YMM, NONE ) /* v2.11 */
#endif
OpCls( RGT16, XMM_M32, NONE )
OpCls( RGT16, XMM_M64, NONE )
#if VMXSUPP
OpCls( R32, R32_M32, NONE )
OpCls( R32_M32, R32, NONE )
OpCls( RGT16, M128, NONE )
#if AMD64_SUPPORT
OpCls( R64, R64_M64, NONE )
OpCls( R64_M64, R64, NONE )
#endif
#endif
#if SVMSUPP
OpCls( A, NONE, NONE ) /* VMRUN rAX */
OpCls( A, R32, NONE ) /* INVLPGA rAX, ECX */
#endif
OpCls( RGT8, A, NONE )
OpCls( RGT8, I, NONE )
OpCls( RGT8, I8, NONE )
OpCls( RGT8, I8_U, NONE )
OpCls( RGT8, MFPTR, NONE )
OpCls( RGT8, MS, NONE )
OpCls( RGT8, RGT8, NONE )
OpCls( RGT8, RGT8_MS, NONE )
OpCls( RGT8, R_MS, NONE )
OpCls( RGT8, SR, NONE )
#if INTELMOVQ
OpCls( R32_M32, MMX, NONE )
OpCls( R32_M32, XMM, NONE )
OpCls( R64_M64, MMX, NONE )
OpCls( R64_M64, XMM, NONE )
#else
OpCls( RMGT16, MMX, NONE )
OpCls( RMGT16, XMM, NONE )
#endif
OpCls( RSPEC, RGT16, NONE )
OpCls( R_MS, CL_ONLY, NONE )
OpCls( R_MS, I, NONE )
OpCls( R_MS, I8_U, NONE )
OpCls( R_MS, I_1, NONE )
OpCls( SR, MS, NONE )
OpCls( SR, RGT8, NONE )
OpCls( ST, STI, NONE )
OpCls( STI, ST, NONE )
OpCls( XMM, I8_U, NONE )
#if AVXSUPP
OpCls( XMM, M32, NONE )
#endif
OpCls( XMM, M64, NONE )
OpCls( XMM, M128, NONE )
OpCls( XMM, MMX, NONE )
OpCls( XMM, MMX_M64, NONE )
OpCls( XMM, RMGT16, NONE )
OpCls( XMM, XMM, NONE )
OpCls( XMM, XMM_M16, NONE )
OpCls( XMM, XMM_M32, NONE )
OpCls( XMM, XMM_M64, NONE )
OpCls( XMM, XMM_M128, NONE )
#if MASM_SSE_MEMX
OpCls( XMM, XMM_M128_08, NONE )
OpCls( XMM, XMM_M128_16, NONE )
OpCls( XMM, XMM_M128_32, NONE )
OpCls( XMM, XMM_M128_64, NONE )
#endif
#if AVXSUPP
OpCls( XMM, YMM_M256, NONE )
OpCls( YMM, M32, NONE )
OpCls( YMM, M64, NONE )
OpCls( YMM, M128, NONE )
OpCls( YMM, M256, NONE )
OpCls( YMM, YMM_M256, NONE )
#endif
OpCls( M16, XMM, I8_U )
OpCls( M32, XMM, I8_U )
OpCls( MMX, MMX_M64, I8_U )
//OpCls( MMX, M16, I8_U ) /* PINSRW */
//OpCls( MMX, R32, I8_U ) /* PINSRW */
OpCls( MMX, R32_M16, I8_U ) /* PINSRW */
OpCls( R32_M32, XMM, I8_U )
#if AMD64_SUPPORT
OpCls( R64_M64, XMM, I8_U )
#endif
OpCls( RGT16, MMX, I8_U )
OpCls( RGT16, XMM, I8_U )
OpCls( RGT16_M08,XMM, I8_U )
OpCls( RGT8, R_MS, I )
OpCls( RGT8, R_MS, I8_U )
OpCls( RGT8_MGT8,RGT8, CL )
OpCls( RGT8_MGT8,RGT8, I8_U )
OpCls( XMM, I8_U, I8_U )
//OpCls( XMM, M16, I8_U ) /* PINSRW */
//OpCls( XMM, R32, I8_U ) /* PINSRW */
OpCls( XMM, R32_M16, I8_U ) /* PINSRW */
OpCls( XMM, R32_M08, I8_U ) /* PINSRB */
OpCls( XMM, R32_M32, I8_U ) /* PINSRD */
#if AMD64_SUPPORT
OpCls( XMM, R64_M64, I8_U )
#endif
OpCls( XMM, XMM, I8_U )
OpCls( XMM, XMM_M32 , HID )
OpCls( XMM, XMM_M64 , HID )
OpCls( XMM, XMM_M128, HID )
OpCls( XMM, XMM_M32 , I8_U )
OpCls( XMM, XMM_M64 , I8_U )
OpCls( XMM, XMM_M128, I8_U )
OpCls( XMM, XMM_M128, XMM0 )
#if AVXSUPP
OpCls( M128, YMM, I8_U )
OpCls( XMM, XMM_M128, XMM )
OpCls( XMM, YMM, I8_U )
OpCls( YMM, XMM_M128, I8_U )
OpCls( YMM, YMM_M256, I8_U )
OpCls( YMM, YMM_M256, YMM )
#endif

324
H/parser.h Normal file
View File

@ -0,0 +1,324 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Parser items
*
****************************************************************************/
#ifndef PARSER_H
#define PARSER_H
#include "operands.h"
#include "symbols.h"
#include "token.h"
/* define tokens for SpecialTable (registers, operators, ... ) */
enum special_token {
T_NULL,
#define res(token, string, type, value, bytval, flags, cpu, sflags) T_ ## token ,
#include "special.h"
#undef res
/* define tokens for SpecialTable (directives) */
#define res(token, string, value, bytval, flags, cpu, sflags) T_ ## token ,
#include "directve.h"
#undef res
SPECIAL_LAST
};
/* define tokens for instruction table (InstrTable[] in reswords.c) */
enum instr_token {
INS_FIRST_1 = SPECIAL_LAST - 1, /* to ensure tokens are unique */
#define ins(token, string, opcls, byte1_info,op_dir,rm_info,opcode,rm_byte,cpu,prefix ) T_ ## token ,
#define insx(token, string, opcls, byte1_info,op_dir,rm_info,opcode,rm_byte,cpu,prefix,flgs ) T_ ## token ,
#define insn(tok, suffix, opcls, byte1_info,op_dir,rm_info,opcode,rm_byte,cpu,prefix)
#define insm(tok, suffix, opcls, byte1_info,op_dir,rm_info,opcode,rm_byte,cpu,prefix)
#include "instruct.h"
#undef insm
#undef insn
#undef insx
#undef ins
#if AVXSUPP
#define VEX_START T_VBROADCASTSS /* first VEX encoded item */
#define avxins(token, string, cpu, flgs ) T_V ## token ,
#include "instravx.h"
#undef avxins
#endif
};
/*---------------------------------------------------------------------------*/
/* queue of symbols */
struct symbol_queue {
struct dsym *head;
struct dsym *tail;
};
enum queue_type {
TAB_UNDEF = 0,
TAB_EXT, /* externals (EXTERNDEF, EXTERN, COMM, PROTO ) */
TAB_SEG, /* SEGMENT items */
TAB_GRP, /* GROUP items */
TAB_PROC, /* PROC items */
TAB_ALIAS, /* ALIAS items */
TAB_LAST,
};
/* several lists, see enum queue_type above */
extern struct symbol_queue SymTables[];
/*
values for <rm_info> (3 bits)
000 -> has rm_byte with w-, d- and/or s-bit in opcode
001( no_RM ) -> no rm_byte - may have w-bit
010( no_WDS ) -> has rm_byte, but w-bit, d-bit, s-bit of opcode are absent
011( R_in_OP ) -> no rm_byte, reg field (if any) is included in opcode
*/
enum rm_info {
no_RM = 0x1,
no_WDS = 0x2,
R_in_OP = 0x3,
};
/* values for <allowed_prefix> (3 bits) */
enum allowed_prefix {
// AP_NO_PREFIX= 0x00, /* value 0 means "normal" */
AP_LOCK = 0x01,
AP_REP = 0x02,
AP_REPxx = 0x03,
AP_FWAIT = 0x04,
AP_NO_FWAIT = 0x05
};
/* values for field type in special_item.
* it should match order of T_REGISTER - T_RES_ID in token.h
*/
enum special_type {
RWT_REG = 2, /* same value as for T_REG */
RWT_DIRECTIVE,
RWT_UNARY_OP,
RWT_BINARY_OP,
RWT_STYPE,
RWT_RES_ID
};
// values for sflags if register
enum op1_flags {
SFR_SIZMSK = 0x1F, /* size in bits 0-4 */
SFR_IREG = 0x20,
SFR_SSBASED = 0x40, /* v2.11: added */
};
#if AMD64_SUPPORT
enum rex_bits {
REX_B = 1, /* regno 0-7 <-> 8-15 of ModR/M or SIB base */
REX_X = 2, /* regno 0-7 <-> 8-15 of SIB index */
REX_R = 4, /* regno 0-7 <-> 8-15 of ModR/M REG */
REX_W = 8 /* wide 32 <-> 64 */
};
#endif
/* operand classes. this table is defined in reswords.c.
* index into this array is member opclsidx in instr_item.
* v2.06: data removed from struct instr_item.
*/
struct opnd_class {
enum operand_type opnd_type[2]; /* operands 1 + 2 */
unsigned char opnd_type_3rd; /* operand 3 */
};
/* instr_item is the structure used to store instructions
* in InstrTable (instruct.h).
* Most compilers will use unsigned type for enums, just OW
* allows to use the smallest size possible.
*/
struct instr_item {
//enum operand_type opnd_type[2]; /* operands 1 + 2 */
//unsigned char opnd_type_3rd; /* operand 3 */
unsigned char opclsidx; /* v2.06: index for opnd_clstab */
unsigned char byte1_info; /* flags for 1st byte */
unsigned char
allowed_prefix : 3, /* allowed prefix */
first : 1, /* 1=opcode's first entry */
rm_info : 3, /* info on r/m byte */
opnd_dir : 1; /* operand direction */
unsigned char reserved; /* not used yet */
#ifdef __WATCOMC__
enum cpu_info cpu; /* CPU type */
#else
unsigned short cpu;
#endif
unsigned char opcode; /* opcode byte */
unsigned char rm_byte; /* mod_rm_byte */
};
/* special_item is the structure used to store directives and
* other reserved words in SpecialTable (special.h).
*/
struct special_item {
unsigned value;
unsigned sflags;
#ifdef __WATCOMC__
enum cpu_info cpu; /* CPU type */
#else
uint_16 cpu; /* CPU type */
#endif
uint_8 bytval;
#ifdef __WATCOMC__
enum special_type type;
#else
uint_8 type;
#endif
};
#define GetRegNo( x ) SpecialTable[x].bytval
#define GetSflagsSp( x ) SpecialTable[x].sflags
#define GetValueSp( x ) SpecialTable[x].value
#define GetMemtypeSp( x ) SpecialTable[x].bytval
#define GetCpuSp( x ) SpecialTable[x].cpu
/* values for <value> if type == RWT_DIRECTIVE */
enum directive_flags {
DF_CEXPR = 0x01, /* avoid '<' being used as string delimiter (.IF, ...) */
DF_STRPARM = 0x02, /* directive expects string param(s) (IFB, IFDIF, ...) */
/* enclose strings in <> in macro expansion step */
DF_NOEXPAND = 0x04, /* don't expand params for directive (PURGE, FOR, IFDEF, ...) */
DF_LABEL = 0x08, /* directive requires a label */
DF_NOSTRUC = 0x10, /* directive not allowed inside structs/unions */
DF_NOCONCAT = 0x20, /* don't concat line */
DF_PROC = 0x40, /* directive triggers prologue generation */
DF_STORE = 0x80, /* FASTPASS: directive triggers line store */
DF_CGEN = 0x100 /* directive generates lines */
};
/* values for <bytval> if type == RWT_DIRECTIVE */
#define res(token, function) DRT_ ## token ,
enum directive_type {
#include "dirtype.h"
};
#undef res
#define MAX_OPND 3
struct opnd_item {
enum operand_type type;
union {
struct {
int_32 data32l;
int_32 data32h; /* needed for OP_I48 and OP_I64 */
};
uint_64 data64;
};
struct fixup *InsFixup;
};
/* code_info describes the current instruction. It's the communication
* structure between parser and code generator.
*/
struct code_info {
struct {
enum instr_token ins; /* prefix before instruction, e.g. lock, rep, repnz */
enum assume_segreg RegOverride;/* segment override (0=ES,1=CS,2=SS,3=DS,...) */
#if AMD64_SUPPORT
unsigned char rex;
#endif
unsigned char adrsiz:1; /* address size prefix 0x67 is to be emitted */
unsigned char opsiz:1; /* operand size prefix 0x66 is to be emitted */
} prefix;
const struct instr_item *pinstr; /* current pointer into InstrTable */
enum instr_token token;
enum memtype mem_type; /* byte / word / etc. NOT near/far */
struct opnd_item opnd[MAX_OPND];
unsigned char rm_byte;
unsigned char sib;
unsigned char Ofssize;
unsigned char opc_or;
#if AVXSUPP
unsigned char vexregop; /* in based-1 format (0=empty) */
#endif
union {
unsigned char flags;
struct {
unsigned char iswide:1; /* 0=byte, 1=word/dword/qword */
unsigned char isdirect:1; /* 1=direct addressing mode */
unsigned char isfar:1; /* CALL/JMP far */
unsigned char const_size_fixed:1; /* v2.01 */
#if AMD64_SUPPORT
unsigned char x86hi_used:1; /* AH,BH,CH,DH used */
unsigned char x64lo_used:1; /* SPL,BPL,SIL,DIL used */
#endif
unsigned char undef_sym:1; /* v2.06b: struct member is forward ref */
};
};
};
#define OPND1 0
#define OPND2 1
#define OPND3 2
/* branch instructions are still sorted:
* CALL, JMP, Jcc, J[e|r]CXZ, LOOP, LOOPcc
*/
#define IS_CALL( inst ) ( inst == T_CALL )
#define IS_JMPCALL( inst ) ( inst == T_CALL || inst == T_JMP )
#define IS_JMP( inst ) ( inst >= T_JMP && inst < T_LOOP )
#define IS_JCC( inst ) ( inst > T_JMP && inst < T_JCXZ )
#define IS_BRANCH( inst ) ( inst >= T_CALL && inst < T_LOOP )
#define IS_ANY_BRANCH( inst ) ( inst >= T_CALL && inst <= T_LOOPNZW )
#define IS_XCX_BRANCH( inst ) ( inst >= T_JCXZ && inst <= T_LOOPNZW )
#define IS_OPER_32( s ) ( s->Ofssize ? ( s->prefix.opsiz == FALSE ) : ( s->prefix.opsiz == TRUE ))
/* globals */
//extern struct asym WordSize;
//#define CurrWordSize WordSize.value
extern const struct instr_item InstrTable[]; /* instruction table */
extern const struct special_item SpecialTable[]; /* rest of res words */
extern uint_16 optable_idx[]; /* helper, access thru IndexFromToken() only */
#define IndexFromToken( tok ) optable_idx[ ( tok ) - SPECIAL_LAST ]
extern int SizeFromMemtype( enum memtype, int, struct asym * );
extern ret_code MemtypeFromSize( int, enum memtype * );
extern int SizeFromRegister( int );
extern ret_code GetLangType( int *, struct asm_tok[], enum lang_type * );
extern void sym_add_table( struct symbol_queue *, struct dsym * );
extern void sym_remove_table( struct symbol_queue *, struct dsym * );
extern void sym_ext2int( struct asym * );
extern int OperandSize( enum operand_type, const struct code_info * );
extern void set_frame( const struct asym *sym );
extern void set_frame2( const struct asym *sym );
extern ret_code ParseLine( struct asm_tok[] );
extern void ProcessFile( struct asm_tok[] );
extern void WritePreprocessedLine( const char * );
#endif

215
H/pespec.h Normal file
View File

@ -0,0 +1,215 @@
/* PE definitions
* see also: coffspec.h
*/
#ifndef PE_H
#define PE_H
struct IMAGE_DOS_HEADER {
uint_16 e_magic; // Magic number
uint_16 e_cblp; // Bytes on last page of file
uint_16 e_cp; // Pages in file
uint_16 e_crlc; // Relocations
uint_16 e_cparhdr; // Size of header in paragraphs
uint_16 e_minalloc; // Minimum extra paragraphs needed
uint_16 e_maxalloc; // Maximum extra paragraphs needed
uint_16 e_ss; // Initial (relative) SS value
uint_16 e_sp; // Initial SP value
uint_16 e_csum; // Checksum
uint_16 e_ip; // Initial IP value
uint_16 e_cs; // Initial (relative) CS value
uint_16 e_lfarlc; // File address of relocation table
uint_16 e_ovno; // Overlay number
uint_16 e_res[4]; // Reserved words
uint_16 e_oemid; // OEM identifier (for e_oeminfo)
uint_16 e_oeminfo; // OEM information; e_oemid specific
uint_16 e_res2[10]; // Reserved words
uint_32 e_lfanew; // File address of new exe header
};
#if PE_SUPPORT
struct IMAGE_DATA_DIRECTORY {
uint_32 VirtualAddress;
uint_32 Size;
};
#define IMAGE_DIRECTORY_ENTRY_EXPORT 0
#define IMAGE_DIRECTORY_ENTRY_IMPORT 1
#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
#define IMAGE_DIRECTORY_ENTRY_SECURITY 4
#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5
#define IMAGE_DIRECTORY_ENTRY_DEBUG 6
#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7
#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8
#define IMAGE_DIRECTORY_ENTRY_TLS 9
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11
#define IMAGE_DIRECTORY_ENTRY_IAT 12
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
/* Subsystem values */
#define IMAGE_SUBSYSTEM_UNKNOWN 0 // Unknown subsystem.
#define IMAGE_SUBSYSTEM_NATIVE 1 // Image doesn't require a subsystem.
#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2 // Image runs in the Windows GUI subsystem.
#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3 // Image runs in the Windows character subsystem.
#define IMAGE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem.
#define IMAGE_SUBSYSTEM_POSIX_CUI 7 // image runs in the Posix character subsystem.
#define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8 // image is a native Win9x driver.
#define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9 // Image runs in the Windows CE subsystem.
#define IMAGE_SUBSYSTEM_EFI_APPLICATION 10 //
#define IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
#define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 //
#define IMAGE_SUBSYSTEM_EFI_ROM 13
#define IMAGE_SUBSYSTEM_XBOX 14
struct IMAGE_OPTIONAL_HEADER32 {
uint_16 Magic;
uint_8 MajorLinkerVersion;
uint_8 MinorLinkerVersion;
uint_32 SizeOfCode;
uint_32 SizeOfInitializedData;
uint_32 SizeOfUninitializedData;
uint_32 AddressOfEntryPoint;
uint_32 BaseOfCode;
uint_32 BaseOfData;
// NT additional fields.
uint_32 ImageBase;
uint_32 SectionAlignment;
uint_32 FileAlignment;
uint_16 MajorOperatingSystemVersion;
uint_16 MinorOperatingSystemVersion;
uint_16 MajorImageVersion;
uint_16 MinorImageVersion;
uint_16 MajorSubsystemVersion;
uint_16 MinorSubsystemVersion;
uint_32 Win32VersionValue;
uint_32 SizeOfImage;
uint_32 SizeOfHeaders;
uint_32 CheckSum;
uint_16 Subsystem;
uint_16 DllCharacteristics;
uint_32 SizeOfStackReserve;
uint_32 SizeOfStackCommit;
uint_32 SizeOfHeapReserve;
uint_32 SizeOfHeapCommit;
uint_32 LoaderFlags;
uint_32 NumberOfRvaAndSizes;
struct IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
};
struct IMAGE_PE_HEADER32 {
uint_32 Signature;
struct IMAGE_FILE_HEADER FileHeader;
struct IMAGE_OPTIONAL_HEADER32 OptionalHeader;
};
#if AMD64_SUPPORT
struct IMAGE_OPTIONAL_HEADER64 {
uint_16 Magic;
uint_8 MajorLinkerVersion;
uint_8 MinorLinkerVersion;
uint_32 SizeOfCode;
uint_32 SizeOfInitializedData;
uint_32 SizeOfUninitializedData;
uint_32 AddressOfEntryPoint;
uint_32 BaseOfCode;
uint_64 ImageBase;
uint_32 SectionAlignment;
uint_32 FileAlignment;
uint_16 MajorOperatingSystemVersion;
uint_16 MinorOperatingSystemVersion;
uint_16 MajorImageVersion;
uint_16 MinorImageVersion;
uint_16 MajorSubsystemVersion;
uint_16 MinorSubsystemVersion;
uint_32 Win32VersionValue;
uint_32 SizeOfImage;
uint_32 SizeOfHeaders;
uint_32 CheckSum;
uint_16 Subsystem;
uint_16 DllCharacteristics;
uint_64 SizeOfStackReserve;
uint_64 SizeOfStackCommit;
uint_64 SizeOfHeapReserve;
uint_64 SizeOfHeapCommit;
uint_32 LoaderFlags;
uint_32 NumberOfRvaAndSizes;
struct IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
};
struct IMAGE_PE_HEADER64 {
uint_32 Signature;
struct IMAGE_FILE_HEADER FileHeader;
struct IMAGE_OPTIONAL_HEADER64 OptionalHeader;
};
#endif
/* base relocations */
struct IMAGE_BASE_RELOCATION {
uint_32 VirtualAddress;
uint_32 SizeOfBlock;
};
#define IMAGE_REL_BASED_ABSOLUTE 0 /* relocation is skipped */
#define IMAGE_REL_BASED_HIGH 1 /* high 16-bits of a 32-bit target */
#define IMAGE_REL_BASED_LOW 2 /* low 16-bits of a 32-bit target */
#define IMAGE_REL_BASED_HIGHLOW 3 /* 32-bit target */
#define IMAGE_REL_BASED_HIGHADJ 4 /* 32-bit target; first high 16-bits, then low 16-bits in next slot */
//#define IMAGE_REL_BASED_IA64_IMM64 9 /* ??? */
#define IMAGE_REL_BASED_DIR64 10 /* 64-bit target */
/* PE resource directory structure */
struct IMAGE_RESOURCE_DIRECTORY { /* size 16 */
uint_32 Characteristics;
uint_32 TimeDateStamp;
uint_16 MajorVersion;
uint_16 MinorVersion;
uint_16 NumberOfNamedEntries;
uint_16 NumberOfIdEntries;
};
struct IMAGE_RESOURCE_DIRECTORY_ENTRY { /* size 8 */
union {
struct {
uint_32 NameOffset:31;
uint_32 NameIsString:1; /* is 1 if id is a name */
};
uint_32 Name; /* ID is an offset to an IMAGE_RESOURCE_DIR_STRING_U struct */
uint_16 Id; /* ID is an integer (usually a resource type ) */
};
union {
uint_32 OffsetToData;
struct {
uint_32 OffsetToDirectory:31;
uint_32 DataIsDirectory:1;
};
};
};
struct IMAGE_RESOURCE_DIR_STRING_U {
uint_16 Length;
int_16 NameString[1];
};
struct IMAGE_RESOURCE_DATA_ENTRY {
uint_32 OffsetToData;
uint_32 Size;
uint_32 CodePage;
uint_32 Reserved;
};
#endif
#endif

12
H/posndir.h Normal file
View File

@ -0,0 +1,12 @@
/****************************************************************************
*
* Description: interface posndir.c - handles ORG, ALIGN, EVEN directives
*
****************************************************************************/
#ifndef _POSNDIR_H_
#define _POSNDIR_H_
extern void AlignCurrOffset( int );
#endif

10
H/preproc.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef _PREPROC_H_INCLUDED
#define _PREPROC_H_INCLUDED
/* v2.11: preprocessor functions moved from input.c to preproc.c */
extern int PreprocessLine( char *, struct asm_tok[] );
extern ret_code WriteCodeLabel( char *, struct asm_tok[] );
#endif

64
H/proc.h Normal file
View File

@ -0,0 +1,64 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: interface to PROC.C routines
*
****************************************************************************/
#ifndef _PROC_H_
#define _PROC_H_
extern struct dsym *CurrProc; /* current procedure */
#if AMD64_SUPPORT
extern struct asym *sym_ReservedStack; /* max stack space required by INVOKE */
#endif
/* v2.11: proc status flags */
enum proc_status {
PRST_INSIDE_PROLOGUE = 0x01,
PRST_INSIDE_EPILOGUE = 0x02,
PRST_FPO = 0x04,
PRST_PROLOGUE_NOT_DONE = 0x80,
};
/*---------------------------------------------------------------------------*/
//extern void pushitem( void *, void * );
//extern void *popitem( void * );
extern ret_code ParseProc( struct dsym *, int, struct asm_tok[], bool, enum lang_type );
extern struct asym *CreateProc( struct asym *, const char *, enum sym_state );
extern void DeleteProc( struct dsym * );
extern ret_code CopyPrototype( struct dsym *, struct dsym * );
extern ret_code RetInstr( int, struct asm_tok[], int ); /* handle RET/IRET within procedures */
extern void write_prologue( struct asm_tok[] );
extern void ProcInit( void );
extern void ProcCheckOpen( void );
#endif

57
H/queue.h Normal file
View File

@ -0,0 +1,57 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: interface for queue.c.
* This file is included by globals.h
*
****************************************************************************/
#ifndef QUEUE_H
#define QUEUE_H 1
struct qnode {
void *next;
union {
const void *elmt;
struct asym *sym;
};
};
struct qdesc {
void *head;
void *tail;
};
//extern void QInit( struct qdesc * );
extern void QEnqueue( struct qdesc *, void * );
extern void QAddItem( struct qdesc *, const void * );
//extern void *QDequeue( struct qdesc * );
//extern void QJoinQueue( struct qdesc *dest, struct qdesc *src );
#endif

76
H/reswords.h Normal file
View File

@ -0,0 +1,76 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: interface to instruction hash table.
*
****************************************************************************/
#ifndef _RESWORDS_H_INCLUDED
#define _RESWORDS_H_INCLUDED
enum reservedword_flags {
//RWF_SPECIAL = 1, /* keyword is NO instruction; v2.11: obsolete */
RWF_DISABLED = 1, /* keyword disabled */
RWF_IA32 = 2, /* keyword specific to IA32 mode */
#if AMD64_SUPPORT
RWF_X64 = 4, /* keyword specific to IA32+ mode */
#endif
#if AVXSUPP
RWF_VEX = 8, /* keyword triggers VEX encoding */
#endif
};
/* structure of items in the "reserved names" table ResWordTable[] */
struct ReservedWord {
uint_16 next; /* index next entry (used for hash table) */
uint_8 len; /* length of reserved word, i.e. 'AX' = 2 */
uint_8 flags; /* see enum reservedword_flags */
#if 0 /* __I86__ ( may be activated for JWASMR, see reswords.c) */
const char __based( void ) *name;
#else
const char *name; /* reserved word (char[]) */
#endif
};
extern unsigned FindResWord( const char *, unsigned char );
extern char *GetResWName( unsigned, char * );
extern bool IsKeywordDisabled( const char *, int );
extern void DisableKeyword( unsigned );
#if RENAMEKEY
extern void RenameKeyword( unsigned, const char *, uint_8 );
#endif
#if AMD64_SUPPORT
extern void Set64Bit( bool );
#endif
extern void ResWordsInit( void );
extern void ResWordsFini( void );
#ifdef DEBUG_OUT
extern void DumpResWords( void );
#endif
#endif

37
H/segattr.h Normal file
View File

@ -0,0 +1,37 @@
/* segment attributes. Included by segment.c only */
sitem( "READONLY", 0, INIT_ATTR )
sitem( "BYTE", 0, INIT_ALIGN )
sitem( "WORD", 1, INIT_ALIGN )
sitem( "DWORD", 2, INIT_ALIGN )
sitem( "PARA", 4, INIT_ALIGN )
sitem( "PAGE", 8, INIT_ALIGN )
#if PAGE4K
sitem( "PAGE4K", 12, INIT_ALIGN )
#endif
sitem( "ALIGN", 0, INIT_ALIGN_PARAM )
sitem( "PRIVATE", COMB_INVALID, INIT_COMBINE )
sitem( "PUBLIC", COMB_ADDOFF, INIT_COMBINE )
sitem( "STACK", COMB_STACK, INIT_COMBINE )
sitem( "COMMON", COMB_COMMON, INIT_COMBINE )
sitem( "MEMORY", COMB_ADDOFF, INIT_COMBINE )
sitem( "AT", COMB_INVALID, INIT_COMBINE_AT )
#if COMDATSUPP
sitem( "COMDAT", COMB_INVALID, INIT_COMBINE_COMDAT )
#endif
sitem( "USE16", USE16, INIT_OFSSIZE )
sitem( "USE32", USE32, INIT_OFSSIZE )
#if AMD64_SUPPORT
sitem( "USE64", USE64, INIT_OFSSIZE )
#endif
sitem( "FLAT", USE32, INIT_OFSSIZE_FLAT )
#if COFF_SUPPORT || ELF_SUPPORT
sitem( "INFO", 0, INIT_CHAR_INFO )
sitem( "DISCARD", IMAGE_SCN_MEM_DISCARDABLE >> 24, INIT_CHAR )
sitem( "NOCACHE", IMAGE_SCN_MEM_NOT_CACHED >> 24, INIT_CHAR )
sitem( "NOPAGE", IMAGE_SCN_MEM_NOT_PAGED >> 24, INIT_CHAR )
sitem( "SHARED", IMAGE_SCN_MEM_SHARED >> 24, INIT_CHAR )
sitem( "EXECUTE", IMAGE_SCN_MEM_EXECUTE >> 24, INIT_CHAR )
sitem( "READ", IMAGE_SCN_MEM_READ >> 24, INIT_CHAR )
sitem( "WRITE", IMAGE_SCN_MEM_WRITE >> 24, INIT_CHAR )
sitem( "ALIAS", 0, INIT_ALIAS )
#endif

76
H/segment.h Normal file
View File

@ -0,0 +1,76 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: segment related prototypes & externals
*
****************************************************************************/
#ifndef _SEGMENT_H_
#define _SEGMENT_H_
#define GetSegm( x ) (struct dsym *)x->segment
extern void SetSymSegOfs( struct asym * );
extern int GetSymOfssize( const struct asym * );
/* Get current segment's offset */
extern uint_32 GetCurrOffset( void );
extern ret_code SetCurrOffset( struct dsym *, uint_32, bool, bool );
extern struct asym *CreateIntSegment( const char *, const char *, uint_8, uint_8, bool );
/* get symbol's segment index, from the symbol itself */
extern unsigned GetSegIdx( const struct asym * );
extern void SegmentInit( int ); /* init segments */
extern void SegmentFini( void ); /* exit segments */
extern struct asym *GetGroup( const struct asym * );
extern uint_32 GetCurrSegAlign( void );
extern ret_code SetOfssize( void );
extern enum seg_type TypeFromClassName( const struct dsym *, const struct asym * );
extern void DefineFlatGroup( void );
extern ret_code SegmentModuleExit( void );
extern void DeleteGroup( struct dsym * );
//extern char *GetLname( int );
//extern void FreeLnameQueue( void );
/* simplified segment functions */
enum sim_seg {
SIM_CODE = 0,
SIM_STACK,
SIM_DATA,
SIM_DATA_UN, /* .DATA? */
SIM_FARDATA,
SIM_FARDATA_UN, /* .FARDATA? */
SIM_CONST,
SIM_LAST
};
extern char *SimGetSegName( enum sim_seg );
extern const char *GetCodeClass( void );
extern ret_code ModelSimSegmInit( int type );
extern void ModelSimSegmExit( void );
extern void SetModelDefaultSegNames( void );
#endif

291
H/special.h Normal file
View File

@ -0,0 +1,291 @@
/****************************************************************************
*
* Description: table of non-instruction reserved words:
* - registers,
* - predefined types
* - operators (unary + binary),
* - language types
* for directives see directve.h!
* for instructions see instruct.h!
*
****************************************************************************/
/* v1.96: items needn't be sorted anymore!
* The items are stored in structures of type special_item.
* If an item is inserted, moved or deleted, the project needs
* a full rebuild.
*/
/* field usage:
* type = RWT_ value SpecialTable.type uint_8
* value = flags SpecialTable.value unsigned
* bytval = value SpecialTable.bytval uint_8
* flags = RWF_ flags ResWordTable.flags uint_8
* cpu = cpu flags SpecialTable.cpu uint_16
* sflags = SpecialTable.sflags unsigned
* for registers, the 'value' field contains OP_ flags.
* Since this field has type unsigned, it may be 16-bits wide only.
* This is no problem, since all register-related flags are in the low word.
*/
/* token str type value bytval flags cpu sflags */
/* registers AH-BH must be consecutive, start with AH and end with BH */
res(AL, al, RWT_REG, OP_AL, 0, 0, P_86, 1)
res(CL, cl, RWT_REG, OP_CL, 1, 0, P_86, 1)
res(DL, dl, RWT_REG, OP_R8, 2, 0, P_86, 1)
res(BL, bl, RWT_REG, OP_R8, 3, 0, P_86, 1)
res(AH, ah, RWT_REG, OP_R8, 4, 0, P_86, 1)
res(CH, ch, RWT_REG, OP_R8, 5, 0, P_86, 1)
res(DH, dh, RWT_REG, OP_R8, 6, 0, P_86, 1)
res(BH, bh, RWT_REG, OP_R8, 7, 0, P_86, 1)
res(AX, ax, RWT_REG, OP_AX, 0, 0, P_86, 2)
res(CX, cx, RWT_REG, OP_R16, 1, 0, P_86, 2)
res(DX, dx, RWT_REG, OP_DX, 2, 0, P_86, 2)
res(BX, bx, RWT_REG, OP_R16, 3, 0, P_86, SFR_IREG|2)
res(SP, sp, RWT_REG, OP_R16, 4, 0, P_86, 2)
res(BP, bp, RWT_REG, OP_R16, 5, 0, P_86, SFR_SSBASED|SFR_IREG|2)
res(SI, si, RWT_REG, OP_R16, 6, 0, P_86, SFR_IREG|2)
res(DI, di, RWT_REG, OP_R16, 7, 0, P_86, SFR_IREG|2)
res(EAX, eax, RWT_REG, OP_EAX, 0, 0, P_386, SFR_IREG|4)
res(ECX, ecx, RWT_REG, OP_R32, 1, 0, P_386, SFR_IREG|4)
res(EDX, edx, RWT_REG, OP_R32, 2, 0, P_386, SFR_IREG|4)
res(EBX, ebx, RWT_REG, OP_R32, 3, 0, P_386, SFR_IREG|4)
res(ESP, esp, RWT_REG, OP_R32, 4, 0, P_386, SFR_SSBASED|SFR_IREG|4)
res(EBP, ebp, RWT_REG, OP_R32, 5, 0, P_386, SFR_SSBASED|SFR_IREG|4)
res(ESI, esi, RWT_REG, OP_R32, 6, 0, P_386, SFR_IREG|4)
res(EDI, edi, RWT_REG, OP_R32, 7, 0, P_386, SFR_IREG|4)
/* registers ES-GS must be consecutive */
res(ES, es, RWT_REG, OP_SR86, 0, 0, P_86, 0)
res(CS, cs, RWT_REG, OP_SR86, 1, 0, P_86, 0)
res(SS, ss, RWT_REG, OP_SR86, 2, 0, P_86, 0)
res(DS, ds, RWT_REG, OP_SR86, 3, 0, P_86, 0)
res(FS, fs, RWT_REG, OP_SR386, 4, 0, P_386, 0)
res(GS, gs, RWT_REG, OP_SR386, 5, 0, P_386, 0)
res(ST, st, RWT_REG, OP_ST, 0, 0, P_87, 10)
res(MM0, mm0, RWT_REG, OP_MMX, 0, 0, P_MMX, 8)
res(MM1, mm1, RWT_REG, OP_MMX, 1, 0, P_MMX, 8)
res(MM2, mm2, RWT_REG, OP_MMX, 2, 0, P_MMX, 8)
res(MM3, mm3, RWT_REG, OP_MMX, 3, 0, P_MMX, 8)
res(MM4, mm4, RWT_REG, OP_MMX, 4, 0, P_MMX, 8)
res(MM5, mm5, RWT_REG, OP_MMX, 5, 0, P_MMX, 8)
res(MM6, mm6, RWT_REG, OP_MMX, 6, 0, P_MMX, 8)
res(MM7, mm7, RWT_REG, OP_MMX, 7, 0, P_MMX, 8)
res(XMM0, xmm0, RWT_REG, OP_XMM, 0, 0, P_SSE1, 16)
res(XMM1, xmm1, RWT_REG, OP_XMM, 1, 0, P_SSE1, 16)
res(XMM2, xmm2, RWT_REG, OP_XMM, 2, 0, P_SSE1, 16)
res(XMM3, xmm3, RWT_REG, OP_XMM, 3, 0, P_SSE1, 16)
res(XMM4, xmm4, RWT_REG, OP_XMM, 4, 0, P_SSE1, 16)
res(XMM5, xmm5, RWT_REG, OP_XMM, 5, 0, P_SSE1, 16)
res(XMM6, xmm6, RWT_REG, OP_XMM, 6, 0, P_SSE1, 16)
res(XMM7, xmm7, RWT_REG, OP_XMM, 7, 0, P_SSE1, 16)
#if AVXSUPP
res(YMM0, ymm0, RWT_REG, OP_YMM, 0, 0, P_AVX, 32)
res(YMM1, ymm1, RWT_REG, OP_YMM, 1, 0, P_AVX, 32)
res(YMM2, ymm2, RWT_REG, OP_YMM, 2, 0, P_AVX, 32)
res(YMM3, ymm3, RWT_REG, OP_YMM, 3, 0, P_AVX, 32)
res(YMM4, ymm4, RWT_REG, OP_YMM, 4, 0, P_AVX, 32)
res(YMM5, ymm5, RWT_REG, OP_YMM, 5, 0, P_AVX, 32)
res(YMM6, ymm6, RWT_REG, OP_YMM, 6, 0, P_AVX, 32)
res(YMM7, ymm7, RWT_REG, OP_YMM, 7, 0, P_AVX, 32)
#endif
res(CR0, cr0, RWT_REG, OP_RSPEC, 0, 0, P_386, 0)
res(CR2, cr2, RWT_REG, OP_RSPEC, 2, 0, P_386, 0)
res(CR3, cr3, RWT_REG, OP_RSPEC, 3, 0, P_386, 0)
res(CR4, cr4, RWT_REG, OP_RSPEC, 4, 0, P_586, 0)
res(DR0, dr0, RWT_REG, OP_RSPEC, 0|0x10, 0, P_386, 0)
res(DR1, dr1, RWT_REG, OP_RSPEC, 1|0x10, 0, P_386, 0)
res(DR2, dr2, RWT_REG, OP_RSPEC, 2|0x10, 0, P_386, 0)
res(DR3, dr3, RWT_REG, OP_RSPEC, 3|0x10, 0, P_386, 0)
res(DR6, dr6, RWT_REG, OP_RSPEC, 6|0x10, 0, P_386, 0)
res(DR7, dr7, RWT_REG, OP_RSPEC, 7|0x10, 0, P_386, 0)
/* v2.11: add RWF_IA32 to TRx registers */
res(TR3, tr3, RWT_REG, OP_RSPEC, 3|0x20,RWF_IA32,P_486, 0)
res(TR4, tr4, RWT_REG, OP_RSPEC, 4|0x20,RWF_IA32,P_486, 0)
res(TR5, tr5, RWT_REG, OP_RSPEC, 5|0x20,RWF_IA32,P_486, 0)
res(TR6, tr6, RWT_REG, OP_RSPEC, 6|0x20,RWF_IA32,P_386, 0)
res(TR7, tr7, RWT_REG, OP_RSPEC, 7|0x20,RWF_IA32,P_386, 0)
#if AMD64_SUPPORT
/* for simplicity, all x64 reserved words must be consecutive
* ( see Set64Bit() in parser.c ).
*/
res(SPL, spl, RWT_REG, OP_R8, 4, RWF_X64, P_64, 1)
res(BPL, bpl, RWT_REG, OP_R8, 5, RWF_X64, P_64, 1)
res(SIL, sil, RWT_REG, OP_R8, 6, RWF_X64, P_64, 1)
res(DIL, dil, RWT_REG, OP_R8, 7, RWF_X64, P_64, 1)
res(R8B, r8b, RWT_REG, OP_R8, 8, RWF_X64, P_64, 1)
res(R9B, r9b, RWT_REG, OP_R8, 9, RWF_X64, P_64, 1)
res(R10B, r10b, RWT_REG, OP_R8, 10, RWF_X64, P_64, 1)
res(R11B, r11b, RWT_REG, OP_R8, 11, RWF_X64, P_64, 1)
res(R12B, r12b, RWT_REG, OP_R8, 12, RWF_X64, P_64, 1)
res(R13B, r13b, RWT_REG, OP_R8, 13, RWF_X64, P_64, 1)
res(R14B, r14b, RWT_REG, OP_R8, 14, RWF_X64, P_64, 1)
res(R15B, r15b, RWT_REG, OP_R8, 15, RWF_X64, P_64, 1)
res(R8W, r8w, RWT_REG, OP_R16, 8, RWF_X64, P_64, 2)
res(R9W, r9w, RWT_REG, OP_R16, 9, RWF_X64, P_64, 2)
res(R10W, r10w, RWT_REG, OP_R16, 10, RWF_X64, P_64, 2)
res(R11W, r11w, RWT_REG, OP_R16, 11, RWF_X64, P_64, 2)
res(R12W, r12w, RWT_REG, OP_R16, 12, RWF_X64, P_64, 2)
res(R13W, r13w, RWT_REG, OP_R16, 13, RWF_X64, P_64, 2)
res(R14W, r14w, RWT_REG, OP_R16, 14, RWF_X64, P_64, 2)
res(R15W, r15w, RWT_REG, OP_R16, 15, RWF_X64, P_64, 2)
res(R8D, r8d, RWT_REG, OP_R32, 8, RWF_X64, P_64, SFR_IREG|4)
res(R9D, r9d, RWT_REG, OP_R32, 9, RWF_X64, P_64, SFR_IREG|4)
res(R10D, r10d, RWT_REG, OP_R32, 10, RWF_X64, P_64, SFR_IREG|4)
res(R11D, r11d, RWT_REG, OP_R32, 11, RWF_X64, P_64, SFR_IREG|4)
res(R12D, r12d, RWT_REG, OP_R32, 12, RWF_X64, P_64, SFR_IREG|4)
res(R13D, r13d, RWT_REG, OP_R32, 13, RWF_X64, P_64, SFR_IREG|4)
res(R14D, r14d, RWT_REG, OP_R32, 14, RWF_X64, P_64, SFR_IREG|4)
res(R15D, r15d, RWT_REG, OP_R32, 15, RWF_X64, P_64, SFR_IREG|4)
res(RAX, rax, RWT_REG, OP_RAX, 0, RWF_X64, P_64, SFR_IREG|8)
res(RCX, rcx, RWT_REG, OP_R64, 1, RWF_X64, P_64, SFR_IREG|8)
res(RDX, rdx, RWT_REG, OP_R64, 2, RWF_X64, P_64, SFR_IREG|8)
res(RBX, rbx, RWT_REG, OP_R64, 3, RWF_X64, P_64, SFR_IREG|8)
res(RSP, rsp, RWT_REG, OP_R64, 4, RWF_X64, P_64, SFR_SSBASED|SFR_IREG|8)
res(RBP, rbp, RWT_REG, OP_R64, 5, RWF_X64, P_64, SFR_SSBASED|SFR_IREG|8)
res(RSI, rsi, RWT_REG, OP_R64, 6, RWF_X64, P_64, SFR_IREG|8)
res(RDI, rdi, RWT_REG, OP_R64, 7, RWF_X64, P_64, SFR_IREG|8)
res(R8, r8, RWT_REG, OP_R64, 8, RWF_X64, P_64, SFR_IREG|8)
res(R9, r9, RWT_REG, OP_R64, 9, RWF_X64, P_64, SFR_IREG|8)
res(R10, r10, RWT_REG, OP_R64, 10, RWF_X64, P_64, SFR_IREG|8)
res(R11, r11, RWT_REG, OP_R64, 11, RWF_X64, P_64, SFR_IREG|8)
res(R12, r12, RWT_REG, OP_R64, 12, RWF_X64, P_64, SFR_IREG|8)
res(R13, r13, RWT_REG, OP_R64, 13, RWF_X64, P_64, SFR_IREG|8)
res(R14, r14, RWT_REG, OP_R64, 14, RWF_X64, P_64, SFR_IREG|8)
res(R15, r15, RWT_REG, OP_R64, 15, RWF_X64, P_64, SFR_IREG|8)
res(XMM8, xmm8, RWT_REG, OP_XMM, 8, RWF_X64, P_64, 16)
res(XMM9, xmm9, RWT_REG, OP_XMM, 9, RWF_X64, P_64, 16)
res(XMM10,xmm10,RWT_REG, OP_XMM, 10, RWF_X64, P_64, 16)
res(XMM11,xmm11,RWT_REG, OP_XMM, 11, RWF_X64, P_64, 16)
res(XMM12,xmm12,RWT_REG, OP_XMM, 12, RWF_X64, P_64, 16)
res(XMM13,xmm13,RWT_REG, OP_XMM, 13, RWF_X64, P_64, 16)
res(XMM14,xmm14,RWT_REG, OP_XMM, 14, RWF_X64, P_64, 16)
res(XMM15,xmm15,RWT_REG, OP_XMM, 15, RWF_X64, P_64, 16)
#if AVXSUPP
res(YMM8, ymm8, RWT_REG, OP_YMM, 8, RWF_X64, P_AVX|P_64, 32)
res(YMM9, ymm9, RWT_REG, OP_YMM, 9, RWF_X64, P_AVX|P_64, 32)
res(YMM10,ymm10,RWT_REG, OP_YMM, 10, RWF_X64, P_AVX|P_64, 32)
res(YMM11,ymm11,RWT_REG, OP_YMM, 11, RWF_X64, P_AVX|P_64, 32)
res(YMM12,ymm12,RWT_REG, OP_YMM, 12, RWF_X64, P_AVX|P_64, 32)
res(YMM13,ymm13,RWT_REG, OP_YMM, 13, RWF_X64, P_AVX|P_64, 32)
res(YMM14,ymm14,RWT_REG, OP_YMM, 14, RWF_X64, P_AVX|P_64, 32)
res(YMM15,ymm15,RWT_REG, OP_YMM, 15, RWF_X64, P_AVX|P_64, 32)
#endif
res(CR8, cr8, RWT_REG, OP_RSPEC, 8, RWF_X64, P_64, 0)
#endif
/* predefined types. BYTE must be first! */
/* token str type value bytval flags cpu sflags */
res(BYTE, byte, RWT_STYPE, 0, MT_BYTE, 0, P_86, USE_EMPTY)
res(SBYTE, sbyte, RWT_STYPE, 0, MT_SBYTE, 0, P_86, USE_EMPTY)
res(WORD, word, RWT_STYPE, 0, MT_WORD, 0, P_86, USE_EMPTY)
res(SWORD, sword, RWT_STYPE, 0, MT_SWORD, 0, P_86, USE_EMPTY)
res(DWORD, dword, RWT_STYPE, 0, MT_DWORD, 0, P_86, USE_EMPTY)
res(SDWORD, sdword, RWT_STYPE, 0, MT_SDWORD, 0, P_86, USE_EMPTY)
res(REAL4, real4, RWT_STYPE, 0, MT_REAL4, 0, P_86, USE_EMPTY)
res(FWORD, fword, RWT_STYPE, 0, MT_FWORD, 0, P_86, USE_EMPTY)
res(QWORD, qword, RWT_STYPE, 0, MT_QWORD, 0, P_86, USE_EMPTY)
res(SQWORD, sqword, RWT_STYPE, 0, MT_SQWORD, 0, P_86, USE_EMPTY)
res(REAL8, real8, RWT_STYPE, 0, MT_REAL8, 0, P_86, USE_EMPTY)
res(TBYTE, tbyte, RWT_STYPE, 0, MT_TBYTE, 0, P_86, USE_EMPTY)
res(REAL10, real10, RWT_STYPE, 0, MT_REAL10, 0, P_86, USE_EMPTY)
res(OWORD, oword, RWT_STYPE, 0, MT_OWORD, 0, P_86, USE_EMPTY)
#if AVXSUPP
res(YMMWORD,ymmword, RWT_STYPE, 0, MT_YMMWORD, 0, P_AVX, USE_EMPTY)
#endif
/* NEAR must be first, FAR32 must be last, all contiguous */
res(NEAR, near, RWT_STYPE, 0, MT_NEAR, 0, P_86, USE_EMPTY)
res(FAR, far, RWT_STYPE, 0, MT_FAR, 0, P_86, USE_EMPTY)
res(NEAR16, near16, RWT_STYPE, 0, MT_NEAR, 0, P_386, USE16)
res(NEAR32, near32, RWT_STYPE, 0, MT_NEAR, 0, P_386, USE32)
res(FAR16, far16, RWT_STYPE, 0, MT_FAR, 0, P_386, USE16)
res(FAR32, far32, RWT_STYPE, 0, MT_FAR, 0, P_386, USE32)
#if XMMWORD
res(MMWORD, mmword, RWT_STYPE, 0, MT_QWORD, 0, P_586|P_MMX, USE_EMPTY)
res(XMMWORD,xmmword, RWT_STYPE, 0, MT_OWORD, 0, P_686|P_SSE1, USE_EMPTY)
#endif
/* unary operators. bytval contains priority */
/* token str type value bytval flags cpu sflags */
res(DOT_TYPE, .type, RWT_UNARY_OP, AT_ALL, 14, 0, P_86, UOT_DOT_TYPE )
res(HIGH, high, RWT_UNARY_OP, AT_TLN, 6, 0, P_86, UOT_HIGH )
#if LOHI32
res(HIGH32, high32, RWT_UNARY_OP, AT_CONST | AT_FLOAT, 6, 0, P_86, UOT_HIGH32 )
#endif
res(HIGHWORD, highword, RWT_UNARY_OP, AT_CONST, 6, 0, P_86, UOT_HIGHWORD )
#if IMAGERELSUPP
/* v2.10: changed AT_TLN to AT_LABEL */
//res(IMAGEREL, imagerel, RWT_UNARY_OP, AT_TLN, 5, 0, P_86, UOT_IMAGEREL )
res(IMAGEREL, imagerel, RWT_UNARY_OP, AT_LABEL, 5, 0, P_86, UOT_IMAGEREL )
#endif
res(LENGTH, length, RWT_UNARY_OP, AT_LF, 3, 0, P_86, UOT_LENGTH )
res(LENGTHOF, lengthof, RWT_UNARY_OP, AT_LF, 3, 0, P_86, UOT_LENGTHOF )
res(LOW, low, RWT_UNARY_OP, AT_TLN, 6, 0, P_86, UOT_LOW )
#if LOHI32
res(LOW32, low32, RWT_UNARY_OP, AT_TLN | AT_FLOAT, 6, 0, P_86, UOT_LOW32 )
#endif
res(LOWWORD, lowword, RWT_UNARY_OP, AT_TLN, 6, 0, P_86, UOT_LOWWORD )
res(LROFFSET, lroffset, RWT_UNARY_OP, AT_LFN, 5, 0, P_86, UOT_LROFFSET )
res(MASK, mask, RWT_UNARY_OP, AT_TBF, 3, 0, P_86, UOT_MASK )
res(OFFSET, offset, RWT_UNARY_OP, AT_TLFN, 5, 0, P_86, UOT_OFFSET )
res(OPATTR, opattr, RWT_UNARY_OP, AT_ALL, 14, 0, P_86, UOT_OPATTR )
#if SECTIONRELSUPP
res(SECTIONREL, sectionrel, RWT_UNARY_OP, AT_LABEL, 5, 0, P_86, UOT_SECTIONREL)
#endif
res(SEG, seg, RWT_UNARY_OP, AT_LABEL, 5, 0, P_86, UOT_SEG )
res(SHORT, short, RWT_UNARY_OP, AT_LABEL, 14, 0, P_86, UOT_SHORT )
res(SIZE, size, RWT_UNARY_OP, AT_TLF, 3, 0, P_86, UOT_SIZE )
res(SIZEOF, sizeof, RWT_UNARY_OP, AT_TLF, 3, 0, P_86, UOT_SIZEOF )
res(THIS, this, RWT_UNARY_OP, AT_TYPE, 5, 0, P_86, UOT_THIS )
res(TYPE, type, RWT_UNARY_OP, AT_ALL, 5, 0, P_86, UOT_TYPE )
res(WIDTH, width, RWT_UNARY_OP, AT_TBF, 3, 0, P_86, UOT_WIDTH )
/* binary operators. bytval contains priority */
/* token str type value bytval flags cpu sflags */
res(EQ, eq, RWT_BINARY_OP, 0, 10, 0, P_86, 0)
res(NE, ne, RWT_BINARY_OP, 0, 10, 0, P_86, 0)
res(GE, ge, RWT_BINARY_OP, 0, 10, 0, P_86, 0)
res(GT, gt, RWT_BINARY_OP, 0, 10, 0, P_86, 0)
res(LE, le, RWT_BINARY_OP, 0, 10, 0, P_86, 0)
res(LT, lt, RWT_BINARY_OP, 0, 10, 0, P_86, 0)
res(MOD, mod, RWT_BINARY_OP, 0, 8, 0, P_86, 0)
res(PTR, ptr, RWT_BINARY_OP, 0, 4, 0, P_86, 0)
/* DUP is also a binary operator, but must be handled differently. */
res(DUP, dup, RWT_RES_ID, 0, 0, 0, P_86, 0)
res(ADDR, addr, RWT_RES_ID, 0, 0, 0, P_86, 0)
res(FLAT, flat, RWT_RES_ID, 0, 0, 0, P_86, 0)
res(VARARG, vararg,RWT_RES_ID, 0, 0, 0, P_86, 0)
#if AMD64_SUPPORT
res(FRAME, frame, RWT_RES_ID, 0, 0, RWF_X64, P_64, 0)
#endif
/* languages, must be in this order! */
/* token str type value bytval flags cpu sflags */
res(C, c, RWT_RES_ID, 0, LANG_C, 0, P_86, 0)
res(SYSCALL, syscall, RWT_RES_ID, 0, LANG_SYSCALL, 0, P_86, 0)
res(STDCALL, stdcall, RWT_RES_ID, 0, LANG_STDCALL, 0, P_86, 0)
res(PASCAL, pascal, RWT_RES_ID, 0, LANG_PASCAL, 0, P_86, 0)
res(FORTRAN, fortran, RWT_RES_ID, 0, LANG_FORTRAN, 0, P_86, 0)
res(BASIC, basic, RWT_RES_ID, 0, LANG_BASIC, 0, P_86, 0)
res(FASTCALL, fastcall, RWT_RES_ID, 0, LANG_FASTCALL, 0, P_86, 0)

537
H/symbols.h Normal file
View File

@ -0,0 +1,537 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: defines symbol structures asym and dsym,
* and prototypes of functions in symbols.c.
* This file is included by parser.h.
*
****************************************************************************/
#ifndef _SYMBOLS_H_
#define _SYMBOLS_H_
/*
* SYM_LIB - library paths are no longer added to the symbol table
* SYM_LNAME has been removed. It was used for the null-entry in the LNAME table only
* v2.01: SYM_PROC has been removed.
* v2.01: SYM_LIB has been removed.
*/
enum sym_state {
SYM_UNDEFINED,
SYM_INTERNAL, /* 1 internal label */
SYM_EXTERNAL, /* 2 external */
SYM_SEG, /* 3 segment */
SYM_GRP, /* 4 group */
SYM_STACK, /* 5 stack variable - in local symbol tables only */
SYM_STRUCT_FIELD, /* 6 struct member - not in symbol table - except record fields */
SYM_TYPE, /* 7 structure, union, typedef, record */
SYM_ALIAS, /* 8 alias name */
SYM_MACRO, /* 9 macro */
SYM_TMACRO, /* 10 text macro */
SYM_CLASS_LNAME /* 11 lname item for segm class - not in symbol table */
};
/* v2.04: MT_SHORT removed */
/* v2.07: MT_ABS (0xC2) removed */
enum memtype {
MT_SIZE_MASK = 0x1F, /* if MT_SPECIAL==0 then bits 0-4 = size - 1 */
MT_FLOAT = 0x20, /* bit 5=1 */
MT_SIGNED = 0x40, /* bit 6=1 */
MT_BYTE = 1 - 1,
MT_SBYTE = MT_BYTE | MT_SIGNED,
MT_WORD = 2 - 1,
MT_SWORD = MT_WORD | MT_SIGNED,
MT_DWORD = 4 - 1,
MT_SDWORD= MT_DWORD | MT_SIGNED,
MT_REAL4 = MT_DWORD | MT_FLOAT,
MT_FWORD = 6 - 1,
MT_QWORD = 8 - 1,
MT_SQWORD= MT_QWORD | MT_SIGNED,
MT_REAL8 = MT_QWORD | MT_FLOAT,
MT_TBYTE = 10 - 1,
MT_REAL10= MT_TBYTE | MT_FLOAT,
MT_OWORD = 16 - 1,
#if AVXSUPP
MT_YMMWORD = 32 - 1,
#endif
MT_PROC = 0x80, /* symbol is a TYPEDEF PROTO, state=SYM_TYPE, typekind=TYPE_TYPEDEF, prototype is stored in target_type */
MT_NEAR = 0x81,
MT_FAR = 0x82,
MT_EMPTY = 0xC0,
MT_BITS = 0xC1, /* record field */
MT_PTR = 0xC3, /* v2.05: changed, old value 0x83 */
MT_TYPE = 0xC4, /* symbol has user-defined type (struct, union, record) */
MT_SPECIAL = 0x80, /* bit 7 */
MT_SPECIAL_MASK = 0xC0, /* bit 6+7 */
MT_ADDRESS = 0x80, /* bit 7=1, bit 6 = 0 */
};
#define IS_SIGNED(x) (((x) & MT_SPECIAL_MASK) == MT_SIGNED)
/* symbols can be
* - "labels" (data or code, internal, external, stack)
* mem_type is MT_BYTE..MT_OWORD, MT_NEAR, MT_FAR, MT_PTR
* - constants (EQU) or assembly time variables ("="),
* mem_type "usually" is MT_EMPTY.
* - types (STRUCT, UNION, TYPEDEF, RECORD), mem_type = MT_TYPE
* - preprocessor items (macros and text macros), which have no
* mem_type (MT_EMPTY).
*/
struct macro_instance;
typedef void (* internal_func)( struct asym *, void * );
struct debug_info {
uint_32 start_line; /* procs's start line */
uint_32 end_line; /* procs's last line */
uint_32 ln_fileofs; /* file offset to line numbers */
uint_16 line_numbers;/* line numbers in function */
uint_16 file; /* proc's start file */
unsigned next_proc; /* index next proc */
unsigned next_file; /* index next file */
};
struct asym {
/* v2.11: name changed from 'next' to 'nextitem' */
struct asym *nextitem; /* next symbol in hash line */
char *name; /* symbol name */
union {
int_32 offset; /* used by SYM_INTERNAL (labels), SYM_TYPE, SYM_STACK, v2.11: SYM_SEG */
int_32 value; /* used by SYM_INTERNAL (equates) */
uint_32 uvalue; /* v2.01: equates (they are 33-bit!) */
char *string_ptr;/* used by SYM_TMACRO */
struct asym *substitute;/* v2.04b: used by SYM_ALIAS */
/* func_ptr: used by SYM_MACRO if predefined==1 */
ret_code (* func_ptr)( struct macro_instance *, char *, struct asm_tok * );
//int_32 max_offset; /* used by SYM_SEG; v2.11 field moved */
int_32 class_lname_idx;/* used by SYM_CLASS_LNAME */
};
struct asym *segment; /* used by SYM_INTERNAL, SYM_EXTERNAL */
enum sym_state state;
enum memtype mem_type;
unsigned char used:1, /* symbol has been referenced */
isdefined:1, /* symbol is "defined" in this pass */
scoped:1, /* symbol is local label or SYM_STACK */
/* v2.07: removed */
//isglobal:1, /* symbol has been added to the globals queue */
#if DLLIMPORT
iat_used:1, /* v2.07: IAT entry of symbol used (SYM_EXTERNAL + isproc==1 only) */
#endif
isequate:1, /* symbol has been defined with EQU */
predefined:1, /* symbol is predefined */
variable:1, /* symbol is variable (defined by '=' directive) */
ispublic:1; /* symbol has been added to the publics queue */
unsigned char list:1, /* symbol is to be listed */
isarray:1, /* symbol is an array (total_length is valid) */
isdata:1, /* field first_size is valid */
isproc:1, /* symbol is PROC or PROTO; has proc_info extension */
#if FASTPASS
issaved:1, /* assembly-time variables only: symbol has been saved */
#endif
//#if FASTMEM==0 /* v2.09: obsolete */
// isstatic:1, /* symbol stored in static memory */
//#endif
fwdref:1, /* symbol was forward referenced */
included:1; /* COFF: static symbol added to public queue. ELF:symbol added to symbol table (SYM_INTERNAL) */
union {
/* for SYM_INTERNAL (data labels, memtype != NEAR|FAR), SYM_STRUCT_FIELD */
uint_32 first_size; /* size of 1st initializer's dimension in bytes */
/* for SYM_INTERNAL (memtype == NEAR|FAR),
* SYM_GRP (Ofssize),
* SYM_EXTERNAL (Ofssize, comm, weak, isfar, is_ptr, ptr_memtype),
* SYM_STACK (Ofssize, isfar, is_vararg, is_ptr, ptr_memtype ),
* SYM_TYPE, TYPE_TYPEDEF (Ofssize, isfar, is_ptr, ptr_memtype )
*/
struct {
unsigned char Ofssize; /* offset size (USE16, USE32) */
unsigned char is_ptr; /* PTR indirection */
union {
unsigned char ptr_memtype;/* pointer target type */
unsigned char asmpass; /* SYM_INTERNAL (mem_type NEAR|FAR) */
};
unsigned char seg_ofssize:2; /* SYM_EXTERNAL only */
unsigned char iscomm:1; /* is communal */
unsigned char weak:1; /* 1 if an unused "externdef" */
unsigned char isfar:1; /* SYM_EXTERNAL, SYM_TYPE, SYM_STACK */
unsigned char is_vararg:1;/* SYM_STACK, VARARG param */
};
/* for SYM_MACRO */
struct {
unsigned char mac_vararg:1,/* accept additional params */
isfunc:1, /* it's a macro function */
#if MACROLABEL
label:1, /* macro is "label-aware" */
#endif
#if VARARGML
mac_multiline:1, /* v2.11: vararg arguments may be on multiple lines */
#endif
purged:1; /* macro has been PURGEd */
};
};
union {
/* for SYM_INTERNAL (data labels only), SYM_STRUCT_FIELD */
uint_32 first_length; /* size of 1st initializer's dimension in item units */
/* SYM_TYPE (TYPEKIND_STRUCT or TYPEKIND_UNION) */
uint_32 max_mbr_size; /* max size members */
/* SYM_STACK, SYM_TYPE (TYPEKIND_TYPEDEF), SYM_EXTERNAL, SYM_INTERNAL (code labels) */
struct asym *target_type; /* set if ptr_memtype is MT_TYPE */
/* SYM_TMACRO (if it's a register variable for FASTCALL) */
uint_16 regist[2];
};
union {
/* for SYM_INTERNAL, SYM_STRUCT_FIELD,
* SYM_TYPE, SYM_STACK,
* SYM_EXTERNAL (comm=1)
* SYM_TMACRO: size of buffer allocated for the text in string_ptr
*/
uint_32 total_size; /* total number of bytes (sizeof) */
/* for SYM_INTERNAL, isequate=1 (numeric equates) */
int_32 value3264; /* high bits for equates */
#if DLLIMPORT
struct dll_desc *dll; /* SYM_EXTERNAL (isproc=1) */
#endif
/* for SYM_SEG; v2.11: moved here to make segment's offset field contain "local start offset" (=0) */
int_32 max_offset;
};
union {
/* SYM_INTERNAL, SYM_STRUCT_FIELD,
* SYM_STACK, SYM_EXTERNAL (comm==1):
* total number of elements (LENGTHOF)
*/
uint_32 total_length;
struct asym *altname; /* SYM_EXTERNAL (comm==0): alternative name */
struct debug_info *debuginfo;/* SYM_INTERNAL (isproc==1): debug info (COFF) */
internal_func sfunc_ptr; /* SYM_INTERNAL+predefined */
struct { /* SYM_TYPE */
/* codeview type index (used after assembly steps)
* v2.04: moved from first_length, were it didn't work anymore
* since the addition of field max_mbr_size.
*/
uint_16 cvtyperef;
uint_8 typekind;
};
};
#if (MAX_ID_LEN <= 255)
uint_8 name_size;
#else
uint_16 name_size;
#endif
enum lang_type langtype;
#ifdef DEBUG_OUT
union {
struct asym *type; /* set if memtype is MT_TYPE */
struct dsym *ttype; /* for easier debugging */
};
#else
struct asym *type; /* set if memtype is MT_TYPE */
#endif
union {
/* SYM_INTERNAL, SYM_UNDEFINED, SYM_EXTERNAL: backpatching fixup */
struct fixup *bp_fixup;
/* for SYM_EXTERNAL */
unsigned ext_idx; /* table index ( for coff and elf ) */
struct {
/* omf indices are 16-bit only! */
uint_16 ext_idx1; /* omf: (external definition) index */
uint_16 ext_idx2; /* omf: (external definition) index for weak external */
};
};
};
/*---------------------------------------------------------------------------*/
/* Structures for grpdef, segdef, externdef, pubdef, included library, */
/* procedure and symbolic integer constants. */
/*---------------------------------------------------------------------------*/
struct seg_item {
struct seg_item *next;
struct dsym *seg;
};
struct grp_info {
struct seg_item *seglist; /* list of segments in the group */
int grp_idx; /* its group index (OMF) */
int lname_idx; /* LNAME index (OMF only) */
unsigned numseg; /* OMF: number of segments in the group */
};
typedef uint_8 * (* FlushSegFunc)( struct dsym *, uint_8 *, unsigned, void * );
struct seg_info {
struct asym *group; /* segment's group or NULL */
uint_32 start_loc; /* starting offset of current ledata or lidata */
union {
uint_32 current_loc; /* current offset in current ledata or lidata */
uint_32 reloc_offset; /* ELF: reloc file offset */
uint_32 start_offset; /* BIN: start offset in group */
};
#ifdef __I86__
uint_8 huge *CodeBuffer;
#else
uint_8 *CodeBuffer;
#endif
uint_32 bytes_written; /* initialized bytes in segment */
union {
struct asym *label_list; /* linked list of labels in this seg */
FlushSegFunc flushfunc; /* to flush the segment buffer */
};
struct {
struct fixup *head; /* fixup queue head */
struct fixup *tail; /* fixup queue tail */
} FixupList;
union {
void *LinnumQueue; /* for COFF line numbers */
uint_32 fileoffset; /* used by BIN + ELF */
uint_32 num_linnums; /* used by COFF (after LinnumQueue has been read) */
};
uint_32 num_relocs; /* used by COFF/ELF */
unsigned seg_idx; /* segment #; v2.12: changed from short to unsigned */
enum seg_type segtype; /* segment's type (code, data, ...) */
int lname_idx; /* segment's name LNAME index (OMF only) */
struct asym *clsym; /* segment's class name (stored in an asym item) */
union {
uint_16 abs_frame; /* ABS seg, frame number (OMF,BIN) */
#if COMDATSUPP
uint_16 comdat_number; /* associated COMDAT segno (COFF) */
uint_16 comdat_idx; /* lname index of COMDAT symbol (OMF) */
#endif
};
union {
uint_32 abs_offset; /* ABS seg, offset (OMF only) */
char *aliasname; /* ALIAS name (COFF/ELF only) */
};
unsigned char Ofssize; /* segment's offset size */
unsigned char characteristics;/* used by COFF/ELF/PE */
unsigned char alignment; /* is value 2^x */
unsigned char readonly:1; /* if segment is readonly */
unsigned char info:1; /* if segment is info only (COFF/ELF) */
unsigned char force32:1; /* force 32bit segdef (OMF only) */
unsigned char data_in_code:1; /* data items in code segm (OMF only) */
unsigned char internal:1; /* internal segment with private buffer */
unsigned char written:1; /* code/data just written */
unsigned char linnum_init:1; /* v2.10: linnum data emitted for segment? */
unsigned char combine:3; /* combine type, see omfspec.h */
#if COMDATSUPP
unsigned char comdat_selection:3; /* if > 0, it's a COMDAT (COFF/OMF) */
#endif
};
#define MAX_SEGALIGNMENT 0xFF
/* PROC item */
struct proc_info {
uint_16 *regslist; /* PROC: list of registers to be saved */
struct dsym *paralist; /* list of parameters */
struct dsym *locallist; /* PROC: list of local variables */
struct dsym *labellist; /* PROC: list of local labels */
unsigned parasize; /* total no. of bytes used by parameters */
unsigned localsize; /* PROC: total no. of bytes used by local variables */
char *prologuearg; /* PROC: prologuearg attribute */
#if AMD64_SUPPORT
struct asym *exc_handler; /* PROC: exc handler set by FRAME */
int ReservedStack; /* PROC: win64: additional reserved stack */
#endif
uint_32 prolog_list_pos;/* PROC: prologue list pos */
union {
unsigned char flags;
struct {
unsigned char has_vararg:1;/* last param is VARARG */
unsigned char pe_type:1; /* PROC: prolog-epilog type, 1=use LEAVE */
unsigned char isexport:1; /* PROC: EXPORT attribute set */
//unsigned char init_done:1; /* has ParseProc() been called? v2.11: obsolete */
unsigned char forceframe:1;/* PROC: FORCEFRAME prologuearg? */
unsigned char loadds:1; /* PROC: LOADDS prologuearg? */
unsigned char stackparam:1;/* PROC: 1=stack params exists ( not just register params ) */
#if AMD64_SUPPORT
unsigned char isframe:1; /* PROC: FRAME attribute set? */
#endif
#if STACKBASESUPP
unsigned char fpo:1;
#endif
};
};
uint_8 size_prolog; /* PROC: v2.10: prologue size */
#if STACKBASESUPP
uint_16 basereg; /* PROC: v2.11: stack base register */
#endif
};
/* macro parameter */
struct mparm_list {
//const char *label; /* name of parameter */
char *deflt; /* optional default parm */
unsigned char required:1; /* is parm required (REQ) */
};
/* macro line */
struct srcline {
struct srcline *next;
uint_8 ph_count; /* placeholders contained in this line */
char line[1];
};
/* macro item */
struct macro_info {
uint_16 parmcnt; /* no of params */
union {
uint_16 localcnt; /* no of locals */
uint_16 autoexp; /* auto-expansion flags if predefined macro */
};
struct mparm_list *parmlist; /* array of parameter items */
struct srcline *data; /* prepared macro source lines */
#ifdef DEBUG_OUT
uint_32 count; /* no of times the macro was invoked */
#endif
unsigned srcfile; /* sourcefile index */
};
/* STRUCT field */
struct sfield {
struct asym sym; /* field symbol ( state=SYM_STRUCT_FIELD ) */
struct sfield *next; /* next field in STRUCT,UNION,RECORD */
//char *init_dir; /* v2.09: removed ; previously: not used by record fields */
char ivalue[1]; /* v2.09: type changed from char * to char[] */
};
enum type_kind {
TYPE_NONE,
TYPE_STRUCT,
TYPE_UNION,
TYPE_TYPEDEF,
TYPE_RECORD
};
struct struct_info {
struct sfield *head; /* STRUCT/UNION/RECORD: start of field list */
struct sfield *tail; /* STRUCT/UNION/RECORD: current/next field */
/* v2.08: typekind moved to struct asym */
//#ifdef __WATCOMC__
// enum type_kind typekind;
//#else
// uint_8 typekind;
//#endif
uint_8 alignment; /* STRUCT: 1,2,4,8,16 or 32 */
union {
uint_8 flags;
struct {
unsigned char isInline:1; /* STRUCT/UNION: inline (unused) */
unsigned char isOpen:1; /* STRUCT/UNION: set until the matching ENDS is found */
unsigned char OrgInside:1; /* STRUCT: struct contains an ORG */
};
};
};
/* dsym originally was a "directive_node"
* However, currently all symbols except SYM_STRUCT_FIELDs are allocated as a dsym.
* the additional 3 fields are used differently depending on symbol's type.
*/
struct dsym {
struct asym sym;
union {
struct seg_info *seginfo; /* SYM_SEG (segments) */
struct grp_info *grpinfo; /* SYM_GRP (groups) */
struct proc_info *procinfo; /* SYM_INTERNAL|SYM_EXTERNAL (procs, isproc=1) */
struct struct_info *structinfo;/* SYM_TYPE (structs, unions, records [, typedefs]) */
struct macro_info *macroinfo; /* SYM_MACRO (macros) */
/* SYM_STACK, SYM_INTERNAL (code labels, isproc=0)
* used to save the local hash table (contains PROC locals: params,
* locals, labels). Details see SymGetLocal(), SymSetLocal() in symbols.c
*/
struct dsym *nextll;
} e;
/* next item in linked lists of certain symbol types.
* - SYM_UNDEFINED -> TAB_UNDEF
* - SYM_EXTERNAL -> TAB_EXT
* - SYM_SEG -> TAB_SEG
* - SYM_GRP -> TAB_GRP
* - SYM_ALIAS: -> TAB_ALIAS
* for SYM_INTERNAL:
* linked list of labels for current segment (used for BackPatch)
*/
struct dsym *next;
union {
/* for SYM_UNDEFINED, SYM_EXTERNAL, SYM_ALIAS and SYM_GRP:
* predecessor of current symbol with the same state, to allow fast removes.
* Actually, the only symbols which may change the state and thus
* have a chance to be removed are SYM_UNDEFINED and SYM_EXTERNAL ( weak=TRUE )
* during pass one.
*/
struct dsym *prev;
/* used by PROC symbols (SYM_INTERNAL) for linked list, TAB_PROC */
struct dsym *nextproc;
/* used by PROC locals (SYM_STACK) for linked list */
struct dsym *nextlocal;
/* used by PROC params (SYM_STACK) for linked list */
struct dsym *nextparam;
/* used by SYM_EXTERNAL (weak=FALSE) if altname is set */
/* v2.11: removed; member is in use for SYM_EXTERNAL */
//struct dsym *nextext;
};
};
extern struct asym *SymAlloc( const char * );
extern void SymFree( struct asym * );
extern struct asym *SymCreate( const char * );
extern struct asym *SymLCreate( const char * );
extern struct asym *SymAddGlobal( struct asym * );
extern struct asym *SymAddLocal( struct asym *, const char * );
extern struct asym *SymLookup( const char * );
extern struct asym *SymLookupLocal( const char * );
extern struct asym *SymFind( const char *name );
#define SymSearch(x) SymFind(x)
extern void SymInit( void );
extern void SymFini( void );
extern void SymPassInit( int pass );
extern void SymMakeAllSymbolsPublic( void );
extern void SymGetAll( struct asym ** );
extern struct asym *SymEnum( struct asym *, int * );
extern uint_32 SymGetCount( void );
#if defined(__WATCOMC__)
typedef int (__watcall * StrCmpFunc)(const void *, const void *, size_t );
#else
typedef int (* StrCmpFunc)(const void *, const void *, size_t );
#endif
extern StrCmpFunc SymCmpFunc;
extern void SymSetCmpFunc( void );
extern void SymClearLocal( void );
extern void SymSetLocal( struct asym * );
extern void SymGetLocal( struct asym * );
#endif

41
H/tbyte.h Normal file
View File

@ -0,0 +1,41 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: tbyte format / long double structure definition
*
****************************************************************************/
#ifndef _TBYTE_H
#define _TBYTE_H
struct TB_LD {
uint_64 m;
unsigned short e;
};
struct TB_LD *strtotb( const char *bufptr, struct TB_LD *pld, char negative );
#endif

94
H/token.h Normal file
View File

@ -0,0 +1,94 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: defines token types and struct asm_tok.
* This file is included by parser.h
*
****************************************************************************/
#ifndef _TOKEN_H_
#define _TOKEN_H_
/* T_INSTRUCTION - T_RES_ID are reserved words.
* T_REG - T_RES_ID match RWT_REG - RWT_RES_ID
*/
enum tok_type {
T_FINAL,
T_INSTRUCTION, /* 1 */
T_REG, /* 2 (==RWT_REG) */
T_DIRECTIVE, /* 3 (==RWT_DIRECTIVE) */
T_UNARY_OPERATOR, /* 4 (==RWT_UNARY_OP) */
T_BINARY_OPERATOR, /* 5 (==RWT_BINARY_OP) */
T_STYPE, /* 6 (==RWT_STYPE) */
T_RES_ID, /* 7 (==RWT_RES_ID) */
T_ID, /* 8 */
T_STRING, /* 9 */
T_NUM, /* A */
T_FLOAT, /* B */
T_BAD_NUM, /* C */
T_DBL_COLON, /* D */
T_OP_BRACKET = '(',
T_OP_SQ_BRACKET = '[',
T_CL_BRACKET = ')',
T_CL_SQ_BRACKET = ']',
T_COMMA = ',',
T_COLON = ':',
T_DOT = '.',
T_QUESTION_MARK = '?',
T_PERCENT = '%'
};
struct asm_tok {
#ifdef __WATCOMC__
enum tok_type token; /* (type of) token */
#else
unsigned char token;
#endif
union {
unsigned char dirtype; /* T_DIRECTIVE: type */
unsigned char bytval; /* T_STYPE: memtype */
/* unsigned char regno; *//* T_REG: register number */
unsigned char precedence; /* T_UNARY_OPERATOR/T_BINARY_OPERATOR */
char string_delim; /* T_STRING: string delimiter */
char floattype; /* T_FLOAT: 0 or 'r' */
char numbase; /* T_NUM: number base */
char specval; /* 1-byte special tokens: flags */
};
char *string_ptr;
union {
unsigned int tokval; /* index if token is a reserved word */
unsigned int stringlen; /* T_STRING: size */
unsigned int idarg; /* T_ID: currently not used */
unsigned int itemlen; /* T_NUM: size */
unsigned int lastidx; /* T_FINAL: last index (used in RunMacro()) */
};
char *tokpos; /* points to item in CurrSource */
};
#endif

61
H/tokenize.h Normal file
View File

@ -0,0 +1,61 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: prototypes for tokenizer
*
****************************************************************************/
#ifndef _TOKENIZE_H_INCLUDED
#define _TOKENIZE_H_INCLUDED
struct line_status {
char *input;
char *output; /* free space in token string buffer */
char *start; /* start of line */
unsigned int index; /* index token array */
//char last_token;
char flags; /* v2.08: added */
char flags2; /* v2.08: was global var g_flags */
char flags3; /* v2.08: added */
};
enum tokenize_flags {
TOK_DEFAULT = 0x00, /* default mode - handle conditional assembly */
TOK_RESCAN = 0x01, /* retokenize after expansion - ignore conditional assembly */
TOK_NOCURLBRACES = 0x02, /* don't handle {}-literals */
TOK_LINE = 0x04, /* full line is retokenized */
};
enum tok_flags3 {
TF3_ISCONCAT = 0x01, /* line was concatenated */
TF3_EXPANSION = 0x02, /* expansion operator % at pos 0 */
};
extern ret_code GetToken( struct asm_tok[], struct line_status * );
extern int Tokenize( char *, unsigned int, struct asm_tok[], unsigned int );
#endif

152
H/trmem.h Normal file
View File

@ -0,0 +1,152 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Interface to the trmem memory allocation tracker and
* validator. This isn't used normally and will work for
* Open Watcom only.
****************************************************************************/
#ifndef _TRMEM_H_INCLUDED
#define _TRMEM_H_INCLUDED
#include <stddef.h>
typedef struct _trmem_internal *_trmem_hdl;
typedef void (*_trmem_who)( void ); /* generic pointer to code */
#define _TRMEM_NO_ROUTINE ((_trmem_who)0)
/* generic pointer to code with realloc signature */
typedef void *(*_trmem_realloc_who)(void*,size_t);
#define _TRMEM_NO_REALLOC ((_trmem_realloc_who)0)
/*
These are some special conditions that trmem can detect. OR together
the ones you're interested in and pass them to _trmem_open in the __flags
parameter.
*/
enum {
_TRMEM_ALLOC_SIZE_0 =0x0001,/* attempted alloc of size 0 */
_TRMEM_REALLOC_SIZE_0 =0x0002,/* attempted realloc/expand of size 0 */
_TRMEM_REALLOC_NULL =0x0004,/* attempted realloc/expand of a NULL ptr */
_TRMEM_FREE_NULL =0x0008,/* attempted free of a NULL pointer */
_TRMEM_OUT_OF_MEMORY =0x0010,/* warn if trmem can't allocate memory
for its own purposes */
_TRMEM_CLOSE_CHECK_FREE =0x0020 /* _trmem_close checks if all chunks
were freed */
};
/*
_trmem_open:
__alloc must be supplied and behave like malloc() when passed a size of 0.
__free must be supplied and behave like free() when passed a NULL ptr.
__realloc may be omitted (use _TRMEM_NO_REALLOC). __realloc must behave
like realloc() when passed a NULL pointer or a size of 0.
__expand may be omitted (use _TRMEM_NO_REALLOC). __expand must behave
like _expand() when passed a NULL pointer or a size of 0.
__prt_parm is passed to __prt_line only.
__prt_line must be supplied. It is called to output any messages trmem
needs to communicate. __buf is a null-terminated string of length
__len (including a trailing '\n').
__flags see enum above for more information.
trmem uses __alloc and __free for its own internal structures. None of
the internal structures will appear in the memory statistics given by
_trmem_prt_usage or _trmem_prt_list.
The handle returned uniquely identifies the tracker. Multiple trackers
may be used simultaneously.
A NULL return indicates failure, for one of any reason.
_trmem_open can/will use any of __alloc, __free, or __prt_line; so be
sure they are initialized before calling _trmem_open.
*/
_trmem_hdl _trmem_open(
void *(*__alloc)(size_t),
void (*__free)(void*),
void * (*__realloc)(void*,size_t),
void * (*__expand)(void*,size_t),
FILE *__prt_parm,
void (*__prt_line)( FILE *__prt_parm, const char *__buf, size_t __len ),
unsigned __flags
);
/*
If ( __flags & _TRMEM_CLOSE_CHECK_FREE ) then _trmem_close checks if all
allocated chunks were freed before closing the handle.
Returns number of unfreed chunks.
*/
unsigned _trmem_close( _trmem_hdl );
/*
Replace calls such as
ptr = malloc( size );
with
ptr = _trmem_alloc( size, _trmem_guess_who(), hdl );
*/
void *_trmem_alloc( size_t, _trmem_who, _trmem_hdl );
void _trmem_free( void *, _trmem_who, _trmem_hdl );
void *_trmem_realloc( void *, size_t, _trmem_who, _trmem_hdl );
void *_trmem_expand( void *, size_t, _trmem_who, _trmem_hdl );
char *_trmem_strdup( const char *str, _trmem_who who, _trmem_hdl hdl );
size_t _trmem_msize( void *, _trmem_hdl );
/*
_trmem_prt_usage prints the current memory usage, and peak usage.
_trmem_prt_list prints a list of all currently allocated chunks.
*/
void _trmem_prt_usage( _trmem_hdl );
unsigned _trmem_prt_list( _trmem_hdl );
/*
_trmem_get_current_usage retrieves the current memory usage.
_trmem_get_peak_usage retrieves the peak memory usage.
*/
unsigned long _trmem_get_current_usage( _trmem_hdl );
unsigned long _trmem_get_peak_usage( _trmem_hdl );
_trmem_who _trmem_guess_who( void * );
#ifdef __WATCOMC__
#pragma aux _trmem_guess_who = \
0x8b 0x45 0x04 /* mov eax,[ebp+4] */ \
parm caller [] \
value [eax] \
modify exact [eax];
#endif
#endif

30
H/types.h Normal file
View File

@ -0,0 +1,30 @@
/* prototypes of TYPES.C */
#ifndef _TYPES_H_INCLUDED
#define _TYPES_H_INCLUDED_
/* qualified_type us used for parsing a qualified type. */
struct qualified_type {
int size;
struct asym *symtype;
enum memtype mem_type;
uint_8 is_ptr; /* contains level of indirection */
uint_8 is_far;
uint_8 Ofssize;
enum memtype ptr_memtype;
};
extern struct dsym *CurrStruct; /* start of current STRUCT list */
extern struct asym *CreateTypeSymbol( struct asym *, const char *, bool );
extern struct asym *SearchNameInStruct( const struct asym *, const char *, uint_32 *, int level );
//extern ret_code EndstructDirective( int );
extern ret_code GetQualifiedType( int *, struct asm_tok[], struct qualified_type * );
extern struct asym *CreateStructField( int, struct asm_tok[], const char *, enum memtype, struct asym *, uint_32 );
extern void UpdateStructSize( struct asym * );
extern ret_code SetStructCurrentOffset( int_32 );
extern ret_code AlignInStruct( int );
extern void TypesInit( void );
extern void DeleteType( struct dsym * );
#endif

29
H/unaryop.h Normal file
View File

@ -0,0 +1,29 @@
/* table of unary operators, used in expreval.c */
res( LOW, low_op )
res( HIGH, high_op )
res( LOWWORD, lowword_op )
res( HIGHWORD, highword_op)
#if LOHI32
res( LOW32, low32_op )
res( HIGH32, high32_op )
#endif
res( OFFSET, offset_op )
res( LROFFSET, offset_op )
#if IMAGERELSUPP
res( IMAGEREL, offset_op )
#endif
#if SECTIONRELSUPP
res( SECTIONREL, offset_op )
#endif
res( SEG, seg_op )
res( OPATTR, opattr_op )
res( DOT_TYPE, opattr_op )
res( SIZE, sizlen_op )
res( SIZEOF, sizlen_op )
res( LENGTH, sizlen_op )
res( LENGTHOF, sizlen_op )
res( SHORT, short_op )
res( THIS, this_op )
res( TYPE, type_op )
res( MASK, wimask_op )
res( WIDTH, wimask_op )

126
H/usage.h Normal file
View File

@ -0,0 +1,126 @@
" JWasm [options] asm-file [options] [asm-file] ... [@env_var]\n\n\0"
"options:\0"
#if AMD64_SUPPORT
"-<0|1|..|10>[p]\0" "Set CPU: 0=8086 (default), 1=80186, 2=80286, 3=80386,\0"
"\0" "4=80486, 5=Pentium, 6=PPro, 7=P2, 8=P3, 9=P4, 10=x86-64;\0"
"\0" "<p> allows privileged instructions\0"
#else
"-<0|1|..|6>[p]\0" "Set CPU: 0=8086 (default), 1=80186, 2=80286, 3=80386,\0"
"\0" "4=80486, 5=Pentium, 6=Pentium Pro;\0"
"\0" "<p> allows privileged instructions\0"
#endif
"-c\0" "Assemble without linking (always set)\0"
"-C<p|u|x>\0" "Set OPTION CASEMAP: p=NONE, u=ALL, x=NOTPUBLIC (default)\0"
"-D<name>[=text]\0" "Define text macro\0"
"-e<number>\0" "Set error limit number (default=50)\0"
"-EP\0" "Output preprocessed listing to stdout\0"
"-eq\0" "don't display error messages\0"
#if DLLIMPORT
"-Fd[=<file_name>]\0" "Write import definition file\0"
#endif
"-Fi<file_name>\0" "Force <file_name> to be included\0"
"-Fl[=<file_name>]\0" "Write listing file\0"
"-Fo<file_name>\0" "Set object file name\0"
"-Fw<file_name>\0" "Set errors file name\0"
"-FPi\0" "80x87 instructions with emulation fixups\0"
"-FPi87\0" "80x87 instructions (default)\0"
"-fpc\0" "Disallow floating-point instructions (.NO87)\0"
"-fp<n>\0" "Set FPU, <n> is: 0=8087 (default), 2=80287, 3=80387\0"
"-G<c|d|r|z>\0" "Use Pascal, C, Fastcall or Stdcall calling convention\0"
"-I<directory>\0" "Add directory to list of include directories\0"
"-m<t|s|c|m|l|h|f>\0" "Set memory model:\0"
"\0" "(Tiny, Small, Compact, Medium, Large, Huge, Flat)\0"
"-nc=<name>\0" "Set class name of code segment\0"
"-n<d|m|t>=<name>\0" "Set name of d)ata segment, m)odule or t)ext segment\0"
#if COCTALS
"-o\0" "Allow C form of octal constants\0"
#endif
"-q, -nologo\0" "Don't display version and copyright information\0"
"-Sa\0" "Maximize source listing\0"
#if COFF_SUPPORT
"-safeseh\0" "Assert all exception handlers are declared\0"
#endif
"-Sf\0" "Generate first pass listing\0"
"-Sg\0" "Display generated code in listing\0"
"-Sn\0" "Suppress symbol-table listing\0"
"-Sx\0" "List false conditionals\0"
"-w\0" "Same as /W0 /WX\0"
"-W<number>\0" "Set warning level number (default=2, max=4)\0"
"-WX\0" "Treat all warnings as errors\0"
"-X\0" "Ignore INCLUDE environment path\0"
"-zcm\0" "C names are decorated with '_' prefix (default)\0"
"-zcw\0" "No name decoration for C symbols\0"
"-Zd\0" "Add line number debug info (OMF & COFF only)\0"
"-Zf\0" "Make all symbols public\0"
#if OWFC_SUPPORT
"-zf<0|1>\0" "Set FASTCALL type: 0=MS VC style (default),\0"
"\0" "1=OW register calling convention\0"
#endif
"-Zg\0" "Generated code is to exactly match Masm's one\0"
"-Zi[0|1|2|3]\0" "Add symbolic debug info (OMF & COFF): 0=globals\0"
"\0" "1= +locals, 2= +types (default), 3= +constants\0"
"-zlc\0" "No OMF records about data in code\0"
"-zld\0" "No OMF records about far call optimization\0"
#if COFF_SUPPORT
"-zl<f|p|s>\0" "Suppress items in COFF symbol table: f=no .file entry,\0"
"\0" "p=no static procs, s=no auxiliary entries for sections\0"
#endif
"-Zm\0" "Masm v5.1 compatibility\0"
"-Zne\0" "Disable syntax extensions not supported by Masm\0"
"-Zp[n]\0" "Set structure alignment, n=<1|2|4|8|16|32>\0"
"-Zs\0" "Perform syntax check only\0"
"-zt<0|1|2>\0" "Set STDCALL symbol decoration: 0=No name decoration,\0"
"\0" "1=No '@size' suffix for functions, 2=Full (default)\0"
"-Zv8\0" "Enable Masm v8+ PROC visibility\0"
"-zze\0" "No name decoration for exported symbols\0"
#if COFF_SUPPORT
"-zzs\0" "Store decorated name of start address (COFF only)\0"
#endif
"@env_var\0" "Environment variable or file containing further commands\0"
"output formats:\0\0"
#if BIN_SUPPORT
"-bin\0" "plain binary file\0"
#endif
#if COFF_SUPPORT
"-coff\0" "COFF object file\0"
#endif
#if COFF_SUPPORT && DJGPP_SUPPORT
"-djgpp\0" "Djgpp's variant of 32-bit COFF object file\0"
#endif
#if ELF_SUPPORT
"-elf\0" "32-bit ELF object file\0"
#if AMD64_SUPPORT
"-elf64\0" "64-bit ELF object file\0"
#endif
#endif
#if BIN_SUPPORT && MZ_SUPPORT
"-mz\0" "DOS MZ binary file\0"
#endif
"-omf\0" "OMF object file (default)\0"
#if PE_SUPPORT
"-pe\0" "PE binary file, 32/64-bit\0"
#endif
#if AMD64_SUPPORT
"-win64\0" "64-bit COFF object file\0"
#endif
#ifdef DEBUG_OUT
"Debug options:\0\0"
"-af\0" "Display all files used in assembly process\0"
"-ce\0" "Cause an exception\0"
"-dm\0" "Display all messages\0"
"-dr\0" "Display reserved words\0"
"-drh\0" "Display reserved words hash table\0"
"-ds\0" "Display global symbols\0"
"-dsh\0" "Display global symbols hash table\0"
"-dt\0" "Display debug trace\0"
#if FASTPASS
"-ls\0" "Display preprocessed line storage\0"
#endif
"-nbp\0" "Disable backpatching\0"
#if FASTPASS
"-nfp\0" "Do full subsequent passes (disables \"fastpass\")\0"
#endif
"-pm=<n>\0" "Stop assembly after <n> passes\0"
"-sp\0" "Skip preprocessor step\0"
#endif
"\n"

34
H/win32.h Normal file
View File

@ -0,0 +1,34 @@
/*
* this file contains prototypes of the Win32 functions which are
* called directly by JWasm (in memalloc.c if FASTMEM=1).
*/
//#if defined(__WATCOMC__) || defined(__PCC__) || defined(__OCC__)
#if defined(__PCC__) || defined(__OCC__)
/* __declspec(dllimport) is a problem if Win32 is linked statically (HX)
* and WLINK < v1.9 is used. MS link is smarter, it knows what to do if a symbol
* has been declared with dllimport and then turns out to be static.
*/
#define WINBASEAPI
#else
#define WINBASEAPI __declspec(dllimport)
#endif
#ifdef _WIN64
#define WINAPI __fastcall
#else
#define WINAPI __stdcall
#endif
#define MEM_COMMIT 0x1000
#define MEM_RELEASE 0x8000
#define PAGE_READWRITE 0x0004
/*
* v2.10: second parameter of VirtualAlloc/Free changed to size_t ( from uint_32 ).
* The old declaration did work for Win64, due to the AMD64 peculiarity that writing
* to the lower 32-bits of a register ( here: EDX/RDX ) clears the upper 32-bits.
*/
WINBASEAPI void *WINAPI VirtualAlloc( void *, size_t, uint_32, uint_32 );
WINBASEAPI int WINAPI VirtualFree( void *, size_t, uint_32 );

64
H/win64seh.h Normal file
View File

@ -0,0 +1,64 @@
/* some structures for Win64 SEH */
/* .pdata items */
typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY
{
uint_32 BeginAddress;
uint_32 EndAddress;
uint_32 UnwindData; /* RVA of UNWIND_INFO */
} IMAGE_RUNTIME_FUNCTION_ENTRY;
/* .xdata items */
enum {
UWOP_PUSH_NONVOL = 0, /* .PUSHREG - push nonvolative gpr */
UWOP_ALLOC_LARGE = 1, /* .ALLOCSTACK - alloc large-sized area on stack */
UWOP_ALLOC_SMALL = 2, /* .ALLOCSTACK - alloc small-sized area (8-128) on stack */
UWOP_SET_FPREG = 3, /* .SETFRAME - set frame pointer */
UWOP_SAVE_NONVOL = 4, /* .SAVEREG - save nonvolative gpr using MOV instead of PUSH */
UWOP_SAVE_NONVOL_FAR = 5, /* .SAVEREG - save nonvolative gpr using MOV instead of PUSH */
UWOP_SAVE_XMM = 6, /* */
UWOP_SAVE_XMM_FAR = 7, /* */
UWOP_SAVE_XMM128 = 8, /* .SAVEXMM128 - save all 128bits of nonvolative XMM register on stack */
UWOP_SAVE_XMM128_FAR = 9, /* .SAVEXMM128 - save all 128bits of nonvolative XMM register on stack */
UWOP_PUSH_MACHFRAME = 10 /* .PUSHFRAME - push a machine frame ( SS, RSP, EFL, CS, RIP [ERRCODE] ) */
};
typedef union _UNWIND_CODE {
struct {
uint_8 CodeOffset; /* offset within prolog */
uint_8 UnwindOp : 4; /* see UWOP_ values */
uint_8 OpInfo : 4;
};
uint_16 FrameOffset;
} UNWIND_CODE;
enum {
UNW_FLAG_NHANDLER = 0,
UNW_FLAG_EHANDLER = 1, /* function to examine exceptions */
UNW_FLAG_UHANDLER = 2, /* function to unwind an exception */
UNW_FLAG_FHANDLER = 3, /* inofficial, is E+U */
UNW_FLAG_CHAININFO = 4
};
typedef struct _UNWIND_INFO {
uint_8 Version : 3; /* is 1 */
uint_8 Flags : 5; /* see UNW_FLAG_ values */
uint_8 SizeOfProlog; /* size of prolog in bytes */
uint_8 CountOfCodes; /* number of UNWIND_CODE entries */
uint_8 FrameRegister : 4; /* if nonzero, function uses a frame pointer */
uint_8 FrameOffset : 4; /* offset frame reg from RSP * 16 */
#if 0
UNWIND_CODE UnwindCode[1]; /* unwind codes array */
union {
uint_32 ExceptionHandler; /* if UNW_FLAG_EHANDLER or UNW_FLAG_UHANDLER is set: RVA of language specific handler */
uint_32 FunctionEntry; /* if UNW_FLAG_CHAININFO is set: see IMAGE_RUNTIME_FUNCTION_ENTRY */
};
uint_32 ExceptionData[];
#endif
} UNWIND_INFO;
#define UNW_VERSION 1

2102
History.txt Normal file

File diff suppressed because it is too large Load Diff

103
IntelC32.mak Normal file
View File

@ -0,0 +1,103 @@
# this makefile (NMake) creates the JWasm Win32 binary with the Intel C++
# compiler. It has been tested with:
# - Intel C++ on IA-32, v11.1
# the Intel compiler needs external includes and libraries, compatible with
# MS Visual C. The MS VC++ Toolkit 2003 has been used here.
# directory paths to adjust:
# CDIR - root directory of the Intel C compiler
# VCDIR - root directory for Visual C includes and libraries
# W32LIB - directory for Win32 import library files (kernel32.lib).
# Default is WinInc ( may be changed to the MS Platform SDK ).
name = jwasm
CDIR = \intelcpp
VCDIR = \msvc71
W32LIB = \WinInc\Lib
# use the MS linker or jwlink (jwlink is experimental!)
!ifndef MSLINK
MSLINK=1
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=ICD
!else
OUTD=ICR
!endif
!endif
inc_dirs = -IH -I"$(CDIR)\include" -I"$(VCDIR)\include"
linker = $(CDIR)\Bin\xilink.exe
lib = $(CDIR)\Bin\xilib.exe
!if $(DEBUG)
extra_c_flags = -Zd -Od -DDEBUG_OUT -FAa -Fa$*
!else
extra_c_flags = -O2 -Gs -DNDEBUG
#extra_c_flags = -Ox -DNDEBUG
!endif
c_flags =-D__NT__ $(extra_c_flags) $(c_flags64)
# if MSVC++ 2005 EE is used:
# 1. define __STDC_WANT_SECURE_LIB__=0 to avoid "deprecated" warnings
# 2. define -GS- to disable security checks
#c_flags =-D__NT__ $(extra_c_flags) -D__STDC_WANT_SECURE_LIB__=0 -GS-
#lflags stuff
#########
LOPT = /NOLOGO
!if $(DEBUG)
LOPTD = /debug
!endif
lflagsw = $(LOPTD) /SUBSYSTEM:CONSOLE $(LOPT) /map:$^*.map /OPT:NOWIN98
CC=$(CDIR)\bin\icl.exe -c -nologo $(inc_dirs) $(c_flags)
.c{$(OUTD)}.obj:
@$(CC) -Fo$* $<
proj_obj = \
!include msmod.inc
TARGET1=$(OUTD)\$(name).exe
ALL: $(OUTD) $(TARGET1)
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).exe : $(OUTD)/main.obj $(OUTD)/$(name).lib
!if $(MSLINK)
@$(linker) @<<
$(lflagsw) $(OUTD)/main.obj $(OUTD)/$(name).lib
/LIBPATH:"$(CDIR)\Lib\Ia32" /LIBPATH:"$(VCDIR)\Lib" /LIBPATH:"$(W32LIB)" /OUT:$@
<<
!else
@jwlink format windows pe file $(OUTD)/main.obj name $@ lib $(OUTD)/$(name).lib libpath "$(CDIR)\Lib\Ia32" libpath "$(VCDIR)\Lib" libpath "$(W32LIB)" op start=_mainCRTStartup, norelocs, eliminate, map=$(OUTD)/$(name).map
!endif
$(OUTD)\$(name).lib : $(proj_obj)
@$(lib) /nologo /out:$(OUTD)\$(name).lib $(proj_obj)
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
@$(CC) -Fo$* msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
@$(CC) -Fo$* reswords.c
######
clean:
@erase $(OUTD)\*.exe
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

98
IntelC64.mak Normal file
View File

@ -0,0 +1,98 @@
# this makefile (NMake) creates the JWasm Win64 binary with the Intel C++
# compiler. It has been tested with:
# - Intel C++ on IA-32, v11.1
# the Intel compiler needs external includes and libraries, compatible with
# MS Visual C. MS VC 2008 has been used here.
# directory paths to adjust:
# CDIR - root directory of the Intel C compiler
# VCDIR - root directory for Visual C includes and libraries
# W64LIB - directory for Win64 import library files (kernel32.lib).
# Default is WinInc ( may be changed to the MS Platform SDK ).
name = jwasm
CDIR = \intelcpp
VCDIR = \msvc9
W64LIB = \WinInc\Lib64
# use the MS linker or jwlink (jwlink is experimental!)
!ifndef MSLINK
MSLINK=1
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=IC64D
!else
OUTD=IC64R
!endif
!endif
inc_dirs = -IH -I"$(CDIR)\include" -I"$(VCDIR)\include"
linker = $(CDIR)\bin64\xilink.exe
lib = $(CDIR)\bin64\xilib.exe
!if $(DEBUG)
extra_c_flags = -Zd -Od -DDEBUG_OUT
!else
extra_c_flags = -O2 -Gs -DNDEBUG
#extra_c_flags = -Ox -DNDEBUG
!endif
c_flags =-D_WIN64 $(extra_c_flags) $(c_flags64)
#lflags stuff
#########
LOPT = /NOLOGO
!if $(DEBUG)
#LOPTD = /debug
!endif
lflagsw = $(LOPTD) /SUBSYSTEM:CONSOLE $(LOPT) /map:$^*.map
CC=$(CDIR)\bin64\icl.exe -c -nologo $(inc_dirs) $(c_flags)
.c{$(OUTD)}.obj:
@$(CC) -Fo$* $<
proj_obj = \
!include msmod.inc
TARGET1=$(OUTD)\$(name).exe
ALL: $(OUTD) $(TARGET1)
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).exe : $(OUTD)/main.obj $(OUTD)/$(name).lib
!if $(MSLINK)
@$(linker) @<<
$(lflagsw) $(OUTD)/main.obj $(OUTD)/$(name).lib
/LIBPATH:"$(CDIR)\Lib\Intel64" /LIBPATH:"$(VCDIR)\Lib64" /LIBPATH:"$(W64LIB)" /OUT:$@
<<
!else
@jwlink format windows pe file $(OUTD)/main.obj name $@ lib $(OUTD)/$(name).lib libpath "$(CDIR)\Lib\Ia32" libpath "$(VCDIR)\Lib64" libpath "$(W64LIB)" op start=_mainCRTStartup, norelocs, eliminate, map=$(OUTD)/$(name).map
!endif
$(OUTD)\$(name).lib : $(proj_obj)
@$(lib) /nologo /out:$(OUTD)\$(name).lib $(proj_obj)
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
@$(CC) -Fo$* msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
@$(CC) -Fo$* reswords.c
######
clean:
@erase $(OUTD)\*.exe
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

352
License.txt Normal file
View File

@ -0,0 +1,352 @@
JWasm License
USE OF THE SYBASE OPEN WATCOM SOFTWARE DESCRIBED BELOW ("SOFTWARE") IS SUBJECT
TO THE TERMS AND CONDITIONS SET FORTH IN THE SYBASE OPEN WATCOM PUBLIC LICENSE
SET FORTH BELOW ("LICENSE"). YOU MAY NOT USE THE SOFTWARE IN ANY MANNER
UNLESS YOU ACCEPT THE TERMS AND CONDITIONS OF THE LICENSE. YOU INDICATE YOUR
ACCEPTANCE BY IN ANY MANNER USING (INCLUDING WITHOUT LIMITATION BY
REPRODUCING, MODIFYING OR DISTRIBUTING) THE SOFTWARE. IF YOU DO NOT ACCEPT
ALL OF THE TERMS AND CONDITIONS OF THE LICENSE, DO NOT USE THE SOFTWARE IN ANY
MANNER.
Sybase Open Watcom Public License version 1.0
1. General; Definitions. This License applies only to the following software
programs: the open source versions of Sybase's Watcom C/C++ and Fortran
compiler products ("Software"), which are modified versions of, with
significant changes from, the last versions made commercially available by
Sybase. As used in this License:
1.1 "Applicable Patent Rights" mean: (a) in the case where Sybase is the
grantor of rights, (i) claims of patents that are now or hereafter acquired,
owned by or assigned to Sybase and (ii) that cover subject matter contained in
the Original Code, but only to the extent necessary to use, reproduce and/or
distribute the Original Code without infringement; and (b) in the case where
You are the grantor of rights, (i) claims of patents that are now or hereafter
acquired, owned by or assigned to You and (ii) that cover subject matter in
Your Modifications, taken alone or in combination with Original Code.
1.2 "Contributor" means any person or entity that creates or contributes to
the creation of Modifications.
1.3 "Covered Code" means the Original Code, Modifications, the combination of
Original Code and any Modifications, and/or any respective portions thereof.
1.4 "Deploy" means to use, sublicense or distribute Covered Code other than
for Your internal research and development (R&D) and/or Personal Use, and
includes without limitation, any and all internal use or distribution of
Covered Code within Your business or organization except for R&D use and/or
Personal Use, as well as direct or indirect sublicensing or distribution of
Covered Code by You to any third party in any form or manner.
1.5 "Larger Work" means a work which combines Covered Code or portions thereof
with code not governed by the terms of this License.
1.6 "Modifications" mean any addition to, deletion from, and/or change to, the
substance and/or structure of the Original Code, any previous Modifications,
the combination of Original Code and any previous Modifications, and/or any
respective portions thereof. When code is released as a series of files, a
Modification is: (a) any addition to or deletion from the contents of a file
containing Covered Code; and/or (b) any new file or other representation of
computer program statements that contains any part of Covered Code.
1.7 "Original Code" means (a) the Source Code of a program or other work as
originally made available by Sybase under this License, including the Source
Code of any updates or upgrades to such programs or works made available by
Sybase under this License, and that has been expressly identified by Sybase as
such in the header file(s) of such work; and (b) the object code compiled from
such Source Code and originally made available by Sybase under this License.
1.8 "Personal Use" means use of Covered Code by an individual solely for his
or her personal, private and non-commercial purposes. An individual's use of
Covered Code in his or her capacity as an officer, employee, member,
independent contractor or agent of a corporation, business or organization
(commercial or non-commercial) does not qualify as Personal Use.
1.9 "Source Code" means the human readable form of a program or other work
that is suitable for making modifications to it, including all modules it
contains, plus any associated interface definition files, scripts used to
control compilation and installation of an executable (object code).
1.10 "You" or "Your" means an individual or a legal entity exercising rights
under this License. For legal entities, "You" or "Your" includes any entity
which controls, is controlled by, or is under common control with, You, where
"control" means (a) the power, direct or indirect, to cause the direction or
management of such entity, whether by contract or otherwise, or (b) ownership
of fifty percent (50%) or more of the outstanding shares or beneficial
ownership of such entity.
2. Permitted Uses; Conditions & Restrictions.Subject to the terms and
conditions of this License, Sybase hereby grants You, effective on the date
You accept this License and download the Original Code, a world-wide,
royalty-free, non-exclusive license, to the extent of Sybase's Applicable
Patent Rights and copyrights covering the Original Code, to do the following:
2.1 You may use, reproduce, display, perform, modify and distribute Original
Code, with or without Modifications, solely for Your internal research and
development and/or Personal Use, provided that in each instance:
(a) You must retain and reproduce in all copies of Original Code the copyright
and other proprietary notices and disclaimers of Sybase as they appear in the
Original Code, and keep intact all notices in the Original Code that refer to
this License; and
(b) You must retain and reproduce a copy of this License with every copy of
Source Code of Covered Code and documentation You distribute, and You may not
offer or impose any terms on such Source Code that alter or restrict this
License or the recipients' rights hereunder, except as permitted under
Section 6.
(c) Whenever reasonably feasible you should include the copy of this License
in a click-wrap format, which requires affirmative acceptance by clicking on
an "I accept" button or similar mechanism. If a click-wrap format is not
included, you must include a statement that any use (including without
limitation reproduction, modification or distribution) of the Software, and
any other affirmative act that you define, constitutes acceptance of the
License, and instructing the user not to use the Covered Code in any manner if
the user does not accept all of the terms and conditions of the License.
2.2 You may use, reproduce, display, perform, modify and Deploy Covered Code,
provided that in each instance:
(a) You must satisfy all the conditions of Section 2.1 with respect to the
Source Code of the Covered Code;
(b) You must duplicate, to the extent it does not already exist, the notice in
Exhibit A in each file of the Source Code of all Your Modifications, and cause
the modified files to carry prominent notices stating that You changed the
files and the date of any change;
(c) You must make Source Code of all Your Deployed Modifications publicly
available under the terms of this License, including the license grants set
forth in Section 3 below, for as long as you Deploy the Covered Code or twelve
(12) months from the date of initial Deployment, whichever is longer. You
should preferably distribute the Source Code of Your Deployed Modifications
electronically (e.g. download from a web site);
(d) if You Deploy Covered Code in object code, executable form only, You must
include a prominent notice, in the code itself as well as in related
documentation, stating that Source Code of the Covered Code is available under
the terms of this License with information on how and where to obtain such
Source Code; and
(e) the object code form of the Covered Code may be distributed under Your own
license agreement, provided that such license agreement contains terms no less
protective of Sybase and each Contributor than the terms of this License, and
stating that any provisions which differ from this License are offered by You
alone and not by any other party.
2.3 You expressly acknowledge and agree that although Sybase and each
Contributor grants the licenses to their respective portions of the Covered
Code set forth herein, no assurances are provided by Sybase or any Contributor
that the Covered Code does not infringe the patent or other intellectual
property rights of any other entity. Sybase and each Contributor disclaim any
liability to You for claims brought by any other entity based on infringement
of intellectual property rights or otherwise. As a condition to exercising
the rights and licenses granted hereunder, You hereby assume sole
responsibility to secure any other intellectual property rights needed, if
any. For example, if a third party patent license is required to allow You to
distribute the Covered Code, it is Your responsibility to acquire that license
before distributing the Covered Code.
3. Your Grants. In consideration of, and as a condition to, the licenses
granted to You under this License, You hereby grant to Sybase and all third
parties a non-exclusive, royalty-free license, under Your Applicable Patent
Rights and other intellectual property rights (other than patent) owned or
controlled by You, to use, reproduce, display, perform, modify, distribute and
Deploy Your Modifications of the same scope and extent as Sybase's licenses
under Sections 2.1 and 2.2.
4. Larger Works. You may create a Larger Work by combining Covered Code with
other code not governed by the terms of this License and distribute the Larger
Work as a single product. In each such instance, You must make sure the
requirements of this License are fulfilled for the Covered Code or any portion
thereof.
5. Limitations on Patent License. Except as expressly stated in Section 2, no
other patent rights, express or implied, are granted by Sybase herein.
Modifications and/or Larger Works may require additional patent licenses from
Sybase which Sybase may grant in its sole discretion.
6. Additional Terms. You may choose to offer, and to charge a fee for,
warranty, support, indemnity or liability obligations and/or other rights
consistent with this License ("Additional Terms") to one or more recipients of
Covered Code. However, You may do so only on Your own behalf and as Your sole
responsibility, and not on behalf of Sybase or any Contributor. You must
obtain the recipient's agreement that any such Additional Terms are offered by
You alone, and You hereby agree to indemnify, defend and hold Sybase and every
Contributor harmless for any liability incurred by or claims asserted against
Sybase or such Contributor by reason of any such Additional Terms.
7. Versions of the License. Sybase may publish revised and/or new versions of
this License from time to time. Each version will be given a distinguishing
version number. Once Original Code has been published under a particular
version of this License, You may continue to use it under the terms of that
version. You may also choose to use such Original Code under the terms of any
subsequent version of this License published by Sybase. No one other than
Sybase has the right to modify the terms applicable to Covered Code created
under this License.
8. NO WARRANTY OR SUPPORT. The Covered Code may contain in whole or in part
pre-release, untested, or not fully tested works. The Covered Code may
contain errors that could cause failures or loss of data, and may be
incomplete or contain inaccuracies. You expressly acknowledge and agree that
use of the Covered Code, or any portion thereof, is at Your sole and entire
risk. THE COVERED CODE IS PROVIDED "AS IS" AND WITHOUT WARRANTY, UPGRADES OR
SUPPORT OF ANY KIND AND SYBASE AND SYBASE'S LICENSOR(S) (COLLECTIVELY REFERRED
TO AS "SYBASE" FOR THE PURPOSES OF SECTIONS 8 AND 9) AND ALL CONTRIBUTORS
EXPRESSLY DISCLAIM ALL WARRANTIES AND/OR CONDITIONS, EXPRESS OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES AND/OR CONDITIONS OF
MERCHANTABILITY, OF SATISFACTORY QUALITY, OF FITNESS FOR A PARTICULAR PURPOSE,
OF ACCURACY, OF QUIET ENJOYMENT, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
SYBASE AND EACH CONTRIBUTOR DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR
ENJOYMENT OF THE COVERED CODE, THAT THE FUNCTIONS CONTAINED IN THE COVERED
CODE WILL MEET YOUR REQUIREMENTS, THAT THE OPERATION OF THE COVERED CODE WILL
BE UNINTERRUPTED OR ERROR-FREE, OR THAT DEFECTS IN THE COVERED CODE WILL BE
CORRECTED. NO ORAL OR WRITTEN INFORMATION OR ADVICE GIVEN BY SYBASE, A SYBASE
AUTHORIZED REPRESENTATIVE OR ANY CONTRIBUTOR SHALL CREATE A WARRANTY. You
acknowledge that the Covered Code is not intended for use in the operation of
nuclear facilities, aircraft navigation, communication systems, or air traffic
control machines in which case the failure of the Covered Code could lead to
death, personal injury, or severe physical or environmental damage.
9. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT
SHALL SYBASE OR ANY CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INCIDENTAL, SPECIAL,
INDIRECT, CONSEQUENTIAL OR OTHER DAMAGES OF ANY KIND ARISING OUT OF OR
RELATING TO THIS LICENSE OR YOUR USE OR INABILITY TO USE THE COVERED CODE, OR
ANY PORTION THEREOF, WHETHER UNDER A THEORY OF CONTRACT, WARRANTY, TORT
(INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, EVEN IF SYBASE OR
SUCH CONTRIBUTOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, AND
NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY REMEDY. SOME
JURISDICTIONS DO NOT ALLOW THE LIMITATION OF LIABILITY OF INCIDENTAL OR
CONSEQUENTIAL OR OTHER DAMAGES OF ANY KIND, SO THIS LIMITATION MAY NOT APPLY
TO YOU. In no event shall Sybase's or any Contributor's total liability to
You for all damages (other than as may be required by applicable law) under
this License exceed the amount of five hundred dollars ($500.00).
10. Trademarks. This License does not grant any rights to use the trademarks
or trade names "Sybase" or any other trademarks or trade names belonging to
Sybase (collectively "Sybase Marks") or to any trademark or trade name
belonging to any Contributor("Contributor Marks"). No Sybase Marks or
Contributor Marks may be used to endorse or promote products derived from the
Original Code or Covered Code other than with the prior written consent of
Sybase or the Contributor, as applicable.
11. Ownership. Subject to the licenses granted under this License, each
Contributor retains all rights, title and interest in and to any Modifications
made by such Contributor. Sybase retains all rights, title and interest in
and to the Original Code and any Modifications made by or on behalf of Sybase
("Sybase Modifications"), and such Sybase Modifications will not be
automatically subject to this License. Sybase may, at its sole discretion,
choose to license such Sybase Modifications under this License, or on
different terms from those contained in this License or may choose not to
license them at all.
12. Termination.
12.1 Termination. This License and the rights granted hereunder will
terminate:
(a) automatically without notice if You fail to comply with any term(s) of
this License and fail to cure such breach within 30 days of becoming aware of
such breach;
(b) immediately in the event of the circumstances described in Section
13.5(b); or
(c) automatically without notice if You, at any time during the term of this
License, commence an action for patent infringement (including as a cross
claim or counterclaim) against Sybase or any Contributor.
12.2 Effect of Termination. Upon termination, You agree to immediately stop
any further use, reproduction, modification, sublicensing and distribution of
the Covered Code and to destroy all copies of the Covered Code that are in
your possession or control. All sublicenses to the Covered Code that have
been properly granted prior to termination shall survive any termination of
this License. Provisions which, by their nature, should remain in effect
beyond the termination of this License shall survive, including but not
limited to Sections 3, 5, 8, 9, 10, 11, 12.2 and 13. No party will be liable
to any other for compensation, indemnity or damages of any sort solely as a
result of terminating this License in accordance with its terms, and
termination of this License will be without prejudice to any other right or
remedy of any party.
13. Miscellaneous.
13.1 Government End Users. The Covered Code is a "commercial item" as defined
in FAR 2.101. Government software and technical data rights in the Covered
Code include only those rights customarily provided to the public as defined
in this License. This customary commercial license in technical data and
software is provided in accordance with FAR 12.211 (Technical Data) and 12.212
(Computer Software) and, for Department of Defense purchases, DFAR
252.227-7015 (Technical Data -- Commercial Items) and 227.7202-3 (Rights in
Commercial Computer Software or Computer Software Documentation).
Accordingly, all U.S. Government End Users acquire Covered Code with only
those rights set forth herein.
13.2 Relationship of Parties. This License will not be construed as creating
an agency, partnership, joint venture or any other form of legal association
between or among you, Sybase or any Contributor, and You will not represent to
the contrary, whether expressly, by implication, appearance or otherwise.
13.3 Independent Development. Nothing in this License will impair Sybase's or
any Contributor's right to acquire, license, develop, have others develop for
it, market and/or distribute technology or products that perform the same or
similar functions as, or otherwise compete with, Modifications, Larger Works,
technology or products that You may develop, produce, market or distribute.
13.4 Waiver; Construction. Failure by Sybase or any Contributor to enforce
any provision of this License will not be deemed a waiver of future
enforcement of that or any other provision. Any law or regulation which
provides that the language of a contract shall be construed against the
drafter will not apply to this License.
13.5 Severability. (a) If for any reason a court of competent jurisdiction
finds any provision of this License, or portion thereof, to be unenforceable,
that provision of the License will be enforced to the maximum extent
permissible so as to effect the economic benefits and intent of the parties,
and the remainder of this License will continue in full force and effect. (b)
Notwithstanding the foregoing, if applicable law prohibits or restricts You
from fully and/or specifically complying with Sections 2 and/or 3 or prevents
the enforceability of either of those Sections, this License will immediately
terminate and You must immediately discontinue any use of the Covered Code and
destroy all copies of it that are in your possession or control.
13.6 Dispute Resolution. Any litigation or other dispute resolution between
You and Sybase relating to this License shall take place in the Northern
District of California, and You and Sybase hereby consent to the personal
jurisdiction of, and venue in, the state and federal courts within that
District with respect to this License. The application of the United Nations
Convention on Contracts for the International Sale of Goods is expressly
excluded.
13.7 Entire Agreement; Governing Law. This License constitutes the entire
agreement between the parties with respect to the subject matter hereof. This
License shall be governed by the laws of the United States and the State of
California, except that body of California law concerning conflicts of law.
Where You are located in the province of Quebec, Canada, the following clause
applies: The parties hereby confirm that they have requested that this
License and all related documents be drafted in English. Les parties ont
exige que le present contrat et tous les documents connexes soient rediges en
anglais.
EXHIBIT A.
"Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
This file contains Original Code and/or Modifications of Original Code as
defined in and that are subject to the Sybase Open Watcom Public License
version 1.0 (the 'License'). You may not use this file except in compliance
with the License. BY USING THIS FILE YOU AGREE TO ALL TERMS AND CONDITIONS OF
THE LICENSE. A copy of the License is provided with the Original Code and
Modifications, and is also available at www.sybase.com/developer/opensource.
The Original Code and all software distributed under the License are
distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM ALL SUCH
WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please
see the License for the specific language governing rights and limitations
under the License."

180
Makefile Normal file
View File

@ -0,0 +1,180 @@
# this makefile in OW WMake style creates JWasm.EXE (Win32) and optionally
# JWasmD.EXE (DOS).
# tools used:
# - Open Watcom v1.9
# - jwlink ( optionally OW Wlink may be used, see below )
# - HXDev ( needed only if a DOS version is to be created )
#
# "WMake" - creates the Win32 version.
# "WMake debug=1" - creates the Win32 debug version.
# "WMake dos=1" - creates both Win32 and DOS version (JWasmD.exe)
# "WMake djgpp=1" - creates a Win32 version with DJGPP support.
# "WMake wlink=1" - create a Win32 version that is linked with OW Wlink.
name = JWasm
WIN=1
# Open Watcom root directory
!ifndef WATCOM
WATCOM = \Watcom
!endif
# if a DOS version is to be created, HXDIR must contain the HX root directory
!ifndef HXDIR
HXDIR = \HX
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef DOS
DOS=0
!endif
!ifndef DJGPP
DJGPP=0
!endif
# to track memory leaks, the Open Watcom TRMEM module can be included.
# it's useful only if FASTMEM=0 is set, though, otherwise most allocs
# won't use the C heap.
!ifndef TRMEM
TRMEM=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=Debug
!else
OUTD=Release
!endif
!endif
inc_dirs = -IH -I$(WATCOM)\H
c_flags = -q -bc -bt=nt -3r -fpi87
# -zc flag makes wcc386 place constant data in code segment.
# used with wlink because it won't accept readonly attribute for segments
!ifdef WLINK
LINK = $(WATCOM)\binnt\wlink.exe
c_flags += -zc
!else
LINK = jwlink.exe
!endif
#cflags stuff
#########
extra_c_flags =
!if $(DEBUG)
extra_c_flags += -od -d2 -w3 -hc -DDEBUG_OUT
!else
#extra_c_flags += -obmilrt -s -DNDEBUG
extra_c_flags += -oxa -s -DNDEBUG
!endif
!if $(TRMEM)
extra_c_flags += -of -DTRMEM -DFASTMEM=0
!endif
!if $(DJGPP)
extra_c_flags += -DDJGPP_SUPPORT=1
!endif
#########
!if $(DEBUG)
# for OW v1.8, the debug version needs user32.lib to resolve CharUpperA()
# without it, WD(W) will crash immediately.
LOPTD = debug c op cvp, symfile lib user32.lib
!else
LOPTD =
!endif
CC=$(WATCOM)\binnt\wcc386 $(c_flags) $(inc_dirs) $(extra_c_flags) -fo$@
LIB=$(WATCOM)\binnt\wlib
.c{$(OUTD)}.obj:
$(CC) $<
proj_obj = &
!include owmod.inc
!if $(TRMEM)
proj_obj += $(OUTD)/trmem.obj
!endif
!if $(WIN)
TARGET1=$(OUTD)/$(name).exe
!endif
!if $(DOS)
TARGET2=$(OUTD)/$(name)d.exe
!endif
ALL: $(OUTD) $(TARGET1) $(TARGET2)
$(OUTD):
@if not exist $(OUTD) mkdir $(OUTD)
$(OUTD)/$(name).exe: $(OUTD)/main.obj $(proj_obj)
$(LINK) @<<
$(LOPTD)
format windows pe runtime console
file { $(OUTD)/main.obj $(proj_obj) } name $@
Libpath $(WATCOM)\lib386\nt;$(WATCOM)\lib386
Library kernel32.lib
op quiet, stack=0x40000, heapsize=0x100000, map=$^*, norelocs
com stack=0x1000
disable 171
!ifndef NOGBL
sort global
!endif
op statics
!ifndef WLINK
segment CONST readonly
segment CONST2 readonly
!endif
<<
!if $(DEBUG)
@if not exist TEST mkdir TEST
copy $(OUTD)\$(name).exe TEST\*.* >NUL
copy $(OUTD)\$(name).sym TEST\*.* >NUL
!endif
$(OUTD)/$(name)d.exe: $(OUTD)/main.obj $(proj_obj)
$(LINK) @<<
$(LOPTD)
!ifndef WLINK
format windows pe hx runtime console
!else
format windows pe runtime console
!endif
file { $(OUTD)/main.obj $(proj_obj) } name $@
Libpath $(WATCOM)\lib386\nt;$(WATCOM)\lib386
Libfile cstrtwhx.obj
libpath $(HXDIR)\lib
Library imphlp.lib, dkrnl32s.lib, HXEmu387.lib
reference EMUInit
op quiet, stack=0x40000, heapsize=0x40000, map=$^*, stub=$(HXDIR)\Bin\loadpex.bin
sort global op statics
!ifndef WLINK
segment CONST readonly
segment CONST2 readonly
!endif
<<
!ifdef WLINK
# $(HXDIR)\Bin\pestub.exe -x -z -n $@
pestub.exe -x -z -n $@
!endif
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
$(CC) msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h H/opndcls.h H/instravx.h
$(CC) reswords.c
######
clean: .SYMBOLIC
@if exist $(OUTD)\$(name).exe erase $(OUTD)\$(name).exe
@if exist $(OUTD)\$(name)d.exe erase $(OUTD)\$(name)d.exe
@if exist $(OUTD)\$(name).map erase $(OUTD)\$(name).map
@if exist $(OUTD)\$(name)d.map erase $(OUTD)\$(name)d.map
@if exist $(OUTD)\*.obj erase $(OUTD)\*.obj

167
Msvc.mak Normal file
View File

@ -0,0 +1,167 @@
# this makefile (NMake) creates the JWasm Win32 binary with MS Visual C++.
# it has been tested with:
# - VC++ 5
# - VC++ 6
# - VC++ Toolkit 2003 ( = VC++ 7.1 )
# - VC++ 2005 EE ( not recommended; creates slow binary )
# - VC++ 2008 EE ( not recommended; creates slow binary )
#
# optionally, a DOS binary can be created. Then the HXDEV package is needed.
#
# to use jwlink instead of MS link, enter: "nmake -f msvc.mak mslink=0
# to additionally create a DOS binary, enter: "nmake -f msvc.mak dos=1 mslink=0"
name = jwasm
WIN=1
!ifndef DOS
DOS=0
!endif
!ifndef MSLINK
MSLINK=1
!endif
# directory paths to adjust
# VCDIR - root directory for VC compiler, linker, include and lib files
# W32LIB - directory for Win32 import library files (kernel32.lib).
# Default is WinInc ( may be changed to the MS Platform SDK ).
# HXDIR - for DOS=1 only: root directory to search for stub LOADPEX.BIN,
# libs DKRNL32S.LIB + IMPHLP.LIB and tool PATCHPE.EXE.
!ifndef VCDIR
VCDIR = \msvc71
!endif
!ifndef W32LIB
W32LIB = \WinInc\Lib
!endif
!if $(DOS)
HXDIR = \HX
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=MSVCD
!else
OUTD=MSVCR
!endif
!endif
inc_dirs = -IH -I"$(VCDIR)\include"
linker = $(VCDIR)\Bin\link.exe
lib = $(VCDIR)\Bin\lib.exe
!ifndef TRMEM
TRMEM=0
!endif
!if $(DEBUG)
#extra_c_flags = -Zi -Od -DDEBUG_OUT -FAa -Fa$*
extra_c_flags = -Z7 -Od -DDEBUG_OUT
!else
extra_c_flags = -O2 -Gs -DNDEBUG
#extra_c_flags = -Ox -DNDEBUG
!endif
!if $(TRMEM)
extra_c_flags = $(extra_c_flags) -DTRMEM -DFASTMEM=0
!endif
c_flags =-D__NT__ $(extra_c_flags)
# if MSVC++ 2005 EE is used:
# 1. define __STDC_WANT_SECURE_LIB__=0 to avoid "deprecated" warnings
# 2. define -GS- to disable security checks
#c_flags =-D__NT__ $(extra_c_flags) -D__STDC_WANT_SECURE_LIB__=0 -GS-
#########
# linker option /OPT:NOWIN98 is not accepted by all MS linkers
#LOPT = /NOLOGO
LOPT = /NOLOGO /OPT:NOWIN98
!if $(DEBUG)
LOPTD = /debug
!endif
lflagsd = $(LOPTD) /SUBSYSTEM:CONSOLE $(LOPT) /map:$^*.map /Libpath:$(HXDIR)\lib
lflagsw = $(LOPTD) /SUBSYSTEM:CONSOLE $(LOPT) /map:$^*.map
CC=$(VCDIR)\bin\cl.exe -c -nologo $(inc_dirs) $(c_flags)
.c{$(OUTD)}.obj:
@$(CC) -Fo$* $<
proj_obj = \
!include msmod.inc
!if $(TRMEM)
proj_obj = $(proj_obj) $(OUTD)/trmem.obj
!endif
!if $(WIN)
TARGET1=$(OUTD)\$(name).exe
!endif
!if $(DOS)
TARGET2=$(OUTD)\$(name)d.exe
!endif
ALL: $(OUTD) $(TARGET1) $(TARGET2)
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).exe : $(OUTD)/main.obj $(OUTD)/$(name).lib
!if $(MSLINK)
@$(linker) @<<
$(lflagsw) $(OUTD)/main.obj $(OUTD)/$(name).lib
/LIBPATH:"$(VCDIR)/Lib" "$(W32LIB)/kernel32.lib" /OUT:$@
<<
!else
@jwlink @<<
format windows pe file $(OUTD)/main.obj
name $@
lib $(OUTD)/$(name).lib
libpath "$(VCDIR)/Lib" lib "$(W32LIB)/kernel32.lib"
op start=_mainCRTStartup, norelocs, eliminate, map=$(OUTD)/$(name).map
#sort global op statics
disable 173
<<
!endif
$(OUTD)\$(name)d.exe : $(OUTD)/main.obj $(OUTD)/$(name).lib
!if $(MSLINK)
@$(linker) @<<
$(lflagsd) /NODEFAULTLIB initw32.obj $(OUTD)/main.obj $(OUTD)/$(name).lib /LIBPATH:$(VCDIR)\Lib
libc.lib oldnames.lib /LIBPATH:$(HXDIR)\Lib imphlp.lib dkrnl32s.lib /STUB:$(HXDIR)\Bin\LOADPEX.BIN
/OUT:$@ /FIXED:NO
<<
@$(HXDIR)\bin\patchpe $@
!else
@jwlink @<<
format windows pe hx file $(HXDIR)/lib/initw32.obj, $(OUTD)/main.obj name $@ lib $(OUTD)/$(name).lib
libpath $(VCDIR)/Lib
libpath $(HXDIR)/Lib lib imphlp.lib, dkrnl32s.lib, hxemu387.lib reference EMUInit
op start=_start, eliminate, map=$(OUTD)/$(name)d.map, stub=$(HXDIR)\Bin\LOADPEX.BIN
<<
!endif
$(OUTD)\$(name).lib : $(proj_obj)
@$(lib) /nologo /out:$(OUTD)\$(name).lib $(proj_obj)
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
@$(CC) -Fo$* msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h H/opndcls.h H/instravx.h
@$(CC) -Fo$* reswords.c
######
clean:
@erase $(OUTD)\*.exe
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

109
Msvc64.mak Normal file
View File

@ -0,0 +1,109 @@
# this makefile (NMake) creates the JWasm Win64 binary with MS Visual Studio 2010.
name = jwasm
# directory paths to adjust
# VCDIR - root directory for VC include and lib files.
# W64LIB - directory for Win64 import library files (kernel32.lib, ...).
# Default is WinInc ( may be changed to the MS Platform SDK ).
# PLEASE NOTE: I didn't install the whole MS Visual Studio stuff,
# just copied the VC branch to D:\MSVC10. However, some binaries
# related to MS symbol files ( mspdbsrv.exe, mspdb100.dll, mspdbcore.dll ),
# which are to be found in \<MSVS root>\Common7\IDE, must then be copied
# manually to a directory in the path ( here: d:\msvc10\bin ).
!ifndef VCDIR
VCDIR = d:\msvc10
!endif
!ifndef W64LIB
W64LIB = \WinInc\Lib64
!endif
VCBIN = $(VCDIR)\bin\x86_amd64
PATH = $(VCDIR)\bin;$(PATH)
# use the MS linker or jwlink
!ifndef MSLINK
MSLINK=1
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=MSVC64D
!else
OUTD=MSVC64R
!endif
!endif
inc_dirs = -IH -I"$(VCDIR)\include"
linker = $(VCBIN)\link.exe
lib = $(VCBIN)\lib.exe
!if $(DEBUG)
extra_c_flags = -Zd -Od -DDEBUG_OUT -FAa -Fa$*
!else
extra_c_flags = -O2 -Ox -GS- -DNDEBUG
#extra_c_flags = -Ox -DNDEBUG
!endif
c_flags =-D__NT__ $(extra_c_flags)
# if MSVC++ 2005 EE is used:
# 1. define __STDC_WANT_SECURE_LIB__=0 to avoid "deprecated" warnings
# 2. define -GS- to disable security checks
#c_flags =-D__NT__ $(extra_c_flags) -D__STDC_WANT_SECURE_LIB__=0 -GS-
#lflags stuff
#########
LOPT = /NOLOGO
!if $(DEBUG)
LOPTD = /debug
!endif
lflagsw = $(LOPTD) /SUBSYSTEM:CONSOLE $(LOPT) /map:$^*.map
CC=$(VCBIN)\cl.exe -c -nologo $(inc_dirs) $(c_flags)
.c{$(OUTD)}.obj:
@$(CC) -Fo$* $<
proj_obj = \
!include msmod.inc
ALL: $(OUTD) $(OUTD)\$(name).exe
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).exe : $(OUTD)/main.obj $(OUTD)/$(name).lib
!if $(MSLINK)
@$(linker) @<<
$(lflagsw) $(OUTD)/main.obj $(OUTD)/$(name).lib
/LIBPATH:"$(VCDIR)/Lib/amd64" "$(W64LIB)/kernel32.lib" /OUT:$@
<<
!else
@jwlink.exe format windows pe file $(OUTD)/main.obj name $@ lib $(OUTD)/$(name).lib libpath "$(VCDIR)/Lib/amd64" lib "$(W64LIB)/kernel32.lib" op start=mainCRTStartup, norelocs, eliminate, map=$(OUTD)/$(name).map
!endif
$(OUTD)\$(name).lib : $(proj_obj)
@$(lib) /nologo /out:$(OUTD)\$(name).lib $(proj_obj)
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
@$(CC) -Fo$* msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
@$(CC) -Fo$* reswords.c
######
clean:
@erase $(OUTD)\*.exe
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

91
MsvcDll.mak Normal file
View File

@ -0,0 +1,91 @@
# this makefile (NMake) creates the JWasm Win32 dll with MS Visual C++.
# it has been tested with:
# - VC++ Toolkit 2003 ( = VC++ 7.1 )
name = jwasm
# directory paths to adjust
# VCDIR - root directory for VC compiler, linker, include and lib files
# W32LIB - directory for Win32 import library files (kernel32.lib)
!ifndef VCDIR
VCDIR = \msvc71
!endif
!ifndef W32LIB
W32LIB = \wininc\lib
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=MsvcDllD
!else
OUTD=MsvcDllR
!endif
!endif
inc_dirs = -IH -I"$(VCDIR)\include"
linker = $(VCDIR)\Bin\link.exe
lib = $(VCDIR)\Bin\lib.exe
!if $(DEBUG)
extra_c_flags = -Zd -Od -DDEBUG_OUT
!else
extra_c_flags = -O2 -Gs -DNDEBUG
#extra_c_flags = -Ox -DNDEBUG
!endif
c_flags =-D__NT__ -D__SW_BD $(extra_c_flags) $(c_flags64)
# if MSVC++ 2005 EE is used:
# 1. define __STDC_WANT_SECURE_LIB__=0 to avoid "deprecated" warnings
# 2. define -GS- to disable security checks
#c_flags =-D__NT__ $(extra_c_flags) -D__STDC_WANT_SECURE_LIB__=0 -GS-
#lflags stuff
#########
LOPT = /NOLOGO
!if $(DEBUG)
LOPTD = /debug
!endif
lflagsw = $(LOPTD) $(LOPT) /map:$^*.map /OPT:NOWIN98
CC=@$(VCDIR)\bin\cl.exe -c -nologo $(inc_dirs) $(c_flags)
.c{$(OUTD)}.obj:
$(CC) -Fo$* $<
proj_obj = \
!include msmod.inc
ALL: $(OUTD) $(OUTD)\$(name).dll
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).dll : $(OUTD)/$(name)s.lib
$(linker) @<<
$(lflagsw) $(OUTD)/$(name)s.lib
/LIBPATH:"$(VCDIR)\Lib" /DLL "$(W32LIB)/kernel32.lib" /OUT:$@
/EXPORT:AssembleModule /EXPORT:ParseCmdline /EXPORT:CmdlineFini
<<
$(OUTD)\$(name)s.lib : $(proj_obj)
@$(lib) /out:$(OUTD)\$(name)s.lib $(proj_obj)
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
$(CC) -Fo$* msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
$(CC) -Fo$* reswords.c
######
clean:
@erase $(OUTD)\*.dll
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

80
OC.mak Normal file
View File

@ -0,0 +1,80 @@
# this makefile (NMake) creates the JWasm Win32 binary with Orange C.
name = jwasm
# directory paths to adjust
# CCDIR - root directory for compiler, linker, include and lib files
!ifndef CCDIR
CCDIR = \OC386
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=OCD
!else
OUTD=OCR
!endif
!endif
inc_dirs = -IH -I"$(CCDIR)\include"
linker = $(CCDIR)\bin\olink.exe
!if $(DEBUG)
extra_c_flags = -DDEBUG_OUT
!else
extra_c_flags = -DNDEBUG
!endif
c_flags =-D__NT__ $(extra_c_flags)
#lflags stuff
#########
LOPT =
!if $(DEBUG)
LOPTD =
!endif
lflagsw = $(LOPTD) $(LOPT)
CC=$(CCDIR)\bin\occ.exe /c /C+F -D__OCC__ $(inc_dirs) $(c_flags)
.c{$(OUTD)}.o:
@set ORANGEC=$(CCDIR)
@set PATH=$(CCDIR)\bin;%PATH%
@$(CC) -o$* $<
!include gccmod.inc
ALL: $(OUTD) $(OUTD)\$(name).exe
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).exe : $(OUTD)/main.o $(proj_obj)
@set ORANGEC=$(CCDIR)
@set PATH=$(CCDIR)\bin;%PATH%
$(linker) /c /T:CON32 /m /o$(OUTD)\$(name) @<<
$(lflagsw) /L$(CCDIR)\Lib $(OUTD)\main.o $(proj_obj:/=\) c0xpe.o "clwin.l" "climp.l"
<<
$(OUTD)/msgtext.o: msgtext.c H/msgdef.h H/globals.h
@set ORANGEC=$(CCDIR)
@set PATH=$(CCDIR)\bin;%PATH%
@$(CC) -o$* msgtext.c
$(OUTD)/reswords.o: reswords.c H/instruct.h H/special.h H/directve.h
@set ORANGEC=$(CCDIR)
@set PATH=$(CCDIR)\bin;%PATH%
@$(CC) -o$* reswords.c
######
clean:
@erase $(OUTD)\*.exe
@erase $(OUTD)\*.o
@erase $(OUTD)\*.map

90
OWDOS16.mak Normal file
View File

@ -0,0 +1,90 @@
# this makefile creates a DOS 16-bit real-mode version of JWasm (JWASMR.EXE).
# tools used:
# - Open Watcom v1.8/v1.9
name = JWasm
!ifndef WATCOM
WATCOM = \Watcom
!endif
!ifndef DEBUG
DEBUG=0
!endif
!if $(DEBUG)
OUTD=OWDOS16D
!else
OUTD=OWDOS16R
!endif
inc_dirs = -IH -I$(WATCOM)\H
# to track memory leaks, the Open Watcom TRMEM module can be included.
# it's useful only if FASTMEM=0 is set, though, otherwise most allocs
# won't use the C heap.
!ifndef TRMEM
TRMEM=0
!endif
LINK = $(WATCOM)\binnt\wlink.exe
#cflags stuff
#########
extra_c_flags =
!if $(DEBUG)
!if $(TRMEM)
extra_c_flags += -od -d2 -DDEBUG_OUT -DTRMEM
!else
extra_c_flags += -od -d2 -DDEBUG_OUT
!endif
!else
extra_c_flags += -obmilrs -s -DNDEBUG
!endif
#########
!if $(DEBUG)
LOPTD = debug dwarf op symfile
!endif
lflagsd = $(LOPTD) sys dos op map=$^*, stack=0x8400
CC=$(WATCOM)\binnt\wcc -q -0 -w3 -zc -ml -bc -bt=dos $(inc_dirs) $(extra_c_flags) -fo$@ -DFASTMEM=0 -DFASTPASS=0 -DCOFF_SUPPORT=0 -DELF_SUPPORT=0 -DAMD64_SUPPORT=0 -DSSSE3SUPP=0 -DSSE4SUPP=0 -DOWFC_SUPPORT=0 -DDLLIMPORT=0 -DAVXSUPP=0 -DPE_SUPPORT=0 -DVMXSUPP=0 -DSVMSUPP=0 -DCVOSUPP=0 -DCOMDATSUPP=0 -DSTACKBASESUPP=0 -zt=12000
.c{$(OUTD)}.obj:
@$(CC) $<
proj_obj = &
!include owmod.inc
!if $(TRMEM)
proj_obj += $(OUTD)/trmem.obj
!endif
ALL: $(OUTD) $(OUTD)/$(name)r.exe
$(OUTD):
@if not exist $(OUTD) mkdir $(OUTD)
$(OUTD)/$(name)r.exe: $(OUTD)/$(name).lib $(OUTD)/main.obj
@set LIB=$(WATCOM)\Lib286;$(WATCOM)\Lib286\DOS
@$(LINK) $(lflagsd) file $(OUTD)/main.obj name $@ lib $(OUTD)/$(name).lib
$(OUTD)/$(name).lib: $(proj_obj)
@cd $(OUTD)
@wlib -q -n $(name).lib $(proj_obj:$(OUTD)/=+)
@cd ..
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
@$(CC) msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
@$(CC) reswords.c
######
clean: .SYMBOLIC
@if exist $(OUTD)\*.obj erase $(OUTD)\*.obj
@if exist $(OUTD)\$(name)r.exe erase $(OUTD)\$(name)r.exe
@if exist $(OUTD)\$(name)r.map erase $(OUTD)\$(name)r.map

98
OWLinux.mak Normal file
View File

@ -0,0 +1,98 @@
# this makefile (WMake) creates the Linux binary of JWasm.
# Open Watcom v1.8-v1.9 may be used.
name = jwasm
!ifndef WATCOM
WATCOM=\Watcom
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=OWLinuxD
!else
OUTD=OWLinuxR
!endif
!endif
# calling convention for compiler: s=Stack, r=Register
CCV=r
inc_dirs = -IH -I$(WATCOM)\LH
# to track memory leaks, the Open Watcom TRMEM module can be included
!ifndef TRMEM
TRMEM=0
!endif
!ifdef JWLINK
LINK = jwlink.exe
c_flags = -zc
!else
LINK = $(WATCOM)\Binnt\wlink.exe
c_flags = -zc
!endif
#cflags stuff
#########
extra_c_flags =
!if $(DEBUG)
extra_c_flags += -od -d2 -DDEBUG_OUT
!else
extra_c_flags += -ot -s -DNDEBUG
!endif
!if $(TRMEM)
extra_c_flags += -DTRMEM -DFASTMEM=0
!endif
#lflags stuff
#########
!if $(DEBUG)
LOPTD = debug dwarf op symfile
!endif
CC = $(WATCOM)\Binnt\wcc386 -q -3$(CCV) $(c_flags) -bc -bt=linux $(inc_dirs) $(extra_c_flags) -fo$@
.c{$(OUTD)}.obj:
$(CC) $<
proj_obj = &
!include owmod.inc
!if $(TRMEM)
proj_obj += $(OUTD)/trmem.obj
!endif
ALL: $(OUTD) $(OUTD)/$(name)
$(OUTD):
@if not exist $(OUTD) mkdir $(OUTD)
$(OUTD)/$(name) : $(OUTD)/main.obj $(proj_obj)
$(LINK) @<<
format elf runtime linux
$(LOPTD)
libpath $(WATCOM)/lib386
libpath $(WATCOM)/lib386/linux
op map=$^*, norelocs, quiet, stack=0x20000
file { $(OUTD)/main.obj $(proj_obj) }
name $@.
<<
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
$(CC) msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
$(CC) reswords.c
######
clean: .SYMBOLIC
@if exist $(OUTD)\*. erase $(OUTD)\*.
@if exist $(OUTD)\*.obj erase $(OUTD)\*.obj
@if exist $(OUTD)\*.map erase $(OUTD)\*.map

88
OWOS2.mak Normal file
View File

@ -0,0 +1,88 @@
# this makefile creates the 32bit OS/2 binary of JWasm.
# tools used:
# - Open Watcom v1.8/v1.9
# Note that this makefile assumes that the OW environment is
# set - the OW tools are to be found in the PATH and the INCLUDE
# environment variable is set correctly.
# 2011-07-09 -- rousseau at ecomstation.com -- fixed some stuff.
# - Removed a trailing space after the '&' in the object-list on the
# line with '$(OUTD)/omffixup.obj' that breaks wmake v1.9.
# - Added '.SYMBOLIC' to 'clean:' to supress dependency checking.
# - Added check for existence of files to 'clean:' to supress
# abort when files are not found.
# - Replaced 'erase' with 'del' in 'clean:' as this is the more common name.
name = JWasm
!ifndef DEBUG
DEBUG=0
!endif
!if $(DEBUG)
OUTD=OWOS2D
!else
OUTD=OWOS2R
!endif
# calling convention for compiler: s=Stack, r=register
# r will create a slightly smaller binary
CCV=r
inc_dirs = -IH
LINK = wlink.exe
#cflags stuff
#########
extra_c_flags =
!if $(DEBUG)
extra_c_flags += -od -d2 -DDEBUG_OUT
!else
extra_c_flags += -obmilrt -s -DNDEBUG
!endif
#########
LOPT = op quiet
!if $(DEBUG)
LOPTD = debug dwarf op symfile
!endif
lflagso = $(LOPTD) system os2v2 $(LOPT) op map=$^*
CC=wcc386 -q -3$(CCV) -bc -bt=os2 $(inc_dirs) $(extra_c_flags) -fo$@
.c{$(OUTD)}.obj:
$(CC) $<
proj_obj = &
!include owmod.inc
TARGET1=$(OUTD)/$(name).exe
ALL: $(OUTD) $(TARGET1)
$(OUTD):
@if not exist $(OUTD) mkdir $(OUTD)
$(TARGET1): $(OUTD)/main.obj $(proj_obj)
$(LINK) @<<
$(lflagso) file { $(OUTD)/main.obj $(proj_obj) } name $@ op stack=0x20000
<<
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/globals.h
$(CC) msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
$(CC) reswords.c
######
clean: .SYMBOLIC
@if exist $(OUTD)\*.exe del $(OUTD)\*.exe
@if exist $(OUTD)\*.obj del $(OUTD)\*.obj
@if exist $(OUTD)\*.map del $(OUTD)\*.map

85
OWWinDll.mak Normal file
View File

@ -0,0 +1,85 @@
# this makefile in OW WMake style creates JWASM.DLL (Win32)
# tools used:
# - Open Watcom v1.8/v1.9
name = JWasm
# Open Watcom root directory
!ifndef WATCOM
WATCOM = \Watcom
!endif
!ifndef DEBUG
DEBUG=0
!endif
!ifndef OUTD
!if $(DEBUG)
OUTD=OWWinDllD
!else
OUTD=OWWinDll
!endif
!endif
# calling convention for compiler: s=Stack, r=register
# r will create a slightly smaller binary
CCV=r
inc_dirs = -IH -I$(WATCOM)\H
LINK = $(WATCOM)\binnt\wlink.exe
#cflags stuff
#########
extra_c_flags =
!if $(DEBUG)
extra_c_flags += -od -d2 -w3 -DDEBUG_OUT
!else
extra_c_flags += -ox -s -DNDEBUG
!endif
#########
LOPT = op quiet
!if $(DEBUG)
# for OW v1.8, the debug version needs user32.lib to resolve CharUpperA()
# without it, WD(W) will crash immediately.
LOPTD = debug dwarf op symfile lib user32.lib
!endif
lflagsw = $(LOPTD) format windows pe dll $(LOPT) op map=$^*, offset=0x5000000 export AssembleModule='_AssembleModule@4', ParseCmdline='_ParseCmdline@8', CmdlineFini='_CmdlineFini@0'
CC=$(WATCOM)\binnt\wcc386 -q -3$(CCV) -bd -zc -bt=nt $(inc_dirs) $(extra_c_flags) -fo$@
.c{$(OUTD)}.obj:
$(CC) $<
proj_obj = &
!include owmod.inc
ALL: $(OUTD) $(OUTD)/$(name).dll
$(OUTD):
@if not exist $(OUTD) mkdir $(OUTD)
$(OUTD)/$(name).dll: $(proj_obj)
$(LINK) @<<
$(lflagsw) file { $(proj_obj) } name $@
Libpath $(WATCOM)\lib386
Libpath $(WATCOM)\lib386\nt
Library kernel32, user32
<<
$(OUTD)/msgtext.obj: msgtext.c H/msgdef.h H/usage.h H/globals.h
$(CC) msgtext.c
$(OUTD)/reswords.obj: reswords.c H/instruct.h H/special.h H/directve.h
$(CC) reswords.c
######
clean:
@erase $(OUTD)\*.dll
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

39
PCC.mak Normal file
View File

@ -0,0 +1,39 @@
# This makefile (NMake) creates the JWasm Win32 binary with PCC.
name = jwasm
!ifndef PCCROOT
PCCROOT = \pcc
!endif
!ifndef DEBUG
DEBUG=0
!endif
!if $(DEBUG)
OUTD=PCCD
!else
OUTD=PCCR
!endif
inc_dirs = -IH -I"$(PCCROOT)\include"
!if $(DEBUG)
extra_c_flags = -g -DDEBUG_OUT
!else
extra_c_flags = -DNDEBUG
!endif
CC=$(PCCROOT)\bin\pcc.exe $(inc_dirs) -D__NT__ $(extra_c_flags)
ALL: $(OUTD) $(OUTD)\$(name).exe
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).exe: *.c
set PCCDIR=$(PCCROOT)
$(CC) -o $(OUTD)\$(name).exe *.c
clean:
@erase $(OUTD)\$(name).exe

88
PellesC.mak Normal file
View File

@ -0,0 +1,88 @@
# This makefile creates the JWasm Win32 or Win64 binary with PellesC.
# Enter
# pomake -f PellesC.mak
# to create the Win32 version. Or enter
# pomake -f PellesC.mak amd64=1
# to create the Win64 version.
#
# Optionally, with 'pomake -f PellesC.mak DOS' one can additionally
# create a JWasm DOS binary (32-bit only. This needs the HXDEV package
# (see HXDIR below).
name = jwasm
# directory paths to adjust
# PODIR - root directory for compiler, linker, include and lib files
!ifndef PODIR
PODIR = \PellesC
!endif
!ifdef AMD64
TARGET=/Tamd64-coff
!endif
!ifdef DEBUG
OUTD=POCD
extra_c_flags = -Zi -DDEBUG_OUT $(TARGET)
LOPTD = /debug
!else
OUTD=POCR
extra_c_flags = -O2 -DNDEBUG $(TARGET)
LOPTD =
!endif
inc_dirs = -IH -I"$(PODIR)\include"
LINK = $(PODIR)\Bin\polink.exe
LIB = $(PODIR)\Bin\polib.exe
# options:
# -Ze enable MS extensions
# -J default type of char is unsigned
# -std:C99 use C99, not C11
c_flags =-D__NT__ -Ze -J -std:C99 $(extra_c_flags)
lflagsw = $(LOPTD) /SUBSYSTEM:CONSOLE /map:$*.map
CC=$(PODIR)\bin\pocc.exe $(inc_dirs) $(c_flags)
.c{$(OUTD)}.obj:
$(CC) -Fo$*.obj $<
proj_obj = \
!include msmod.inc
!ifdef DOS
# directory where HXDEV has been installed.
HXDIR=\hx
DOSTARG=$(OUTD)\$(name)d.exe
lflagsd = $(LOPTD) /NODEFAULTLIB /FIXED:NO /SUBSYSTEM:CONSOLE /map:$*.map /STUB:$(HXDIR)\bin\loadpex.bin /LIBPATH:$(HXDIR)\Lib dkrnl32s.lib imphlp.lib /STACK:0x40000,0x1000 /HEAP:0x1000,0x1000
!endif
all: $(OUTD) $(OUTD)\$(name).exe $(DOSTARG)
$(OUTD):
@mkdir $(OUTD)
$(OUTD)\$(name).exe : $(OUTD)\main.obj $(OUTD)\$(name).lib
!ifdef AMD64
$(LINK) $(lflagsw) $(OUTD)\main.obj $(OUTD)\$(name).lib /LIBPATH:$(PODIR)\Lib /LIBPATH:$(PODIR)\Lib\Win64 /OUT:$@
!else
$(LINK) $(lflagsw) $(OUTD)\main.obj $(OUTD)\$(name).lib /LIBPATH:$(PODIR)\Lib /LIBPATH:$(PODIR)\Lib\Win /OUT:$@
!endif
$(OUTD)\$(name)d.exe : $(OUTD)\main.obj $(OUTD)\$(name).lib
@$(LINK) $(lflagsd) $(HXDIR)\Lib\initw32.obj $(OUTD)\main.obj $(OUTD)\$(name).lib /LIBPATH:$(PODIR)\Lib crt.lib /OUT:$@
@$(HXDIR)\bin\patchpe $*.exe
$(OUTD)\$(name).lib : $(proj_obj)
@$(LIB) /out:$(OUTD)\$(name).lib $(proj_obj)
######
clean:
@erase $(OUTD)\*.exe
@erase $(OUTD)\*.obj
@erase $(OUTD)\*.map

175
Readme.txt Normal file
View File

@ -0,0 +1,175 @@
JWasm Readme
1. About JWasm
JWasm is intended to be a free Masm-compatible assembler. It supports
16-, 32- and 64-bit code generation and instructions up to AVX.
Various output formats are supported:
format option comment
-----------------------------------------------------------------------
OMF -omf (default) object format, 16- and 32-bit supported
BIN -bin plain binary format (boot sector, BIOS, DOS COM)
COFF -coff MS Win32 object format
WIN64 -win64 MS Win64 object format
MZ -mz DOS native binary format (.EXE)
PE -pe Win32/Win64 PE binary format
ELF32 -elf Linux 32-bit object format
ELF64 -elf64 Linux 64-bit object format
DJGPP -djgpp Djgpp's 32-bit COFF variant (optional).
JWasm is distributed in several packages. Besides the source package
there are some which contain precompiled binaries for Windows, DOS and
Linux. Other OSes like OS/2 and FreeBSD are also supported, but no binary
is supplied, it must be created from the sources.
JWasm has its roots in Open Watcom's Wasm. The source is released under
the Sybase Open Watcom Public License (see license.txt for details).
2. Requirements
- JWASM.EXE, a precompiled Win32 binary, should run on any 32- or 64-bit
Windows.
- JWASMD.EXE, a precompiled DOS binary, runs in DOS 32bit protected-mode.
It requires a 80386 cpu and needs a MS-DOS v5 compatible DOS to run
(FreeDOS v1 will do). Long filenames (LFN) are supported. JWASMD.EXE
won't run on 64-bit Windows.
- JWASMR.EXE is a DOS real-mode program which runs on any x86 cpu.
Similar to JWASMD.EXE it needs a MS-DOS v5 compatible DOS. This version
has some restrictions, to limit the amount of memory the binary will need.
Memory requirements depend on the source which is assembled. The source
itself is not kept in memory, but the symbol table is, and this table
can easily grow to several MBs if huge amounts of equates are defined.
That's why JWASMR.EXE might be unable to assemble large sources.
3. Installation
The precompiled binaries are supplied as a compressed file. The simplest
and best approach to "install" JWasm is to create a directory named JWasm,
copy the compressed file ( i.e. jwasm205w.zip ) into this directory and
"unzip" it. If you want to run JWasm without having to type the full path
name, you'll either have to add the JWasm directory to your PATH
environment variable or to copy the JWasm binary to a directory that's
included in your PATH.
If you want to deinstall JWasm, delete the JWasm directory. If you had
added the directory to your PATH environment variable, remove it from
there.
4. Documentation
JWasm's documentation consists of
- Readme.txt (this file)
- a Manual, which describes the differences to Masm. It may be in
HTML (Manual.html) or Windows HTMLHelp (JWasm.ch*) format.
- History.txt, which describes bugfixes and changes of all JWasm versions.
- License.txt, which is a copy of the Sybase Open Watcom Public License.
5. Samples
The binary packages contain samples in subdirectory SAMPLES.
For output formats other than BIN, MZ or PE, JWasm's output has to be
linked to create an executable binary. The following set of linkers
have been verified to cooperate with JWasm:
Format Linker Comment
-------------------------------------------------------------
OMF Wlink contained in Open Watcom, free, open source
OMF ALink by A. Williams, free
OMF ValX by David Lindauer (Ladsoft), free
OMF OptLink from Digital Mars, free
OMF Link16 the old OMF linker (v5.60) from Microsoft
OMF TLink from Borland
COFF Wlink this linker accepts OMF and COFF modules
COFF MS Link will also accept OMF modules
COFF PoLink supplied with PellesC, free
WIN64 MS Link must be version 7.10 or newer
WIN64 Polink must be version 5 or newer
WIN64 JWlink fork of OW Wlink
ELF32 LD the GNU linker
ELF64 LD the GNU linker
ELF64 JWlink fork of OW Wlink
Note that the name of the MS OMF linker binary is LINK.EXE, identical
to the MS COFF linker name.
6. How to Create the JWasm Binaries
JWasm is written in C. It's virtually C89, but 64-bit integers and
structures/unions as unnamed members of structures/unions must be
supported by the compiler.
The following Makefiles are supplied in the source package:
name tool chain used creates binary for
---------------------------------------------------------------
Makefile Open Watcom v1.8-v1.9 Win32 [, DOS (32-bit)]
OWDOS16.MAK Open Watcom v1.8-v1.9 DOS (16-bit)
OWOS2.MAK Open Watcom v1.8-v1.9 OS/2 (32-bit)
OWLinux.MAK Open Watcom v1.8-v1.9 Linux
OWWinDll.MAK Open Watcom v1.8-v1.9 Win32 (JWasm.dll)
Msvc.MAK VC++ TK 2003/VC++ 2008 EE Win32 [, DOS (32-bit)]
Msvc64.MAK VC++ 2010 Win64
MsvcDll.MAK VC++ TK 2003 Win32 (JWasm.dll)
GccWin.MAK GCC, MinGW/Cygwin Win32
GccWin64.MAK GCC, MinGW-w64 Win64
GccDos.MAK GCC, DJGPP DOS (32-bit)
GccUnix.MAK GCC, FreeBSD/Linux FreeBSD [, Linux]
---------------------------------------------------------------
BCC.MAK Borland C++ Cmdline Tools Win32
OC.MAK Orange C Win32
PCC.MAK PCC Win32
PellesC.MAK Pelles C v7 Win32, Win64
TCC.MAK Tiny C Win32
IntelC32.MAK Intel C++ Compiler, MSVC Win32
IntelC64.MAK Intel C++ Compiler, MSVC Win64
The makefiles that use the OW tool chain are supposed to be run
with Open Watcom's WMake, Msvc*.MAK and IntelC*.MAK should be run with
MS NMAKE, PellesC.MAK expects POMAKE and for Gcc*.MAK GNU make is to be
used.
More detailed information may be found in the makefiles themselves!
Please note that only the binaries created with toolchains Open Watcom,
VC++ and GCC are regularily tested to pass the JWasm regression test.
7. Using JWasm with Visual Studio
a) VS 2005/2008
To integrate JWasm into VS, copy file jwasm.rules to directory
<vc_dir>\VC\VCProjectDefaults. After this is done, JWasm can be
selected as assembler inside the VS IDE.
b) VS 2010/2012
- Unzip file VS2010CustomBuildRule.zip. The result are 3 files,
jwasm.props, jwasm.targets and jwasm.xml.
- Copy those files to MSBUILD's build customization directory.
8. Contributors
These people contributed to JWasm ( additions, bugfixes, bug reports):
agner, BlackVortex, dosfan01, drizz, Paul Edwards, filofel, Peter Flass,
James C. Fuller, gfalen, habran, Japheth, Jimg, jj2007, John Hankinson,
Khusraw, Alex Kozlov, Peter Kuznetsov, misca, Michal Necasek, H. Nidudsson,
Nikitakita, Jose Pascoa, Terry Philips, qWord, RotateRight, Ito Toshimitsu,
Vortex.
Japheth

56
Regress/ABS1.ASO Normal file
View File

@ -0,0 +1,56 @@
;--- invalid operator arguments
.286
.model small
.code
v1 db 0
mov ax, type 0 ;ok
mov ax, seg 0
mov ax, offset 0;ok
mov ax, length 0
mov ax, size 0
mov ax, lengthof 0
mov ax, sizeof 0
mov ax, seg bx
mov ax, offset bx
mov ax, length bx
mov ax, size bx
mov ax, lengthof bx
mov ax, sizeof bx
mov al, HIGH bx
mov al, LOW bx]
mov ax, HIGHWORD bx
mov ax, LOWWORD bx
mov ax, seg [bx]
mov ax, offset [bx]
mov ax, length [bx]
mov ax, size [bx]
mov ax, lengthof [bx]
mov ax, sizeof [bx]
mov al, HIGH [bx]
mov al, LOW [bx]
mov ax, HIGHWORD [bx]
mov ax, LOWWORD [bx]
mov ax, seg _TEXT ;ok
mov ax, offset _TEXT ;ok
mov ax, length _TEXT ;expected data label
mov ax, size _TEXT ;expected data label
mov ax, lengthof _TEXT ;expected data label
mov ax, sizeof _TEXT ;expected data label
mov al, HIGH _TEXT ;should be an error
mov al, LOW _TEXT ;should be an error
mov ax, HIGHWORD _TEXT
mov ax, LOWWORD _TEXT ;should be an error
mov ax, length (v1+1) ;should be an error, but is currently accepted
end

30
Regress/ABS1.EXP Normal file
View File

@ -0,0 +1,30 @@
ABS1.ASO(13) : Error A2228: Invalid operand for SEG: 0
ABS1.ASO(16) : Error A2228: Invalid operand for LENGTH: 0
ABS1.ASO(17) : Error A2228: Invalid operand for SIZE: 0
ABS1.ASO(18) : Error A2228: Invalid operand for LENGTHOF: 0
ABS1.ASO(19) : Error A2228: Invalid operand for SIZEOF: 0
ABS1.ASO(21) : Error A2228: Invalid operand for SEG: bx
ABS1.ASO(22) : Error A2228: Invalid operand for OFFSET: bx
ABS1.ASO(23) : Error A2228: Invalid operand for LENGTH: bx
ABS1.ASO(24) : Error A2228: Invalid operand for SIZE: bx
ABS1.ASO(25) : Error A2228: Invalid operand for LENGTHOF: bx
ABS1.ASO(26) : Error A2228: Invalid operand for SIZEOF: bx
ABS1.ASO(27) : Error A2228: Invalid operand for HIGH: bx
ABS1.ASO(28) : Error A2228: Invalid operand for LOW: bx
ABS1.ASO(29) : Error A2228: Invalid operand for HIGHWORD: bx
ABS1.ASO(30) : Error A2228: Invalid operand for LOWWORD: bx
ABS1.ASO(32) : Error A2228: Invalid operand for SEG: [bx]
ABS1.ASO(33) : Error A2228: Invalid operand for OFFSET: [bx]
ABS1.ASO(34) : Error A2228: Invalid operand for LENGTH: [bx]
ABS1.ASO(35) : Error A2228: Invalid operand for SIZE: [bx]
ABS1.ASO(36) : Error A2228: Invalid operand for LENGTHOF: [bx]
ABS1.ASO(37) : Error A2228: Invalid operand for SIZEOF: [bx]
ABS1.ASO(38) : Error A2228: Invalid operand for HIGH: [bx]
ABS1.ASO(39) : Error A2228: Invalid operand for LOW: [bx]
ABS1.ASO(40) : Error A2228: Invalid operand for HIGHWORD: [bx]
ABS1.ASO(41) : Error A2228: Invalid operand for LOWWORD: [bx]
ABS1.ASO(45) : Error A2232: Expected data label
ABS1.ASO(46) : Error A2232: Expected data label
ABS1.ASO(47) : Error A2232: Expected data label
ABS1.ASO(48) : Error A2232: Expected data label
ABS1.ASO(51) : Error A2228: Invalid operand for HIGHWORD: _TEXT

26
Regress/ABSEXT.ASO Normal file
View File

@ -0,0 +1,26 @@
;--- "absolute" externals
.286
.model small
externdef E1:abs
.code
mov ax, seg E1 ;is to fail
mov ax, offset E1
mov ax, low E1
mov ax, high E1
mov ax, lowword E1
mov ax, highword E1 ;is to fail
mov ax, type E1
mov ax, opattr E1
mov ax, .type E1
mov ax, length E1
mov ax, size E1
mov ax, lengthof E1 ;jwasm rejects
mov ax, sizeof E1 ;jwasm rejects
end

4
Regress/ABSEXT.EXP Normal file
View File

@ -0,0 +1,4 @@
ABSEXT.ASO(11) : Error A2188: Operand must be relocatable
ABSEXT.ASO(16) : Error A2228: Invalid operand for HIGHWORD: E1
ABSEXT.ASO(23) : Error A2232: Expected data label
ABSEXT.ASO(24) : Error A2232: Expected data label

Some files were not shown because too many files have changed in this diff Show More