Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bogus "constant too large" error?

585 views
Skip to first unread message

Jim Leonard

unread,
Nov 12, 2014, 4:13:03 PM11/12/14
to
I ran into an assembler warning the other day that I couldn't explain. The following code:

push ds
mov ax,40h
mov ds,ax
mov al,[75h] ;get the number of hard disks.
pop ds

...produces a warning assembling with TASM for the line referencing [75h]:

*Warning* tail.ASM(486) [Constant] assumed to mean immediate constant

I thought the warning was clear; changing the source to this:

mov al,[075h]

...assembled without errors. However, a larger value produced both a warning and an error. Changing the above to:

push ds
xor ax,ax
mov ds,ax
mov al,[475h] ;get the number of hard disks.
pop ds

...produces this:

*Warning* tail.ASM(486) [Constant] assumed to mean immediate constant
**Error** tail.ASM(486) Constant too large

...and changing it to [0475h] does not eliminate the error.

What gives? The value is not over FFFFh so this should not be throwing an error. Changing the line to "mov al,ds:[0475h]" assembles, but the output inserts an unnecessary DS: override.

Has anyone seen this? Is this a bug, or am I missing something?

Rick C. Hodgin

unread,
Nov 12, 2014, 4:28:08 PM11/12/14
to
It seems that TASM is interpreting it as:
mov al,75h

Try:

push ds
push si
mov ax,40h
mov ds,ax
mov si,75h
mov al,[si] ;get the number of hard disks.
pop si
pop ds

Or possibly:
push ds
mov ax,40h
mov ds,ax
mov al,ds:[075h] ;get the number of hard disks.
pop ds

Best regards,
Rick C. Hodgin

Robert Wessel

unread,
Nov 13, 2014, 2:14:00 AM11/13/14
to
While I haven't used TASM in years, and even then only a bit, the
first warning is, I think the tip-off. It's interpreting the second
parameter as a constant, not an address; hence 0475h is too large to
fit into AL.

With MASM, you'd normally code what you're trying to do as

mov al,byte ptr [0475h]

I think the same should work in TASM.

pe...@nospam.demon.co.uk

unread,
Nov 13, 2014, 2:44:19 AM11/13/14
to
Never seen it before, so can only assume that I've never tried to use
such a construct before! The key thing is to see what the code is
assembling to and I bet it's not what you intended. So I tried

Turbo Assembler Version 3.1 13/11/14 06:45:23 Page 1
tempo2.ASM

1 0000 code segment public 'code'
2 assume cs:code
3
4 org 100h
5 0100 start:
6 0100 B0 75 mov al,[0075h]
*Warning* tempo2.ASM(6) [Constant] assumed to mean immediate constant
7 0102 90 nop
8 0103 B0 75 mov al,75h
9 0105 90 nop
10 0106 B0 75 mov al,byte ptr [75h]
*Warning* tempo2.ASM(10) [Constant] assumed to mean immediate constant
11 0108 90 nop
12 0109 B0 75 mov al,byte ptr 75h
13 010B 90 nop
14 010C A0 0075 mov al,ds:75h
15 010F 90 nop
16 0110 A0 0075 mov al,ds:[75h]
17 0113 90 nop
18
19 0114 B8 4C00 mov ax, 4c00h
20 0117 CD 21 int 21h
21
22 0119 code ends
23 end

You can see that it is completely disregarding the [..] and treating
the operand as a constant, and loading it directly into AL. Only by
explicitly providing a 'ds:' override does it assemble to the code
that I think you want it to [A0,75,00]. I've not used IDEAL mode much
but that does appear to honour the square brackets.

FWIW I assembled the same code using masm 4.0 and 5.1 with identical
results, except they didn't even give warnings!

Pete
--
Believe those who are seeking the truth.
Doubt those who find it. - André Gide

Frank Kotler

unread,
Nov 13, 2014, 3:29:23 AM11/13/14
to
Jim Leonard wrote:

...
> Has anyone seen this?

Yeah. I vaguely recall trying to get the command line length (in DOS)...

mov cl, [80h]

... and having Masm/Tasm treat it as an immediate. I don't recall the
warning. The workaround was

mov cl, ds:[80h]

As I recall, this was "just syntax" and the ds: override was not
emitted. The code Pete posted seems to confirm this. My workaround was
to use a different assembler. :) If you tell Nasm...

mov cl, [ds:80h]

... you do get the redundant override.

Best,
Frank

Rick C. Hodgin

unread,
Nov 13, 2014, 10:00:09 AM11/13/14
to
On Wednesday, November 12, 2014 4:13:03 PM UTC-5, Jim Leonard wrote:
> I ran into an assembler warning the other day that I couldn't explain. The following code:
>
> push ds
> mov ax,40h
> mov ds,ax
> mov al,[75h] ;get the number of hard disks.
> pop ds
>

The "mov al,[75h]" opcode bytes for immediate offset memory address are:
A0 75 00 00 00

So, you could insert them manually to bypass the DS: override:

push ds
mov ax,40h
mov ds,ax

;mov al,[75h] ; get the number of hard disks.
db 0A0h ; mov al,byte ptr[...]
dd 075h ; 75h (change to 475h in the other form)

pop ds

Or create a macro for it, etc.

Jim Leonard

unread,
Nov 15, 2014, 11:50:59 AM11/15/14
to
Thanks for all the replies; I should have checked the disassembly. I'll go read the TASM documentation to see if there are non-IDEAL rules for handling this.

How odd that an assembler does strange and wacky things, yet DEBUG assembles it immediately and correctly.
0 new messages