calculation error
Spiral_72
Posts: 791
I read about orders of operation in the manual..... at least I THOUGHT I did. Why doesn't the following give me a correct address???
ptr is a Word sized pointer variable. Movem is a DATA table containing numerous pairs of BYTE sized numbers
ptr=Movem
READ ptr+x*3, y
Following the orders of operation, it should:
add the variable ptr to the product of the variable x and the constant 3
This was supposed to give me the address to lookup (via READ) data in my table. Instead it give me garbage. Gosh, it took an hour to figure out what was going on
If this is the way it is, and I'm not doing something stupid, BE AWARE to use yo' parentheses!!!!!
ptr is a Word sized pointer variable. Movem is a DATA table containing numerous pairs of BYTE sized numbers
ptr=Movem
READ ptr+x*3, y
Following the orders of operation, it should:
add the variable ptr to the product of the variable x and the constant 3
This was supposed to give me the address to lookup (via READ) data in my table. Instead it give me garbage. Gosh, it took an hour to figure out what was going on
If this is the way it is, and I'm not doing something stupid, BE AWARE to use yo' parentheses!!!!!
Comments
At the risk of sounding completely retarded I finally found it on page 103 under "Orders of Operations". Go figure.
Calculations are performed left to right. There are no orders or operations, or rather that IS the order. Of course parentheses work.
Oh, well. Maybe someone will learn from my stupidity.