Skip to content

Commit

Permalink
listing: relocations marked in code lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Baron-von-Riedesel committed Jun 12, 2024
1 parent dc2fb6a commit ab8a297
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 112 deletions.
2 changes: 1 addition & 1 deletion GccDos.mak
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extra_c_flags = -DNDEBUG -O2
OUTD=build\DJGPPr
endif

c_flags = -DDJGPP_SUPPORT $(extra_c_flags)
c_flags = $(extra_c_flags)

CC=gcc.exe -c $(inc_dirs) $(c_flags)

Expand Down
3 changes: 2 additions & 1 deletion History.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Changelog

__.__.2024, v2.18:
09.06.2024, v2.18:

Bugfixes:
- omffixup.c, debug version only: a superfluous %s in a debug display
Expand All @@ -28,6 +28,7 @@
- OWDOS32.mak added. Creates a 32-bit version that uses the native Open
Watcom runtime for extended DOS. Open Watcom 2.0 is recommended to
create this variant.
- listing: relocations in code marked with lowercase letters.

25.03.2023, v2.17:

Expand Down
7 changes: 7 additions & 0 deletions Html/Manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,13 @@ <H2 ID="OUTPUTFORMATPE"> 6.5 PE Output Format </H2>
<P>
Sample <A HREF="#AB06">Win64_8</A> shows how a 64-bit Windows binary is created with -pe. It also
shows how to define resources in .rsrc manually and how to modify default values of PE header fields.
<P>
To import functions by number with option -pe, the alias directive has to be used:
<pre>
OPTION DLLIMPORT: &lt;kernel32.dll&gt;
VxDCall1 proto stdcall :dword
ALIAS &lt;kernel32.1&gt; = &lt;VxDCall1&gt;
</pre>


<H1 ID="CHAPMASMBUGS"> 7. Masm bugs fixed in JWasm </H1>
Expand Down
33 changes: 16 additions & 17 deletions Html/Readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
JWasm is intended to be a free Masm-compatible assembler. It supports
16-, 32- and 64-bit code generation and instructions up to AVX.

JWasm is distributed in several packages. Besides the source package
there are some containing precompiled binaries for Windows and DOS.
For other OSes the binary 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 <a href="License.html">license.txt</a> for details).

Various output formats are supported:

format option comment
Expand All @@ -28,33 +35,25 @@
ELF64 -elf64 Linux 64-bit object format
DJGPP -djgpp Djgpp's 32-bit COFF variant

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 <a href="License.html">license.txt</a> for details).


<b>2. Requirements</b>

- JWASM.EXE, a precompiled Win32 binary, should run on any 32- or 64-bit
- 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.
- 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.
(FreeDOS should do). Long filenames (LFN) are supported. JWasmD 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
- JWasmR.exe is a DOS real-mode program which runs on any x86 cpu.
Similar to JWasmD it needs a MS-DOS v5 compatible DOS. This version
has some <A HREF="Manual.html#AE">restrictions</A>, 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.
That's why JWasmR might be unable to assemble large sources.


<b>3. Installation</b>
Expand All @@ -78,8 +77,8 @@
- Readme.txt (this file)
- a Manual, which describes the differences to Masm. It may be in
<a href="Manual.html">HTML</a> (Manual.html) or Windows HTMLHelp (JWasm.ch*) format.
- <a href="History.txt">History.txt</a>, which describes bugfixes and changes of all JWasm versions.
- <a href="License.html">License.txt</a>, which is a copy of the Sybase Open Watcom Public License.
- <a href="History.txt">History.txt</a>, describes bugfixes and changes of all JWasm versions.
- <a href="License.html">License.txt</a>, that's a copy of the Sybase Open Watcom Public License.


<b>5. Samples</b>
Expand Down
8 changes: 3 additions & 5 deletions OWDOS32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Tools used:
# - Open Watcom v2.0
# - jwlink ( OW's wlink might also be used )
# - HXDev ( for modules cstrtdhr.obj and loadpe.bin )
# - HXDev ( for modules cstrtdhr.obj and loadpero.bin )
#
# "WMake debug=1" - creates a debug version.
#
Expand All @@ -19,10 +19,6 @@ name = JWasm
!ifndef WATCOM
WATCOM = \ow20
!endif
# HXDIR must contain the HX root directory
!ifndef HXDIR
HXDIR = \HX
!endif

NOGBL = 1

Expand Down Expand Up @@ -51,6 +47,8 @@ OUTD=Build\OWDOS32R
inc_dirs = -Isrc\H -I$(WATCOM)\H
c_flags = -q -bc -bt=dos -3r -fpi87 -wcd=115 -D__WATCOM_LFN__

# OW's wlink could be used as well, but jwlink can better handle CONST segments in PE file format;
# also, it understands "format windows pe hx" ( which simply produces a 'PX' instead of 'PE' binary )
LINK = jwlink.exe

#cflags stuff
Expand Down
Binary file modified Regression/Regression.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions src/H/fastpass.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ void FreeLineStore( void );

#define FStoreLine( flags ) if ( Parse_Pass == PASS_1 ) StoreLine( CurrSource, flags, 0 ); else

#define FSL_WITHCMT 1

#else

