Define store_and as lhs_operation

正在查看此主题的用户

dunde

Count
I have error message about usage of unassigned variable when I use store_and operation. I was wondering why this operation didn't work if the first variable (destionation) 's not assigned before, for store_add did work with same condition. I found what's difference between store_add and store_and declaration in header_operations.py. store_add 's marked as member of lhs_operations, and store_and is not. I tried a test here :
on module_scripts.py :
插入代码块:
("test_op",
 [(assign, ":a", 0x10),
  (assign, ":b", 0x11),
  (store_add, ":c", ":a", ":b"),
  (assign, reg0, ":c"),
 ]),   
compiled to be :
插入代码块:
test_op -1
 4 2133 2 1224979098644774912 16 2133 2 1224979098644774913 17 2120 3 1224979098644774914 1224979098644774912 1224979098644774913 2133 2 72057594037927936 1224979098644774914
It's ok, there're 3 local variables defined there.
on module_scripts.py :
插入代码块:
("test_op",
 [(assign, ":a", 0x10),
  (assign, ":b", 0x11),
  (store_and, ":c", ":a", ":b"),
  (assign, reg0, ":c"),
 ]),   
compiled to be :
插入代码块:
test_op -1
 4 2133 2 1224979098644774912 16 2133 2 1224979098644774913 17 2117 3 -1 1224979098644774912 1224979098644774913 2133 2 72057594037927936 -1
Error, MS didn't define 3rd local variable.
on module_scripts.py :
插入代码块:
("test_op",
 [(assign, ":a", 0x10),
  (assign, ":b", 0x11),
  (assign, ":c", 0x00), 
  (store_and, ":c", ":a", ":b"),
  (assign, reg0, ":c"),
 ]),   
compiled to be :
插入代码块:
test_op -1
 5 2133 2 1224979098644774912 16 2133 2 1224979098644774913 17 2133 2 1224979098644774914 0 2117 3 1224979098644774914 1224979098644774912 1224979098644774913 2133 2 72057594037927936 1224979098644774914
It's ok, there're 3 local variables defined there, but (assign, ":c", 0x00), 's useless.
插入代码块:
lhs_operations = [try_for_range,
         ..... <CUT for SPACE>            
                  store_mod,
                  store_add,
                  store_and, ### TRIAL to insert this
                  store_sub,
compiled to be :
插入代码块:
test_op -1
 4 2133 2 1224979098644774912 16 2133 2 1224979098644774913 17 2117 3 1224979098644774914 1224979098644774912 1224979098644774913 2133 2 72057594037927936 1224979098644774914
It's ok, there're 3 local variables defined there.
Same goes to store_or operation.
 
Good work indeed! lhs_operation and rhs_operation are used by process_*.py to identify different types of operations. I noticed this mistake in MS long ago, but never really thought of correct it this way.
 
Only coders that extensively use bit masking operations like you will notice this MS mistake. Size of my scripts.txt was reduced up to 1KB by removing (assign, ":mad:xx", 0), things from form rank code.
 
No wonder I've been having a hell of a time debugging my messaging script. It's based entirely on bit masking and the bitwise operators.

Good info to know, and thanks for sharing.
 
后退
顶部 底部