Skip to content

Instantly share code, notes, and snippets.

@tommie
Last active February 8, 2024 16:23
Show Gist options
  • Save tommie/3107274f9c3625d6be9c55005a171300 to your computer and use it in GitHub Desktop.
Save tommie/3107274f9c3625d6be9c55005a171300 to your computer and use it in GitHub Desktop.
MPASM (gpasm?) macro text substitution flaw
;; gpasm --mpasm-compatible -p p16f887 repro.asm
;;
;; Should produce four nop, but produces none, because the m2 i
;; binding leaks into the m1 i via the n parameter.
;;
;; See also https://forum.microchip.com/s/topic/a5C3l000000LzjcEAC/t229040
m1 macro n
local i
i set 0
while i < n
i set i + 1
nop
endw
endm
m2 macro
local i
i set 4
m1 i
endm
m2
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment