gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Newbie asm question, invalid constant error

#19273 - alek - Thu Apr 15, 2004 8:42 pm

I'm trying to get the division algorithm from http://www.peter-teichmann.de/adiv1e.html to work in my project.
Here is the pice of the original code which I am having problems with:
Code:

|FDIVS|

  ands r3,r1,#&80000000
  rsbmi r1,r1,#0
  eor r3,r3,r0,asr#1             ;bit 31 = quotsign, bit 30 = remsign
  cmp r0,#0
  rsbmi r0,r0,#0
 
  mov r12,r14
  bl |FDIV|
 
  tst r3,#&80000000
  rsbne r0,r0,#0
  tst r3,#&40000000
  rsbne r1,r1,#0
 
  movs pc,r12

I got a lot of errors so I changed it to this

Code:

fixdivs:
   ands r3,r1,#80000000
   rsbmi r1,r1,#0
   eor r3,r3,r0,asr#1             @bit 31 = quotsign, bit 30 = remsign
   cmp r0,#0
   rsbmi r0,r0,#0

   mov r12,r14
   bl fixdiv

   tst r3,#80000000
   rsbne r0,r0,#0
   tst r3,#40000000
   rsbne r1,r1,#0

   movs pc,r12


I still get the following errors when I try to compile:
fixdiv.s:264: Error: invalid constant -- `ands r3,r1,#80000000'
fixdiv.s:273: Error: invalid constant -- `tst r3,#80000000'
fixdiv.s:275: Error: invalid constant -- `tst r3,#40000000'

what shoul I do
thanks,

I didn't know whether to put this post in the asm forum or the beginner forum but since this is not a complex problem I decided to put it here

#19274 - poslundc - Thu Apr 15, 2004 9:28 pm

What assembler are you using?

Dan.

#19275 - alek - Thu Apr 15, 2004 9:31 pm

poslundc wrote:
What assembler are you using?

Dan.


I'm using gcc.

The error I got before I changed it was
fixdiv.s:264: Error: bad expression -- `ands r3,r1,#&80000000'
fixdiv.s:273: Error: bad expression -- `tst r3,#&80000000'
fixdiv.s:275: Error: bad expression -- `tst r3,#&40000000'

#19277 - tepples - Thu Apr 15, 2004 9:40 pm

Different assemblers seem to want different syntaxes for hexadecimal constants. GAS might be happier with hex constants prefaced by '0x': #0x80000000
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#19278 - alek - Thu Apr 15, 2004 9:54 pm

tepples wrote:
Different assemblers seem to want different syntaxes for hexadecimal constants. GAS might be happier with hex constants prefaced by '0x': #0x80000000


yepp, that did the trick. Thanks for the help.