OK, grok responded to my micropython example above with this conversion to MMB:
SETPIN GP16, PIO0
PIO ASSEMBLE 0, “.program pulser”
PIO ASSEMBLE 0, “.line 0”
PIO ASSEMBLE 0, “set pindirs, 1”
PIO ASSEMBLE 0, “jmp loop”
PIO ASSEMBLE 0, “.line 2”
PIO ASSEMBLE 0, “wrap_target”
PIO ASSEMBLE 0, “loop:”
PIO ASSEMBLE 0, “set pins, 1 [9]”
PIO ASSEMBLE 0, “set pins, 0 [9]”
PIO ASSEMBLE 0, “wrap”
PIO ASSEMBLE 0, “.end program”
p = Pio(pinctrl 0,1,,,,GP16,)
e = Pio(execctrl 31, 2, 4)
PIO INIT MACHINE 0, 0, 1000000, p, e
PIO START 0, 0
PRINT “Starting. Out is GP16”
Looks correct to me! Though the syntax differs, the logic is identical. Could Ian try it please?
Grok took 2 minutes 32 seconds to do the conversion, and listed a number of steps that a human might follow, starting with “read the MMB Manual”. The AI summary is sensible. Of interest is that Grok coped with two versions of the PIO assembler, so it’s translating three languages not just two.
A quirk! I, writing code for a human said:
set(pins,1)[10-1], which grok converted to PIO ASSEMBLE 0, “set pins, 1 [9]”. They are equivalent.
But I said [10-1] because I want the reader to focus on the wanted delay which is 10uS. The wait is 9 cycles but set(pins) takes 1 clock cycle, so the total is 10. 9 obfuscates that this is a 10uS delay. Grok didn’t understand why I wrote 10-1 rather than 9, and simplified it. In the same vein, my code has many explanatory comments, which grok doesn’t bother with. It might if I ask it to!
To reinforce Ian’s point, grok did the conversion far faster that I could! Even though I’m familiar with both MS-BASIC and Python and have a nodding acquaintance with PIO assembler.
Dave