Got a bit of difficulty with signed integer compares.
Code: Select all
Program Compares
dim i1,idelta as integer 'signed 16bit integers
main:
integer1 = -22
idelta = 1
while 1
if integer1 > 2000 then 'if (-22 > 2000) then ... this should be a false condition, but interpreted as true condition
idelta = -1 'this statement should be skipped on false condition, but it is executed
end if
integer1 = imteger1 + idelta
wend
end.
Code: Select all
;a.mbas,10 :: if integer1 > 2000 then
0x021A 0x804021 MOV _integer1, W1
0x021C 0x207D00 MOV #2000, W0
0x021E 0xE10800 CP W1, W0
0x0220 0x360002 BRA LEU L__main7 'should be BRA LE ?
L__main10:
;a.mbas,11 :: idelta = -1
0x0222 0x2FFFF0 MOV #65535, W0
0x0224 0x884000 MOV W0, _idelta
L__main7:
;a.mbas,13 :: integer1 = integer1 + idelta
Code: Select all
if integer1 > integer2 'code ok
if integer1 > 200 'code ok
if integer1 > 2000 'code not ok as above