Skip to content

Commit 97cf364

Browse files
author
John Hankinson
committed
initial 2.13 commit
0 parents  commit 97cf364

File tree

421 files changed

+285923
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

421 files changed

+285923
-0
lines changed

.vs/HJWasm/v14/.suo

80.5 KB
Binary file not shown.

Doc/enh.txt

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
2+
Possible Enhancements for JWasm
3+
4+
1. support UNICODE strings. Similar to PoAsm? Most likely no,
5+
since using the DB/DW directives to define such strings
6+
doesn't seem to be the best strategy. Might be better to
7+
have an extra type for unicode strings (tchar), in
8+
conjunction with a cmdline option to switch ansi/unicode.
9+
10+
2. [ done, was: option FPO (frame pointer omission); has
11+
become option STACKBASE. ]
12+
13+
3. unnamed RECORD within a STRUCT. Record field names
14+
will be local then and must be unique within the STRUCT. This
15+
feature will ease converting C include files to ASM.
16+
17+
Syntax:
18+
19+
operator WIDTH: ok
20+
operator MASK: ???
21+
22+
S1 STRUCT
23+
f1 dd ?
24+
RECORD bit0:1, bit1:1
25+
S1 ends
26+
27+
mov eax, MASK S1.bit0
28+
or v1.bit0 ???
29+
30+
4. [ done, was: native support for PE binaries ]
31+
32+
5. ASSUME extension
33+
34+
use ASSUME CS:[USE16|USE32|USE64] to change current offset size
35+
without changing segments.
36+
37+
6. FOR extension
38+
39+
Preprocessor extension:
40+
41+
FOR EACH x IN [<struct>|<union>|<record>|<proc>]
42+
...
43+
ENDM
44+
45+
- x is the loop variable, it's a text macro, its value will be
46+
the name of the item.
47+
- the "members" are enumerated. For PROCedures, these are the
48+
parameters, local variables and local labels.

Doc/fixes.txt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
Issues in the source which should be fixed.
3+
4+
1. Backpatching
5+
6+
Currently backpatching handles JMPs and CALLs only. It
7+
is unable to handle PUSHs ( and may be others as well).
8+
So the backpatch routine calculates addresses wrong and
9+
as a result an additional assembly pass is required.
10+
11+
2. Two Pass Minimum
12+
13+
Currently the generated code/data bytes aren't stored in
14+
assembly pass one. So a second pass is always needed.
15+
With better backpatching capabilities, JWasm should be
16+
able to virtually become a one-pass assembler.
17+
18+
[ issue fixed in v2.06
19+
20+
3. Token Buffer
21+
22+
The token buffer is a global variable. This causes
23+
a lot of problems. There are some workarounds implemented
24+
to make the buffer reusable, but these hacks didn't
25+
help to make the code more readable.
26+
]

Doc/gencode.txt

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

Doc/overview.txt

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
2+
A brief overview of JWasm's source code
3+
4+
1. Source files
5+
6+
file comment
7+
-----------------------------------------------------------------------
8+
main.c contains main()
9+
cmdline.c parse command line
10+
assemble.c assembler (generic)
11+
input.c read source file,
12+
preprocessor (generic)
13+
calling preprocessor directives
14+
expans.c (text) macro expansion
15+
tokenize.c tokenizer, COMMENT directive
16+
condasm.c preprocessor conditional directives (IFx, ELSEx, ENDIF )
17+
loop.c preprocessor loop directives (FOR, FORC, REPT, WHILE, ...)
18+
equate.c (preprocessor) EQU and '=' directives
19+
string.c preprocessor string directives (TEXTEQU, CATSTR, SUBSTR, ...)
20+
macro.c preprocessor MACRO and PURGE directives
21+
parser.c parser (generic)
22+
branch.c parsing of branch instructions (JMP, Jcc, CALL, JxxxZ, LOOPx )
23+
expreval.c expression evaluator
24+
25+
assume.c parsing of ASSUME directive
26+
context.c parsing of directives PUSHCONTEXT, POPCONTEXT
27+
cpumodel.c parsing of .MODEL and cpu (.8086, .80186, ...) directives
28+
data.c parsing of data directives (DB, DW, ... ), data labels
29+
handles data generation (+fixups)
30+
directiv.c parsing of various directives which have no other home
31+
end.c parsing of END, .STARTUP and .EXIT directives
32+
extern.c parsing of EXTERN, EXTERNDEF, COMM, PUBLIC, PROTO
33+
hll.c parsing of hll directives (.IF, .ELSE, .WHILE, .REPEAT, ...)
34+
invoke.c parsing of INVOKE directive
35+
labels.c parsing of LABEL directive, code labels
36+
listing.c parsing of listing directives (.LIST, .CREF, ...)
37+
writing of listing file
38+
option.c parsing of OPTION directive
39+
posndir.c parsing of ORG, ALIGN, EVEN directives
40+
proc.c parsing of PROC, ENDP, LOCAL directives
41+
generates procedure prologues and epilogues
42+
safeseh.c parsing of .SAFESEH directive
43+
segment.c parsing of SEGMENT (+ENDS) and GROUP directives
44+
simsegm.c parsing of simplified segment directives (.CODE, .DATA, ...)
45+
types.c parsing of STRUCT (+ENDS), UNION, TYPEDEF, RECORD directives
46+
47+
omf.c handles OMF output format
48+
omffixup.c handles OMF fixup generation
49+
omfint.c handles OMF I/O
50+
coff.c handles COFF output format (32- and 64-bit)
51+
elf.c handles ELF output format (32- and 64-bit)
52+
bin.c handles binary and DOS MZ output format
53+
dbgcv.c handles output of CodeView symbolic debugging info
54+
55+
reswords.c handles access to table of reserved words
56+
symbol.c handles access to - global and local - symbol (hash) table
57+
backptch.c handles backpatching (jump distance optimization)
58+
codegen.c handles instruction code generation (+fixups)
59+
fixup.c fixup creation
60+
fpfixup.c 16-bit floating-point fixup creation
61+
errmsg.c handles assembler error messages (non-fatal)
62+
fatal.c handles fatal assembler errors
63+
memalloc.c handles dynamic memory allocations
64+
tbyte.c handles TBYTE data format (10-byte floating-point format)
65+
queue.c handles internal queues
66+
mangle.c handles symbol name mangling (name decoration)
67+
apiemu.c handles C compiler peculiarities and bugs
68+
69+
70+
2. Calling hierarchy
71+
72+
main
73+
- main_init
74+
- main_fini
75+
- AssembleModule
76+
- AssembleInit
77+
- AssembleFini
78+
- OnePass
79+
- GetPreprocessedLine ( if pass == 1 )
80+
- GetTextLine
81+
- Tokenize ( if pass > 1 )
82+
- ParseLine
83+
- directive
84+
- data_init
85+
- EvalOperand
86+
- EvalOperand()
87+
- codegen()
88+
89+
1. main()
90+
91+
cmdline parsing, wildcards
92+
calls AssembleModule() for each source module.
93+
94+
2. AssembleModule()
95+
96+
assembles one module in at least 2 passes.
97+
98+
3. OnePass()
99+
100+
Executes one pass for a module. Pass one is handled
101+
differently than the others, because the preprocessed
102+
lines are saved in this pass and then read in the
103+
consecutive passes.
104+
105+
4. Tokenize()
106+
107+
The tokenizer. Scans a source line and detects reserved words,
108+
numbers, IDs, operators, literals. Converts the items to tokens
109+
stored in array tokenarray[].
110+
111+
5. GetPreprocessedLine()
112+
113+
This is the preprocessor. It
114+
- reads a line from the current source,
115+
- converts in into tokens ( function Tokenize() )
116+
- calls macro expansion.
117+
- checks if the line contains a preprocessor directive
118+
preprocessor directives are IF, WHILE, REPEAT, INCLUDE,
119+
TEXTEQU, CATSTR, INSTR, ...
120+
- if yes, handles the directive and returns 0.
121+
- if no, returns the number of tokens found in the line
122+
123+
6. ParseLine()
124+
125+
The parser. It does:
126+
- checks if first item is a code label (ID followed by ':'). If yes,
127+
a label is created ( function LabelCreate() ).
128+
- checks if current item is a directive. If yes, calls function
129+
directive() or - if directive is a "data definition directive" -
130+
function data_item()
131+
- checks if current item is predefined type or an arbitrary type.
132+
If yes, calls function data_item().
133+
- if current item is an instruction, it calls the expression
134+
evaluator ( function EvalOperand() ), up to 3 times, to get
135+
the operands.
136+
- if more than 1 operand has been read, function check_sizes()
137+
is called, which verifies that the sizes of the operands will
138+
"match".
139+
- the code generator ( function codegen() ) is called.
140+
141+
7. codegen()
142+
143+
The code generator. This part
144+
- scans the instruction table to find an entry which matches
145+
the number of operands and their types.
146+
- if an entry is found, the code bytes and fixups are generated
147+
and written into a buffer.
148+
149+
8. data_init()
150+
151+
Handles data lines. This is either a data directive ( DB, DW, DD, ...),
152+
a predefined type ( BYTE, WORD, DWORD, ... ) or an arbitrary type, defined
153+
with TYPEDEF, STRUCT, UNION, ....
154+
155+
9. GetTextLine()
156+
157+
Reads a line from the current source. This is either a macro, a source
158+
file or the global line queue, which is used to store generated code.

