Coder Social home page Coder Social logo

jwasm's Introduction

JWasm

masm compatible assembler.

Runs under Windows, Linux, DOS, OS/2 ( and probably other OSes as well ).

Hints:

  • For Windows, use file Msvc.mak/Msvc64.mak if Visual C++ is to be used to create a 32-/64-bit version of JWasm. OWWin32.mak will create a 32-bit binary using Open Watcom.

  • For Linux, use GccUnix.mak to produce JWasm with gcc or CLUnix.mak to use CLang instead.

  • For DOS, Open Watcom may be the best choice. It even allows to create a 16-bit (limited) version of JWasm that runs on a 8088 cpu. Old versions of Visual C++ are also possible, although you probably need the HX development files then.

  • For OS/2, OWOS2.mak (Open Watcom) is supplied.

There is a bunch of other makefiles in the main directory, intended for other compilers. Some of them might be a bit outdated.

JWasm Manual

jwasm's People

Contributors

baron-von-riedesel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jwasm's Issues

Trying to build JWasm results in the error 'missing binary operator before token "1000000"'

While building JWasm from source I am getting the following error:

make -f GccUnix.mak
gcc -c -Isrc/H -D__UNIX__ -DNDEBUG -O2 -o build/GccUnixR/assemble.o src/assemble.c
In file included from /usr/include/time.h:41:0,
                 from src/assemble.c:12:
src/assemble.c: In function ‘AssembleModule’:
src/assemble.c:1525:5: error: missing binary operator before token "1000000"
 #if CLOCKS_PER_SEC > 1000
     ^
GccUnix.mak:34: recipe for target 'build/GccUnixR/assemble.o' failed
make: *** [build/GccUnixR/assemble.o] Error 1

This error occurs because CLOCKS_PER_SEC is a macro containing a typecast, in /usr/include/bits/time.h:

   The macro 'CLOCKS_PER_SEC' is an expression with type 'clock_t' that is
   the number per second of the value returned by the 'clock' function.  */
/* CAE XSH, Issue 4, Version 2: <time.h>
   The value of CLOCKS_PER_SEC is required to be 1 million on all
   XSI-conformant systems. */
#  define CLOCKS_PER_SEC  ((clock_t) 1000000)

Since typecasts are handled at compile time, they cannot be evaluated by the preprocessor. As a workaround I omitted the preprocessor bits in my build, because on my system it is safe to assume CLOCKS_PER_SEC is greater than 1000, but there should be fix for this I presume.

Listing of machine code bytes >= 80h broken

Hi, I just cloned the current revision of JWasm into a new repo, built it using the gcc unix makefile, and built the 2024-06-01 revision of Debug/X. Here's the output listing file: https://pushbx.org/ecm/test/20240611/DEBUG.LST

Here's a relevant excerpt:

010A                            cmdloop proc
                                if FLATSS
                                else
010A FFFFFF8B26 0000o           	mov sp,[top_sp]		;restore stack (this must be first)
                                endif
010E FFFFFFC706 0000o 0000o     	mov [errret],offset cmdloop
0114 1E                         	push ds
0115 07                         	pop es

It seems negative s8 values are sign-extended to 32 bits.

Spurious segment overrides for LODSB, CMPSW, etc. without operands

Hello @Baron-von-Riedesel,

Thank you for your fix (bdaff8f) for the lack of segment overrides for LODS, CMPS, and MOVS I had earlier reported at JWasm/JWasm#211 .

However, I am now getting an opposite problem with your updated code: a simple LODSB, LODSW, MOVSB, MOVSW, CMPSB, or CMPSW without operands may now sometimes get an extra CS: or ES: segment override, even though there should not be one.

Here is a test input that shows the problem:

CGROUP	GROUP	CODE
DGROUP	GROUP	DATA
EGROUP	GROUP	EXTRA

DATA	SEGMENT PUBLIC
DWLAB	DW	0
DBLAB	DB	0
DATA	ENDS

EXTRA	SEGMENT PUBLIC
EWLAB	DW	0
EBLAB	DB	0
EXTRA	ENDS

CODE	SEGMENT PUBLIC
	ASSUME	CS:CGROUP,DS:DGROUP,ES:EGROUP
