Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!helios!bcm!rice!uw-beaver!cornell!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!ralf From: ralf+@cs.cmu.edu (Ralf Brown) Newsgroups: comp.os.msdos.programmer Subject: Re: TASM can't subtract ... Message-ID: <1991Mar2.041832.28328@cs.cmu.edu> Date: 2 Mar 91 04:18:32 GMT References: <1991Mar1.014835.7651@athena.mit.edu> Sender: netnews@cs.cmu.edu (USENET News Group Software) Organization: School of Computer Science, Carnegie Mellon Lines: 39 In article <1991Mar1.014835.7651@athena.mit.edu> mmshah@athena.mit.edu (Milan M Shah) writes: }I am trying to assemble Fontedit.asm, a program published in PC-Magazine }vol 7 no. 15 using Turbo Assembler 1.0 (Yup, its 1.0 alright). In the program, }there's a couple of lines that go: } }LOADER LABEL BYTE }LOADER_OFFSET EQU 100H - LOADER } }Simple enough, but TASM complains. It says 'Can't add relative addresses.' }First off, 100H is a constant, and not a relative address. Second, I think }its pretty ridiculous for TASM to give an error and die. Maybe a warning, }but to refuse to assemble? Sheesh, here's a number, here's another, and I }want TASM to subtract one from the other, and TASM can't do that? That's }ridiculous, I sez. It's actually a linker limitation. LOADER doesn't necessarily end up in the executable at the same offset as the assembler's location counter indicates. You *can* say "EQU LOADER-100h", because the assembler can put a -100h in the location and tell the linker to adjust it by the offset of LOADER. Unfortunately, the assembler can't tell the linker to fixup a location by the negative of an address.... The assembler used by FONTEDIT's author probably has a bug that lets it do the arithmetic and store the value as a constant in the .OBJ. Unfortunately, you will get rather hard to find errors on multi-file programs (I know, I once got bitten by such a problem with MASM 2.04) because the final executable will address the wrong location. BTW, TASM 2.0 has a more informative message: "Can't subtract dissimilar relative quanties". (If they were the same, i.e. LOADER1-LOADER2, where both are in the same segment, the result would be a constant and would be independent of any relocation performed by the linker) -- {backbone}!cs.cmu.edu!ralf ARPA: RALF@CS.CMU.EDU FIDO: Ralf Brown 1:129/3.1 BITnet: RALF%CS.CMU.EDU@CMUCCVMA AT&Tnet: (412)268-3053 (school) FAX: ask DISCLAIMER? Did | It isn't what we don't know that gives us trouble, it's I claim something?| what we know that ain't so. --Will Rogers