Author Topic: An attempted store to 0 leaves the value on the stack  (Read 2747 times)

Offline Trafalgar

  • Bot Destroyer
  • ***
  • Posts: 122
    • View Profile
An attempted store to 0 leaves the value on the stack
« on: July 15, 2007, 05:42:47 PM »
I've discovered that calling store with an address of 0 results in the value (not the address) remaining on the stack. It took a while to track this down (it was causing test code in a bot to fail to execute properly).

This demonstrates the bug:

Code: [Select]
cond
start
'920 should be 41, and 919-917 should be 0, if there is no bug here. This works properly.
41 'So there's something visible on the end of the stack
97 999 store
'dump stack
920 store 919 store 918 store 917 store

'930 should be 42, and 929-927 should be 0, if there is no bug here. This works properly.
42 'So there's something visible on the end of the stack
98 1000 store
'dump stack
930 store 929 store 928 store 927 store

'924 should be 43, and 923-921 should be 0, if there is no bug here. This does not work properly - 924 is 99, and 923 is 43.
43 'Same reason
99 0 store
'dump stack
924 store 923 store 922 store 921 store

'914-911 should be 0, if there is nothing being left on the stack. However, the 100 is still on the stack after the store, and so it ends up in 914.
100 0 store
'dump stack
914 store 913 store 912 store 911 store
stop

P.S. I put the extra values (42 43 etc) before the stores in order to test whether the bug only happened if there was already something on the stack (besides the store's 2 parameters). As the last test (914-911) shows, it seems to happen regardless of whether something else is on the stack already.
« Last Edit: July 15, 2007, 05:44:40 PM by Trafalgar »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
An attempted store to 0 leaves the value on the stack
« Reply #1 on: July 15, 2007, 05:58:03 PM »
Thought Eric had fixed this.  Sorry 'bout the trouble