Trying to reverse a switch I tried to use xor as follows:
// read s0
cpy_cs acc32, switch ; read in the switch sfr
xor acc32, 0x0001 ; invert switch action
andi acc32, 0x0001 ; only keep S0
This is not generating an assembly error but generates the opcodes: AA100001 XOR ACC32(0x10) 0X0001(0x0001) and is obviously not working since 0x0001 is a creg (r1?) holding an unknown value.
It should have been this:
// read s0
cpy_cs acc32, switch ; read in the switch sfr
xori acc32, 0x0001 ; invert switch action (mind the 'i' for immediate)
andi acc32, 0x0001 ; only keep S0
This generates: AC100001 : XORI ACC32(0x10) 0X0001(0x0001)
A stupid error of course but could this error be made detectable by the assembler ?
Assembler error?
Re: Assembler error?
Not really, 0x0001 is a valid CREG address. The assembler makes sure that the final address is valid but there are many paths we can take to get there (default name, name using .rn, etc.). Limiting this to a specific subset would limit programmers' choices.HKWijhe wrote: ↑Sat Feb 18, 2023 2:51 am Trying to reverse a switch I tried to use xor as follows:
// read s0
cpy_cs acc32, switch ; read in the switch sfr
xor acc32, 0x0001 ; invert switch action
andi acc32, 0x0001 ; only keep S0
This is not generating an assembly error but generates the opcodes: AA100001 XOR ACC32(0x10) 0X0001(0x0001) and is obviously not working since 0x0001 is a creg (r1?) holding an unknown value.
It should have been this:
// read s0
cpy_cs acc32, switch ; read in the switch sfr
xori acc32, 0x0001 ; invert switch action (mind the 'i' for immediate)
andi acc32, 0x0001 ; only keep S0
This generates: AC100001 : XORI ACC32(0x10) 0X0001(0x0001)
A stupid error of course but could this error be made detectable by the assembler ?