"constant excepted" compilation problem ...

Started by Gawen, October 10, 2006, 07:54:18 PM

Previous topic - Next topic

Gawen

Hello,

I use for the first time your masm compiler. The installation was succeded.

I want to make a 4k demo only in assembler. I choose the tiny memory mode. Unfortunately each of my compilation failed ...

So I decided to compile a example program I found on the Web. However that doesn't work ...

Here the example assembler listing (the compiled example binary is a .com) :

.model tiny
.code
.startup
.486

   mov al, 13h
   int 10h

   push cs
   pop ds
   mov si, offset datas

   push 0a000h
   pop es

@otro_frame:
   inc word ptr lx
   inc word ptr camx

   xor di, di
   mov word ptr j, -100
@otra_linea:

   mov cx,320
   push word ptr camx
   pop  word ptr i
@otro_punto:

   finit
   
   fild word ptr i 
   fmul st(0),st(0)      ; iý
   fild word ptr j
   fmul st(0), st(0)     ; jý
   fild word ptr d
   fmul st(0), st(0)     ; dý
   faddp st(1),st(0)
   faddp st(1),st(0)     ; a

   fild word ptr d       ; d
   fimul word ptr prof   ; Prof. de la camara
   fadd st(0), st(0)

   fild word ptr prof    ; Prof. de la camara
   fmul st(0),st(0)
   fisub word ptr r2     ; rý
   
   fld st(0)
   fmul st(0),st(3)
   fadd st(0),st(0)
   fadd st(0),st(0)      ; 4 a c

   fld st(2)
   fmul st(0),st(0)      ; bý

   fsub st(0),st(1)      ; disc = bý - 4 a c
   ftst
   fstsw ax
   sahf
   mov ax,bx
   jc Pinta

   fsqrt                 ; sqrt(disc)

   fld st(4)
   fadd st(0), st(0)     ; 2 a

   fldz
   fsub st(0), st(5)
   fsub st(0), st(2)     ; - b - sqrt(disc)

   fdiv st(0), st(1)     ; ( - b - sqrt(disc) ) / (2 a)
   fstp dword ptr t
   finit
   fld dword ptr t       ; st(0) = t

   fild word ptr i       ; i
   fmul st(0), st(1)

   fild word ptr j       ; j
   fmul st(0), st(2)
   
   fild word ptr d       ; d
   fmul st(0), st(3)
   fiadd word ptr prof   ; Prof.

   ; Ahora st(0) = z
   ;       st(1) = y
   ;       st(2) = x
   ;       st(3) = t

   ffree st(3)

   fld st(2)
   fisub word ptr lx
   fld st(2)
   fisub word ptr ly
   fld st(2)
   fisub word ptr lz

   fld st(0)
   fmul st(0),st(0)
   fld st(2)
   fmul st(0),st(0)
   faddp st(1),st(0)
   fld st(3)
   fmul st(0),st(0)
   faddp st(1),st(0)

   fsqrt
   fimul word ptr r

   fld st(1)   
   fmulp st(5),st(0)
   fld st(2)   
   fmulp st(6),st(0)
   fld st(3)
   fmul st(0),st(7)
   fadd st(0),st(5)
   fadd st(0),st(6)

   fdiv st(0), st(1)
   fimul word ptr rango
   fabs

   fistp word ptr t
   mov al, t

   add al,16

Pinta:
   stosb
   inc word ptr i
   dec cx
   jnz @otro_punto

   inc word ptr j
   cmp byte ptr j, 100
   jne @otra_linea

   cmp byte ptr camx + 1, 1
   je exit

   in al, 60h
   dec ax
   jnz @otro_frame

exit:
   mov al, 3h
   int 10h

   ret

datas:

   prof = [si+$-offset datas]
   dw -40       ; Prof. de la camara

   r2 = [si+$-offset datas]
   d = r2
   dw  225      ; rý

   r = [si+$-offset datas]
   rango = r
   dw  15

   lx = [si+$-offset datas]
   ly = [si+$-offset datas+2]
   lz = [si+$-offset datas+4]
   dw  -250,-100,-400 ; Luz

   camx = [si+$-offset datas]
   dw  -425

   j = [si+$-offset datas]

   i = [si+$-offset datas + 2]

   t = [si+$-offset datas + 4]

end


I type the command :

ml /nologo /AT /Zm /Zi /c /Fl /coff null_rt.asm