#define FStoreLine( flags )
Expand Down
1 change: 1 addition & 0 deletions src/H/fixup.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ struct fixup {
#endif
unsigned char loader_resolved:1; /* operator LROFFSET */
unsigned char orgoccured:1; /* v2.04 ORG occured behind this fix */
unsigned char size:4; /* v2.18 */
#if FASTMEM==0
unsigned char count:2; /* v2.14 ref count */
#endif
Expand Down
12 changes: 6 additions & 6 deletions src/H/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,16 @@ struct code_info {
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 */
const struct instr_item *pinstr; /* current pointer into InstrTable (=InstrTable[IndexFromToken(token)] */
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;
unsigned char rm_byte; /* rm byte set by set_rm_sib() in parser.c */
unsigned char sib; /* sib byte set by set_rm_sib() in parser.c */
unsigned char Ofssize; /* current offset size */
unsigned char opc_or; /* bit 0 & 2 or'ed with opcode */
#if AVXSUPP
unsigned char vexregop; /* in based-1 format (0=empty) */
unsigned char vexregop; /* in based-1 format (0=empty) */
#endif
union {
unsigned char flags;
Expand Down
15 changes: 7 additions & 8 deletions src/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,11 @@ static void output_data( const struct code_info *CodeInfo, enum operand_type det
size = 4; /* = size of displacement */
#if AMD64_SUPPORT
/* v2.11: overflow check for 64-bit added */
#if defined(LLONG_MAX) || defined(__GNUC__) || defined(__TINYC__)
#if defined(LLONG_MAX) || defined(__GNUC__) || defined(__TINYC__)
if ( CodeInfo->Ofssize == USE64 && CodeInfo->opnd[index].data64 >= 0x80000000 && CodeInfo->opnd[index].data64 < 0xffffffff80000000ULL )
#else
#else
if ( CodeInfo->Ofssize == USE64 && CodeInfo->opnd[index].data64 >= 0x80000000 && CodeInfo->opnd[index].data64 < 0xffffffff80000000ui64 )
#endif
#endif
EmitErr( INVALID_INSTRUCTION_OPERANDS );
#endif
}
Expand Down Expand Up @@ -506,8 +506,9 @@ static void output_data( const struct code_info *CodeInfo, enum operand_type det
CodeInfo->opnd[index].InsFixup->sym ? CodeInfo->opnd[index].InsFixup->sym->name : szNull );
/* don't exit! */
}
CodeInfo->opnd[index].InsFixup->locofs = GetCurrOffset();
CodeInfo->opnd[index].InsFixup->size = size;
if ( write_to_file ) {
CodeInfo->opnd[index].InsFixup->locofs = GetCurrOffset();
OutputBytes( (unsigned char *)&CodeInfo->opnd[index].data32l,
size, CodeInfo->opnd[index].InsFixup );
return;
Expand Down Expand Up @@ -928,8 +929,7 @@ ret_code codegen( struct code_info *CodeInfo, uint_32 oldofs )
/* v2.06: simplified */
if ( tbl_op1 == OP_NONE && opnd1 == OP_NONE ) {
output_opc( CodeInfo );
if ( CurrFile[LST] )
LstWrite( LSTTYPE_CODE, oldofs, NULL );
LstWrite( LSTTYPE_CODE, oldofs, CodeInfo );
return( NOT_ERROR );
} else if ( opnd1 & tbl_op1 ) {
/* for immediate operands, the idata type has sometimes
Expand All @@ -955,8 +955,7 @@ ret_code codegen( struct code_info *CodeInfo, uint_32 oldofs )
break;
}
if( retcode == NOT_ERROR ) {
if ( CurrFile[LST] )
LstWrite( LSTTYPE_CODE, oldofs, NULL );
LstWrite( LSTTYPE_CODE, oldofs, CodeInfo );
return( NOT_ERROR );
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,14 @@ ret_code data_dir( int i, struct asm_tok tokenarray[], struct asym *type_sym )
UpdateStructSize( sym );

if ( ModuleInfo.list )
LstWrite( CurrStruct ? LSTTYPE_STRUCT : LSTTYPE_DATA, currofs, sym );
//LstWrite( CurrStruct ? LSTTYPE_STRUCT : LSTTYPE_DATA, currofs, sym ); /* v2.18: sym not used by LSTTYPE _STRUCT/_DATA */
/* todo: struct members should display useful info in the "code" area.
* Currently just the offset is displayed.
*/
if ( CurrStruct )
LstWrite( LSTTYPE_STRUCT, currofs, NULL );
else
LstWrite( LSTTYPE_DATA, currofs, NULL );

DebugMsg1(("data_dir: exit, no error, label=%s, is_array=%u, Curr%s.ofs=%X\n",
sym ? sym->name : "NULL",
Expand Down
5 changes: 4 additions & 1 deletion src/fastpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ static void SaveState( void )
DebugMsg(( "SaveState exit\n" ));
}

/* flags: b0: 1=store line with comment
*/

void StoreLine( const char *srcline, int flags, uint_32 lst_position )
/********************************************************************/
{
Expand All @@ -83,7 +86,7 @@ void StoreLine( const char *srcline, int flags, uint_32 lst_position )
SaveState();

i = strlen( srcline );
j = ( ( ( flags & 1 ) && ModuleInfo.CurrComment ) ? strlen( ModuleInfo.CurrComment ) : 0 );
j = ( ( ( flags & FSL_WITHCMT ) && ModuleInfo.CurrComment ) ? strlen( ModuleInfo.CurrComment ) : 0 );
LineStoreCurr = LclAlloc( i + j + sizeof( struct line_item ) );
LineStoreCurr->next = NULL;
LineStoreCurr->lineno = GetLineNumber();
Expand Down
Loading

0 comments on commit ab8a297

Please sign in to comment.