CWLAB	DW	0
CBLAB	DB	0
	MOV	CWLAB,1
	MOV	CBLAB,1
	MOV	DWLAB,1
	MOV	DBLAB,1
	MOV	EWLAB,1
	MOV	EBLAB,1
	LODSW
	LODSB
	INT	3
	LODS	CWLAB
	LODS	CBLAB
	LODS	DWLAB
	LODS	DBLAB
	LODS	EWLAB
	LODS	EBLAB
	MOVSW
	MOVSB
	INT	3
	MOVS	EWLAB,CWLAB
	MOVS	EBLAB,CBLAB
	MOVSW
	MOVSB
	INT	3
	MOVS	EWLAB,DWLAB
	MOVS	EBLAB,DBLAB
	MOVSW
	MOVSB
	INT	3
	MOVS	EWLAB,EWLAB
	MOVS	EBLAB,EBLAB
	CMPSW
	CMPSB
	INT	3
	CMPS	CWLAB,EWLAB
	CMPS	CBLAB,EBLAB
	CMPS	DWLAB,EWLAB
	CMPS	DBLAB,EBLAB
	CMPS	EWLAB,EWLAB
	CMPS	EBLAB,EBLAB
	XLAT	CBLAB
	XLAT	DBLAB
	XLAT	EBLAB
CODE	ENDS
	END

Output:

$ jwasm -Zm -Zne -Zv8 -mh foo.asm
JWasm v2.14pre, Jun 19 2020, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

foo.asm: 62 lines, 2 passes, 1127 ms, 0 warnings, 0 errors
$ wdis foo.o
Module: foo.asm
GROUP: 'DGROUP' _DATA,DATA
GROUP: 'CGROUP' CODE
GROUP: 'EGROUP' EXTRA

Segment: FOO_TEXT WORD USE16 00000000 bytes

Routine Size: 0 bytes,    Routine Base: FOO_TEXT + 0000

No disassembly errors

Segment: _DATA WORD USE16 00000000 bytes

Segment: DATA PARA USE16 00000003 bytes
0000				L$1:
0000  00 00                                           ..
0002				L$2:
0002  00                                              .

Segment: EXTRA PARA USE16 00000003 bytes
0000				L$3:
0000  00 00                                           ..
0002				L$4:
0002  00                                              .

Segment: CODE PARA USE16 00000060 bytes
0000				L$5:
0000  00 00                                           ..
0002				L$6:
0002  00                                              .
0003  2E C7 06 00 00 01 00		mov		word ptr cs:L$5,0x0001
000A  2E C6 06 02 00 01			mov		byte ptr cs:L$6,0x01
0010  C7 06 00 00 01 00			mov		word ptr DGROUP:L$1,0x0001
0016  C6 06 02 00 01			mov		byte ptr DGROUP:L$2,0x01
001B  26 C7 06 00 00 01 00		mov		word ptr es:L$3,0x0001
0022  26 C6 06 02 00 01			mov		byte ptr es:L$4,0x01
0028  26 AD				lods		word ptr es:[si]
002A  26 AC				lods		byte ptr es:[si]
002C  CC				int		0x03
002D  2E AD				lods		word ptr cs:[si]
002F  2E AC				lods		byte ptr cs:[si]
0031  AD				lodsw
0032  AC				lodsb
0033  26 AD				lods		word ptr es:[si]
0035  26 AC				lods		byte ptr es:[si]
0037  A5				movsw
0038  A4				movsb
0039  CC				int		0x03
003A  2E A5				movs		word ptr [di],word ptr cs:[si]
003C  2E A4				movs		byte ptr [di],byte ptr cs:[si]
003E  2E A5				movs		word ptr [di],word ptr cs:[si]
0040  2E A4				movs		byte ptr [di],byte ptr cs:[si]
0042  CC				int		0x03
0043  A5				movsw
0044  A4				movsb
0045  A5				movsw
0046  A4				movsb
0047  CC				int		0x03
0048  26 A5				movs		word ptr [di],word ptr es:[si]
004A  26 A4				movs		byte ptr [di],byte ptr es:[si]
004C  26 A7				cmps		word ptr es:[si],word ptr [di]
004E  26 A6				cmps		byte ptr es:[si],byte ptr [di]
0050  CC				int		0x03
0051  2E A7				cmps		word ptr cs:[si],word ptr [di]
0053  2E A6				cmps		byte ptr cs:[si],byte ptr [di]
0055  A7				cmpsw
0056  A6				cmpsb
0057  26 A7				cmps		word ptr es:[si],word ptr [di]
0059  26 A6				cmps		byte ptr es:[si],byte ptr [di]
005B  2E D7				xlat		word ptr cs:[bx]
005D  D7				xlatb
005E  26 D7				xlat		word ptr es:[bx]