And here my error listing :
Assembling: null_rt.asm
null_rt.asm(156) : error A2026: constant expected
null_rt.asm(159) : error A2026: constant expected
null_rt.asm(163) : error A2026: constant expected
null_rt.asm(167) : error A2026: constant expected
null_rt.asm(168) : error A2026: constant expected
null_rt.asm(169) : error A2026: constant expected
null_rt.asm(172) : error A2026: constant expected
null_rt.asm(175) : error A2026: constant expected
null_rt.asm(177) : error A2026: constant expected
null_rt.asm(179) : error A2026: constant expected
null_rt.asm(17) : error A2006: undefined symbol : lx
null_rt.asm(18) : error A2006: undefined symbol : camx
null_rt.asm(21) : error A2006: undefined symbol : j
null_rt.asm(25) : error A2006: undefined symbol : camx
null_rt.asm(26) : error A2006: undefined symbol : i
null_rt.asm(31) : error A2006: undefined symbol : i
null_rt.asm(33) : error A2006: undefined symbol : j
null_rt.asm(35) : error A2006: undefined symbol : d
null_rt.asm(40) : error A2006: undefined symbol : d
null_rt.asm(41) : error A2006: undefined symbol : prof
null_rt.asm(44) : error A2006: undefined symbol : prof
null_rt.asm(46) : error A2006: undefined symbol : r2
null_rt.asm(73) : error A2006: undefined symbol : t
null_rt.asm(75) : error A2006: undefined symbol : t
null_rt.asm(77) : error A2006: undefined symbol : i
null_rt.asm(80) : error A2006: undefined symbol : j
null_rt.asm(83) : error A2006: undefined symbol : d
null_rt.asm(85) : error A2006: undefined symbol : prof
null_rt.asm(95) : error A2006: undefined symbol : lx
null_rt.asm(97) : error A2006: undefined symbol : ly
null_rt.asm(99) : error A2006: undefined symbol : lz
null_rt.asm(111) : error A2006: undefined symbol : r
null_rt.asm(123) : error A2006: undefined symbol : rango
null_rt.asm(126) : error A2006: undefined symbol : t
null_rt.asm(127) : error A2006: undefined symbol : t
null_rt.asm(133) : error A2006: undefined symbol : i
null_rt.asm(137) : error A2006: undefined symbol : j
null_rt.asm(138) : error A2006: undefined symbol : j
null_rt.asm(141) : error A2006: undefined symbol : camx
null_rt.asm(160) : error A2006: undefined symbol : r2
null_rt.asm(164) : error A2006: undefined symbol : r


(I'm really sorry to flood on this topic but I do NOT understand what's wrong ...)

That's not the only case : the majority of assembler listing example from a book can't compile.

Can anybody help me ?

Regards,
Gawen

Draakie

[If I'am wrong don't kill me - but looks to be ....]

1.
You're pre-initialized (variable) data section is'nt correctly defined - thus the errors.
2.
The listing looks like it was meant for TASM (Borland Turbo Assembler).

PS : this is a real crappy and confuzing way to set up data and you should
      spank the author for doing this to you. (personal opinion)

Hope this helps.
Draakie
Does this code make me look bloated ? (wink)

japheth

Hi,

MASM doesn't like things like

   prof = [si+$-offset datas]

you must write them this way

   prof equ [si+$-offset datas]

I'm also not sure if /Zm is a good switch in this case. It enables masm v5.1 compatibility, which is most likely not required here and may cause problems.


PBrennick

Here is 'one' methode of setting up for creating a .com program:

The Beginning few lines:

            TITLE   This is a template
            PAGE    63,128
CODE_SEG    SEGMENT
            ASSUME  CS:CODE_SEG,DS:CODE_SEG,SS:CODE_SEG
            ORG     100h

Start:


The last few lines:

CODE_SEG    ENDS
            END     Start


Do not use the link.exe program that comes with masm32, use a 16 bit linker. Rename it to link16.exe after unpacking and put it in the \masm32\bin folder.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

MichaelW

Gawen,

If you replace all instances of "=" with "equ" then the source will assemble and link OK, but it hangs when run, even when it is built as a COM (TINY model) program.

To make a COM program with MASM 6.14 and the 16-bit linker you would use command lines like this:

ML /Fl /c filename.asm
LINK16 /tiny filename.obj;

Or in a batch file with pause statements added so you can see the assembler and linker output:

ML /Fl /c filename.asm
pause
LINK16 /tiny filename.obj;
pause
eschew obfuscation

Gawen

Thank you for your councils, that helped me much !

You are really effective. Thank you still.