News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Why is "MOV DL, VAL1 [BX] " allowed in JWASM/MASMv5.1, but not MOV DL, [BX] VAL1

Started by bugthis, April 15, 2025, 07:34:40 AM

Previous topic - Next topic

bugthis

Tested with JWASM v2.19 and MASM version 5.10
Code (asm) Select
; Indirect Addressing Test:
; iad_test.asm
.MODEL SMALL, C
VAL1 EQU 7
.STACK 256
.DATA
  STR1 DB "9876543210$"

.CODE
START:
  MOV AX, @DATA
  MOV DS, AX
  MOV BX, OFFSET STR1

; Output
  MOV DL, [BX + VAL1]  ; normal Syntax
  MOV AH, 02h
  INT 21h

  MOV DL, VAL1 [BX]    ; works without +
  MOV AH, 02h
  INT 21h

  MOV DL, [BX] + VAL1  ; works
  MOV AH, 02h
  INT 21h

;  MOV DL, [BX] VAL1   ; Not allowed
;  MOV AH, 02h
;  INT 21h

; Input
  MOV BYTE PTR [BX + VAL1], "B" ; normal Syntax
  MOV DL, VAL1 [BX]
  MOV AH, 02h
  INT 21h

  MOV BYTE PTR VAL1 [BX], "A"   ; works without +
  MOV DL, VAL1 [BX]
  MOV AH, 02h
  INT 21h

  MOV BYTE PTR [BX] + VAL1, "C" ; works
  MOV DL, VAL1 [BX]
  MOV AH, 02h
  INT 21h

;  MOV BYTE PTR [BX] VAL1, "D"    ; not allowed
;  MOV DL, VAL1 [BX]
;  MOV AH, 02h
;  INT 21h

  MOV AH, 4Ch
  INT 21h
  END START

I assume JWASM adopted this behavior from MASM for compatibility reasons. But why is this allowed in MASM at all?

EDIT:
I just saw that I've already addressed this topic here. So you can ignore it.