Unexpected ASM-warning while compiling

Windows specific questions.
BasicJan
Posts: 46
Joined: Aug 30, 2005 20:09
Location: Netherlands

Unexpected ASM-warning while compiling

Postby BasicJan » Aug 03, 2008 15:24

While compiling next code, a warning is generated while compiling the program:

FILE: BIBLIOTH.BAS

Code: Select all

' $DYNAMIC   Set arrays dynamic for better use of memory
DEFINT A-Z
DEFINT a-z

DECLARE FUNCTION CalculateDateNumber(CDate$) AS LONG

FUNCTION CalculateDateNumber(CDate$) AS LONG
'Calculate the daynumber starting at januari 1, 1951
'Format CDate$: DD-MM-CCYY or DD/MM/CCYY
  DIM LvYear
  DIM LvMonth
  DIM LvDay

  LvYear=VAL(MID$(CDate$,7,4))
  LvMonth=VAL(MID$(CDate$,4,2))
  LvDay=VAL(MID$(CDate$,1,2))
  IF LvYear>1950 THEN
'**********
    'Next statement compiles wrong:
    CalculateDateNumber=(LvYear-1950)*512 + LvMonth*32 + LvDay
    'Next statement compiles correct, but is nog what I want:
    'CalculateDateNumber=LvYear*512 + LvMonth*32 + LvDay
'**********
  ELSE
    CalculateDateNumber=0
  END IF
END FUNCTION


Next message occurs while compiling:

BIBLIOTH.asm: Assembler messages:
BIBLIOTH.asm:52: Warning: -998400 shortened to 50176

Compilation commandline:
FBC -lang qb -w 0 -exx -s gui BIBLIOTH.BAS

Compiler: 0.18.5b, W32
Mysoft
Posts: 779
Joined: Jul 28, 2005 13:56
Location: Brazil, Santa Catarina, Indaial (ouch!)
Contact:

Postby Mysoft » Aug 03, 2008 17:24

im not sure of the problem... it seems to be a bug...
but what i know is that -1950*512 = -998400 freebasic is pre-calculating this... and since you are using 16bit integers it overflows... you can change this:

Code: Select all

CalculateDateNumber=(LvYear-1950)*512 + LvMonth*32 + LvDay
to this

Code: Select all

CalculateDateNumber=(LvYear-1950)*512& + LvMonth*32 + LvDay


that will make it evaluate as a long instead of integer... what will fix this warning... and then probabily make it work as expected =)

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 4 guests