3

I have legacy (DOS era) code that used:

push cs
pop ds

and that assembled fine with TASM v1.01

Trying to assemble with TASM v5.4 I get 'illegal indexing mode' error for push cs instruction.

How can I fix that?

(Searching for [tasm] illegal indexing mode did not return any results for this particular issue.)

EDIT: Here's the code, reduced to minimum (nonsense) that still produces the error I'm talking about.

        assume  cs:code
code    segment
main    proc
        push    cs
main    endp
code    ends
        end

and here's the assembler output:

Turbo Assembler  Version 5.4  Copyright (c) 1988, 2010 Embarcadero Technologies, Inc.

Assembling file:   sample.ASM
**Error** sample.ASM(4) Illegal indexing mode
Error messages:    1
Warning messages:  None
Passes:            1
tonypdmtr
  • 3,037
  • 2
  • 17
  • 29
  • 2
    Weird. This should still assemble just fine. Make sure the error actually occurs on that line. – fuz Nov 07 '19 at 12:45
  • @fuz I added sample code that shows the error (at least in my system). Can someone verify? – tonypdmtr Nov 07 '19 at 18:29
  • 1
    Sounds like TASM being weird; that's a legal instruction. Upvoted now that there's a full [mcve] of a whole file that doesn't contain anything else that looks problematic. NASM assembles your push/pop pair just fine in 16-bit mode. (But of course it's not useful if you have a whole bunch of TASM-syntax code.) – Peter Cordes Nov 07 '19 at 18:36

1 Answers1

4

The problem seems to be related to using ASSUME with a segment that has yet to be defined. Moving the ASSUME directive into the code segment removes the error, as does deleting the directive. Changing the CS register to the DS register in both the ASSUME directive and PUSH instruction causes the same error, so the segment register used doesn't seem to matter.

This appears to be a bug in the assembler, but the workaround is simple. Just move the ASSUME directive to just after the code SEGMENT directive. This is where you would normally want it as you wouldn't normally want to assume CS is code inside other segments.

(You can also work around the problem by having TASM use at least two passes. That requires both using the /m option and having at least one construct in your code that requires a second pass, like a forward reference. The bug in TASM 5.4 appears to be that it doesn't recognize that assume cs:code is a forward reference.)

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • 1
    So it appears to be a bug in the assembler. I did what you said, and it assembles OK. (I wouldn't have thought it's a bug because of much earlier TASM 1.01 not having this issue.) – tonypdmtr Nov 07 '19 at 19:49