Routine Size: 96 bytes,    Routine Base: CODE + 0000

No disassembly errors

The string instructions just before each int 0x03 should by right have no segment overrides.

Thank you!

.if (eax || edx) && ecx

http://masm32.com/board/index.php?topic=5896.msg62670#msg62670

	.486
	.model flat
	.code

	.if (eax || edx) && ecx
		nop
	.endif

	.if !(eax || edx) && ecx
		nop
	.endif

	.while (eax || edx) && ecx
		nop
	.endw

	.while !(eax || edx) && ecx
		nop
	.endw

	.repeat
		nop
	.until (eax || edx) && ecx

	.repeat
		nop
	.until !(eax || edx) && ecx

ifdef __ASMC__
	.switch
          .case  (eax || edx) && ecx : nop : .endc
          .case !(eax || edx) && ecx : nop : .endc
        .endsw
endif
	END

JWASMD refuses to overwrite existing file

At least under DosBox JWASMD refuses to overwrite an existing .OBJ file. JWASMR and the original WASM have no problems with it. Is that perhaps some incompatibility between the DOS extender and DosBox?
command_001

SHR - calculate() in exprecal.c

    .386
    .model flat
    .code

    row = -1
    REPT 8
        row = row SHR 4
        mov eax,row
    ENDM

    end

	case T_SHR:
	    if ( opnd2->value < 0 )
		fnasmerr( 2092 );
	    else if ( opnd2->value >= ( 8 * sizeof( opnd1->llvalue ) ) )
		opnd1->llvalue = 0;
	    else {
		if ( opnd1->value == -1 && ModuleInfo.Ofssize == USE32 )
		    opnd1->llvalue = (unsigned long)opnd1->llvalue >> opnd2->value;
		else
		    opnd1->llvalue = opnd1->llvalue >> opnd2->value;
	    }

Domain `jwasm.info`

Since I started the fork some time ago thinking the development was abandoned and obviously it is continued here and active, do you need me to transfer the domain I registered to you? Let me know.

I will archive then all repositories in https://github.com/JWasm

EDR-DOS macro orgabs resets org when it shouldn't

This test case is based on the revision in https://hg.pushbx.org/ecm/edrdos/rev/8d01d7fe3cc1

This is the source of the test case, which is a part of drbio/init.asm plus all the files it includes: https://hg.pushbx.org/ecm/testjwas/file/5e082442d4c4

This is the resulting listing file: https://pushbx.org/ecm/test/20230814/repo/init.lst

The error is that the orgabs macro should detect that offset 171h is above 16Ch and therefore the org was directive should be run. However, it appears that the directive is not run, as the devno variable ends up at 16Ch.

This works correctly on MASM 6.11, and for JWasm the same macro does work in several other spots but not in this one.

Output:

$ jwasm -c -Zm -Flinit.lst init.asm
JWasm v2.18, Aug 14 2023, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

init.asm: 378 lines, 3 passes, 2 ms, 0 warnings, 0 errors
$ grep -E "orgabs\s+MACRO" -A11 init.asm
orgabs  MACRO   address
        local   was,is
        was = offset $
        org address
        is = offset $
        if was GT is
;       if2
;               %OUT ERROR - absolute data overwritten !! moving it
;       endif
        org     was
endif
ENDM
$ grep oldxbda,newxbda -A12 init.lst
                                        Public  oldxbda,newxbda,xbdalen,oldmemtop
0169 0000                       oldxbda         dw      0               ; old XBDA segment address
016B 0000                       newxbda         dw      0               ; new XBDA segment address
016D 0000                       xbdalen         dw      0               ; length of XBDA in words
016F 0000                       oldmemtop       dw      0               ; old conventional mem limit

                                        orgabs  16ch                    ; PRN:/AUX: the device number
00000171 = 171               1          ??0006 = offset $
                             1          org 16ch
0000016C = 16C               1          ??0007 = offset $

016C 0000                       devno   db      0,0                     ;** fixed location **

$

