Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Internal Types
#1
This issues a warning: "Test.bas:22: warning: Redundant operation ABS for unsigned value"

Surely if a Byte is signed, then (Byte-Byte) is signed as well?

Is this an internal issue, or is it me doing something wrong, and I should be casting, here?

(I know poking the routine with fspDataStart is a bad idea - I needed label to be able to make this compile on its own to demonstrate the query - I'm not really writing horrifically wrong self-modifying code!)
Code:
fspDataStart:
SUB fspCollisionCheck()
    dim sprite as uInteger
    dim xCoords(3) as Byte
    dim yCoords(3) as Byte
    dim i,j as uByte
    
    let sprite=@fspDataStart
    for i=0 to 3
     if (PEEK sprite) mod 2 =1 then:
      let xCoords(i)=PEEK (sprite+2)
      let yCoords(i)=PEEK (sprite+2)
      poke sprite,1
     end if
     let sprite=sprite+43
    next i
    
    let sprite=@fspDataStart
    
    for i=0 to 2
     for j=i+1 to 3
       if ABS (xCoords(i)-xCoords(j)) < 2 AND ABS (yCoords(i)<yCoords(j)) <2 THEN poke (sprite+43*i), PEEK (sprite+43*i) + ((1 SHL i) SHL (j-i)) : END IF
     next j
    next i
END SUB
Reply
#2
britlion Wrote:This issues a warning: "Test.bas:22: warning: Redundant operation ABS for unsigned value"

Surely if a Byte is signed, then (Byte-Byte) is signed as well?
The compiler is right. At line 22, you have:
Code:
... ABS (yCoords(i) < yCoords(j)) <2 THEN
The ABS argument is a boolean value, which maps to an unsigned byte. Thus unsigned. ;-) I guess you have a bug here, and what you meant was a subtraction, isn't it?
Reply
#3
Sheesh.

And I swear I tried it without the second argument.

Weird when you can't see what you typed sometimes. I stared at that for about an hour.

I blame coding after midnight and my old failing eyesight.

Have you changed some of the error messages? They seem to be getting more helpful...
Reply
#4
britlion Wrote:Sheesh.

And I swear I tried it without the second argument.

Weird when you can't see what you typed sometimes. I stared at that for about an hour.

I blame coding after midnight and my old failing eyesight.

Have you changed some of the error messages? They seem to be getting more helpful...
Nope, just divided the line into two lines, using the line continuation "_" character:
Code:
if ABS (xCoords(i)-xCoords(j)) < 2 AND _
    ABS (yCoords(i)<yCoords(j)) <2 THEN
    poke (sprite+43*i), PEEK (sprite+43*i) + ((1 SHL i) SHL (j-i))
END IF

This way you can make your code more readable and the warning/error is reported more accurately. BASIC is line-oriented => you can't break the line in the middle of a single sentence, but the _ terminator (written AT THE VERY END of the line) allows line wrapping.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)