Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange behaviour with memory pointer calculation (*solved*)
#1
Splitting this out from the other thread, sorry. Smile

In 1.6.2 there seems to be something weird going on when I perform calculations on memory pointers. My program switches between various banks of UDGs by POKEing 23675/23676 to point to different addresses. When I compiled with the 1.6.2 I noticed that none of my UDGs were working properly. After some experimentation I discovered that the maths I was using to calculate the high and low byte values was giving the wrong values for some reason.

Take a look at this program, which I adapted from my main program (hence it looking a bit weird, sorry):
Code:
dim n, b as ubyte
declare sub start()

start()

UDGS:
asm
defb 255,255,255,255,255,255,255,255
end asm

sub start()
    cls
    print "@UDGS = ";@UDGS
    print "@UDGS/256 = ";(@UDGS/256)
    print "int(@UDGS/256) = ";int(@UDGS/256)
    b=int(@UDGS/256)
    print "b = ";b
end sub

When I run this the address of the UDGS bank is 32793. The first two calculations that I print directly (without assigning to a variable) work as I would expect - the value is 128. But when I do the same calculation and assign it to ubyte 'b', the value suddenly becomes 254. This same program produces '128' in all PRINT statements using version 1.5.3 of ZX Basic.

I've no idea what's going on there, unfortunately. Sorry! Sad
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)