Miscellaneous > 16 bit DOS Programming

JWASM ignores -0 and -1 parameter even when .286 directive is present

(1/1)

bugthis:
When i use an assembler command like

--- Code: ---; 286
SHR DL, 3

--- End code ---
then i need the .286 directive in the source code too.
Because SHR DL, NUMBER does only work on a 80286 CPUs or better.
An 8086 needs the CL Register as a replacement for NUMBER.

--- Code: ---; 8086
MOV CL, 3
SHR DL, CL

--- End code ---

8086

--- Code: ---; 8086 code
; Tests shift operator SHL, SHR with JWASM without .286 Directive
; Prog.Name:    s_test.asm
.MODEL SMALL, C

.STACK 256

.CODE
START:
  MOV     AX,0097h
  MOV     CX,0004h
  SHL     AX,CL
  SHR     AL,CL

  ADD     AX,3030h ; Create ASCII digits
  MOV     BX,AX

  MOV     DL,BH    ; Output upper digit
  MOV     AH,02h
  INT     21h
  MOV     DL,BL    ; Output lower digit
  MOV     AH,02h
  INT     21h

  MOV     AH,4Ch    ; return to DOS
  INT     21h
  END START

--- End code ---

286

--- Code: ---; 286 code
; Tests shift operator SHL, SHR with JWASM and .286 Directive
; Prog.Name:    s_test_2.asm
.MODEL SMALL, C
.286
.STACK 256

.CODE
START:
  MOV     AX,0097h

  SHL     AX,04h
  SHR     AL,04h

  ADD     AX,3030h ; Create ASCII digits
  MOV     BX,AX

  MOV     DL,BH    ; Output upper digit
  MOV     AH,02h
  INT     21h
  MOV     DL,BL    ; Output lower digit
  MOV     AH,02h
  INT     21h

  MOV     AH,4Ch    ; return to DOS
  INT     21h
  END START

--- End code ---



So far so good. But when i assemble the 286 version with:

--- Code: ---JWASMR -0 -mz s_test_2.asm

--- End code ---
or

--- Code: ---JWASMR -1 -mz s_test_2.asm

--- End code ---

Then JWASMR doesn't complain, but it should. Because the manual says that the parameter options -0 produces a binary for 8086 CPUs and -1 a binary for  80186 CPUs or older.
https://www.japheth.de/JWasm/Manual.html#CMDOPT0https://www.japheth.de/JWasm/Manual.html#CMDOPT0

If i remove the .286 directive in the 286 code, then JWASMR complaines with an ERROR message like it should. But the -0 and -1 command line parameters are ignored.

_japheth:

--- Quote from: bugthis on November 16, 2022, 10:43:35 AM ---Then JWASMR doesn't complain, but it should. Because the manual says that the parameter options -0 produces a binary for 8086 CPUs and -1 a binary for  80186 CPUs or older.
https://www.japheth.de/JWasm/Manual.html#CMDOPT0https://www.japheth.de/JWasm/Manual.html#CMDOPT0

--- End quote ---

Well, the documentation is probably a bit unclear here. The "number arguments" just set the cpu to a default value, and this may be modified by the cpu directives ( .8086, .286, ...)
So, if you don't want to override the default, don't use those directives. There's the @Cpu equate that is set by both the arguments and the directives, maybe this helps?

bugthis:

--- Quote from: _japheth on November 16, 2022, 04:19:01 PM ---Well, the documentation is probably a bit unclear here. The "number arguments" just set the cpu to a default value, and this may be modified by the cpu directives ( .8086, .286, ...)
So, if you don't want to override the default, don't use those directives. There's the @Cpu equate that is set by both the arguments and the directives, maybe this helps?

--- End quote ---

I understand. So the argument numbers don't enforce the allowed CPU related assembly commands.

But when i want have a binary, that definitely runs on an 8086, how can i enforce it, that the assembler throws a warning or error, when an assembly command got used, that isn't for the 8086 CPU?

_japheth:

--- Quote from: bugthis on November 20, 2022, 06:23:34 AM ---But when i want have a binary, that definitely runs on an 8086, how can i enforce it, that the assembler throws a warning or error, when an assembly command got used, that isn't for the 8086 CPU?

--- End quote ---

Hmm, perhaps using the NOKEYWORD option?

By disabling anything beyond .8086 the source must stay with 8086 opcodes.

Navigation

[0] Message Index

Go to full version