Doc/srclic.txt

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
JWasm originally was a fork of Wasm. The old Open Watcom Wasm source
3+
was released under the Sybase license (S).
4+
5+
In the meantime, a part of the source contain no lines of
6+
Wasm anymore - they are new or have been completely rewritten. The license
7+
for these files is Public Domain (P).
8+
9+
apiemu.c P
10+
assemble.c P
11+
assume.c S
12+
atofloat.c P
13+
backptch.c S
14+
bin.c P
15+
branch.c S
16+
cmdline.c S
17+
codegen.c S
18+
coff.c P
19+
condasm.c S
20+
context.c P
21+
cpumodel.c P
22+
data.c S
23+
dbgcv.c P
24+
directiv.c P
25+
elf.c P
26+
end.c P
27+
equate.c P
28+
errmsg.c S
29+
expans.c P
30+
expreval.c S
31+
extern.c P
32+
fastpass.c P
33+
fixup.c S
34+
fpfixup.c S
35+
hll.c P
36+
input.c S
37+
invoke.c P
38+
label.c S
39+
linnum.c P
40+
listing.c P
41+
loop.c P
42+
lqueue.c P
43+
macro.c P
44+
main.c P
45+
mangle.c S
46+
memalloc.c P
47+
msgtext.c P
48+
omf.c S
49+
omffixup.c S
50+
omfint.c S
51+
option.c P
52+
parser.c S
53+
posndir.c S
54+
preproc.c P
55+
proc.c P
56+
queue.c S
57+
reswords.c P
58+
safeseh.c P
59+
segment.c S
60+
simsegm.c P
61+
string.c P
62+
symbols.c S
63+
tbyte.c S
64+
tokenize.c S
65+
trmem.c S
66+
types.c P

GccDos.mak

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
# This makefile creates the HJWasm 32-bit DOS binary with DJGPP.
3+
# 'make -f GccDos.mak'
4+
5+
name = hjwasm
6+
7+
ifndef DEBUG
8+
DEBUG=0
9+
endif
10+
11+
inc_dirs = -IH
12+
13+
#cflags stuff
14+
15+
ifeq ($(DEBUG),1)
16+
extra_c_flags = -DDEBUG_OUT -g
17+
OUTD=DJGPPd
18+
else
19+
extra_c_flags = -DNDEBUG -O2
20+
OUTD=DJGPPr
21+
endif
22+
23+
c_flags = $(extra_c_flags)
24+
25+
CC=gcc.exe -c $(inc_dirs) $(c_flags)
26+
27+
$(OUTD)/%.o: %.c
28+
$(CC) -o $(OUTD)/$*.o $<
29+
30+
include gccmod.inc
31+
32+
TARGET1=$(OUTD)/$(name).exe
33+
34+
ALL: $(OUTD) $(TARGET1)
35+
36+
$(OUTD):
37+
mkdir $(OUTD)
38+
39+
$(OUTD)/$(name).exe : $(OUTD)/main.o $(proj_obj)
40+
gcc.exe $(OUTD)/main.o $(proj_obj) -s -o $(OUTD)/$(name).exe -Wl,-Map,$(OUTD)/$(name).map
41+
42+
$(OUTD)/msgtext.o: msgtext.c H/msgdef.h H/globals.h
43+
$(CC) -o $(OUTD)/msgtext.o msgtext.c
44+
45+
$(OUTD)/reswords.o: reswords.c H/instruct.h H/special.h H/directve.h
46+
$(CC) -o $(OUTD)/reswords.o reswords.c
47+
48+
######
49+
50+
clean:
51+
@erase $(OUTD)\*.exe
52+
@erase $(OUTD)\*.obj
53+
@erase $(OUTD)\*.map

0 commit comments

Comments
 (0)