Asm causing real-mode compiler to hang

The attached file "e.asm" (errorasm.zip, 2 kb) hangs real-mode version of compiler.
Also, JWasm once displayed "internal error in file omfint.c, line 168" message, but I can not get this error anymore, it simply hangs.

The file is currently in compilable form, but if you remove file "dummy.asm" (or make any error in "e.asm"), the compiler will hang.

It also hangs in DosBox (as in safer environment), but only after several launches and if free memory is below ≈600 kb.
The attached "a.bat" automatically eats memory and launches JWasmr.exe to reproduce the error (in DosBox the bat needs to be relaunched manually, because its command.com does not support /k switch).

The error only affects real-mode version, therefore it is probably a limitation of low memory, but if you'll decide to look, here it is.
And thanks for the program!

extern macro error

Hi japheth. I'll add some of the issues fixed in Asmc here.

macro28.asm:

include macro.inc

    end

macro.inc:

    .386
    .model flat
    .code


line_error macro line

    mov ax,line1
    exitm<eax>
    endm

    mov edx,line_error(5)

macro28.asm(12) : Error A2102: Symbol not defined : line1

CreateVariable() - qword

    .386
    .model flat
    .code

foostr TEXTEQU <xyz>
foo SIZESTR foostr

%   mov	eax,@CatStr(%foo)

IF foo GT 1
    mov	eax,1
ELSE
    .err <should be dead code>
ENDIF

foo = foo - 100		; <--- does set asym.value3264 to -1
foo SIZESTR foostr	; <-- CreateVariable() does not zero asym.value3264, if equate already exist.

%   mov	eax,@CatStr(%foo)
IF foo GT 1
    mov	eax,1
ELSE
    .err <should be dead code>
ENDIF

    END

Usage conditions on JWasm Manual and code base, regarding OpenWatcom relicensing effort

The definitive document on the OpenWatcom relicensing effort appears to be this wiki page, which had some activity as recently as 2023: https://github.com/open-watcom/open-watcom-v2/wiki/Relicensing-effort

Quoting a part of that:

SAP are willing to relicense their own contributions under the Apache License, v2.0. Sebastian Wolf from SAP reached out to the community, to say such. This is important, because Sybase/SAP’s code is the original basis for Open Watcom. SAP will likely grant addition permissions, [...] probably the LLVM Exceptions.

Would you be willing to grant the same usage conditions, Apache License v2.0 with LLVM Exceptions, to all your contributions to JWasm and JWlink? If so, I'd appreciate it if you made a definitive statement to that end.

In a very cursory glance at the sources I noticed that some files already contain Public Domain dedications. However, the JWasm Manual contains this section:

  1. License

This manual was written by Andreas Grech ( aka Japheth ). It may be redistributed as long as it is free of charge.

This dedication is not free software / open source compatible. Would you reconsider and perhaps also provide the manual under the Apache License v2.0 with LLVM Exceptions?

offset[size]

Some more stuff.

Offset is added using 64-bit and assigned using 32 so negative values fails.

    .x64
    .model flat
    .code

    BUFFERSIZE equ 512

foo proc

  local buffer[BUFFERSIZE]:byte

    lea rax,buffer[BUFFERSIZE]
    ret

foo endp

    end

expreval.c:(get_operand())

    if ( sym->state == SYM_STACK ) {
        opnd->value64 = (int_64)(sym->offset + (int)StackAdj);

Type size is added to offset in bin.c

    .x64
    .model flat
    .data
    d_08 label byte
    d_16 label word
    d_32 label dword
    d_64 label qword
    oword -1,-1
    .code
start:
    mov d_08[1],al      ; 2 --> 1
    mov d_16[2],ax      ; 4 --> 2
    mov d_32[4],eax     ; 8 --> 4
    mov d_64[8],rax     ;16 --> 8
    ret
    end start

bin.c

    case FIX_RELOFF8:
    case FIX_RELOFF16:
    case FIX_RELOFF32:
	/* v1.96: special handling for "relative" fixups */
	/* v2.28: removed fixup->offset.. */
	value = seg->e.seginfo->start_offset /*+ fixup->offset*/ + offset;
	break;

Missing cstrtwhx.obj?

Triyng to build JWasmD with OWWin32.mak:

         Error! E2008: cannot open cstrtwhx.obj : No such file or directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.