phil@kcl-cs.UUCP (Phil Thompson) (01/22/86)
I think that the following should assemble without problems: PUBLIC foo foo PROC NEAR . . . mov [si],OFFSET bar . . . foo ENDP bar PROC NEAR . . . bar ENDP All of this being in the code segment of course. The error message from MASM is: error 35: Operand must have size This happens with both V3.0 and V4.0 of MASM. Is this a bug and how do I get around it? Incidentally I remember quite a bit of discussion about the assembler output produced by the Microsoft C Compiler (V3.0) when using the /Fa switch. As far as I can remember the concenus was that you had to use MASM V3.0 to assemble it. However I can get the compiler to produce the above code which, as I say, doesn't assemble. Thanks for ANY help. Phil Thompson.
frank@sagan.UUCP (Frank Whaley) (01/29/86)
In article <231@argon.kcl-cs.UUCP> phil@kcl-cs.UUCP writes: >I think that the following should assemble without problems: >PUBLIC foo >foo PROC NEAR > mov [si],OFFSET bar >foo ENDP > >bar PROC NEAR >bar ENDP >All of this being in the code segment of course. The error message from MASM >is: > error 35: Operand must have size >This happens with both V3.0 and V4.0 of MASM. Is this a bug and how do I get >around it? The assembler first converts the "OFFSET bar" into a (relative) constant, thus forgetting its type (size). This confuses the opcode generator, which doesn't know if SI is pointing to a byte- or word-sized data. Thus MASM complains. The only work-around I found was: mov [si],Word Ptr (OFFSET bar) which looks funny, but assembles correctly. The parentheses are necessary, as: mov [si],Word Ptr OFFSET bar again confuses the assembler. The fact that the compiler outputs this code is probably a case of premature optimization (the coder missed one of the cases). I usually see compilers output something like: mov ax,OFFSET bar mov [si],ax which is one more byte but one less clock (on an 8088). -- ...Frank Whaley, MicroPro Product Development UUCP: {decvax!decwrl | ucbvax}!dual! {hplabs | glacier}!well! seismo!lll-crg! ihnp4!ptsfa! pyramid!micropro!sagan!frank ARPA: micropro!sagan!frank@lll-crg.ARPA "I'm told there are better programs [than WordStar], but I'm also told there are better alphabets." --William F. Buckley Jr.
dob@ihmax.UUCP (dan o'brien) (02/01/86)
> >I think that the following should assemble without problems: > >PUBLIC foo > >foo PROC NEAR > > mov [si],OFFSET bar > >foo ENDP ... > > error 35: Operand must have size > > The only work-around I found was: > mov [si],Word Ptr (OFFSET bar) > which looks funny, but assembles correctly. The parentheses are > necessary, as: ... Won't this work? mov word ptr [si],OFFSET bar -- Daniel M. O'Brien (ihnp4!ihmax!dob) AT&T Bell Laboratories IH 4A-257, x 4782 Naperville-Wheaton Road Naperville, IL 60566