Converting PWM_32 to GCC
SRLM
Posts: 5,045
I'm having a bit of trouble converting the assembly of PWM_32 to GCC.
It works fine with a test harness when I run it with the pre-compiled binary blob, but when I try to use the .S file there is no PWM output.
I've tried all the obvious things such as turning off optimization and garbage collection, changing memory models, changing label names, adding ".pasm", etc but it doesn't help.
I suspect the problem is with relative addressing, since the original ASM has things like:
where t1, Ch, etc. are labels. Spin2cpp translates that as
If that's the problem then I don't know how to fix it. Do I have to add in "- ..start" everywhere?
Also, I noticed the following in the assembly output:
Isn't this incorrect? I count 16 .long locations in the declaration, but only 5 in the outputted source. When I expand them (as I did in the attached .S file) I count the full 16 lines.
It works fine with a test harness when I run it with the pre-compiled binary blob, but when I try to use the .S file there is no PWM output.
I've tried all the obvious things such as turning off optimization and garbage collection, changing memory models, changing label names, adding ".pasm", etc but it doesn't help.
I suspect the problem is with relative addressing, since the original ASM has things like:
'------------------------------------------------------------- sub t1 + 00, #1 wc Ch01 if_c xor Ch + 00, Mask + 00 wz if_c_and_z mov t1 + 00, T_Off_Ch + 00 if_c_and_nz mov t1 + 00, T_On__Ch + 00
where t1, Ch, etc. are labels. Spin2cpp translates that as
Ch01 if_c xor (Ch + 0), (MaskPWM + 0) wz if_c_and_z mov (T1PWM + 0), (T_off_ch + 0) if_c_and_nz mov (T1PWM + 0), (T_on__ch + 0) sub (T1PWM + 1), #1 wc(note that I changed some of the names to reduce namespace collision)
If that's the problem then I don't know how to fix it. Do I have to add in "- ..start" everywhere?
Also, I noticed the following in the assembly output:
335 T_off_ch 336 04d0 00000000 .long 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 336 00000000 336 00000000 336 00000000 336 00000000 337 0510 00000000 .long 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 337 00000000 337 00000000 337 00000000 337 00000000
Isn't this incorrect? I count 16 .long locations in the declaration, but only 5 in the outputted source. When I expand them (as I did in the attached .S file) I count the full 16 lines.