{"id":596,"date":"2015-04-01T14:07:37","date_gmt":"2015-04-01T14:07:37","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=596"},"modified":"2022-02-18T15:37:49","modified_gmt":"2022-02-18T15:37:49","slug":"inline-assembly-generates-error-876-syntax-error","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/mplab-x\/issues\/inline-assembly-generates-error-876-syntax-error","title":{"rendered":"Inline assembly generates &#8220;error: (876) syntax error&#8221;"},"content":{"rendered":"<p>\n&nbsp;\n<\/p>\n<pre>\r\n<code>\r\n\t#asm\r\n\tGLOBAL _uc_asm_irq_temp\r\n\tGLOBAL _uc_asm_irq_temp1\r\n\t\/\/Reset timer for next rollover\r\n\tmovff\tTMR0L,_uc_asm_irq_temp\t\t\t\/\/read_current_timer_value (read low byte loads high byte)\r\n\tmovff\tTMR0H,_uc_asm_irq_temp1\r\n\tmovlw\t0xfb\r\n\taddwf\t_uc_asm_irq_temp,1,0\t\t\t\t\/\/(1 = file register, 0 = access ram)\r\n\tmovlw\t0xd8\r\n\taddwfc\t_uc_asm_irq_temp1,1,0\t\t\t\/\/(1 = file register, 0 = access ram)\r\n\tmovff\t_uc_asm_irq_temp1,TMR0H\t\t\t\/\/Store new value (high byte first)\r\n\tmovff\t_uc_asm_irq_temp,TMR0L\r\n\t#endasm\r\n<\/code><\/pre>\n<p>\nNewer versions of XC8 generate a &quot;error: (876) syntax error&quot; to the use of the above. It turns out &quot;,1,0&quot; on the end of the addwf and addwfc lines are the issue (even though these numeric values are specified for use in device datasheets). &nbsp;\n<\/p>\n<p>\nThe &#39;1&#39; needs to change to &#39;f&#39; for file register.\n<\/p>\n<p>\nThe &#39;0&#39; needs to change to &#39;c&#39; for common memory \/ access ram (the alternative would be &#39;b&#39; for bank select register.\n<\/p>\n<p>\nSee XC8 user guide in section 6.2.1&nbsp;\n<\/p>\n<pre>\r\n<code>\r\n#asm\r\n\tGLOBAL _uc_asm_irq_temp\r\n\tGLOBAL _uc_asm_irq_temp1\r\n\t\/\/Reset timer for next rollover\r\n\tmovff\tTMR0L,_uc_asm_irq_temp\t\t\t\/\/read_current_timer_value (read low byte loads high byte)\r\n\tmovff\tTMR0H,_uc_asm_irq_temp1\r\n\tmovlw\t0xfb\r\n\taddwf\t_uc_asm_irq_temp,f,c\t\t\t\t\/\/(1 = file register, 0 = access ram)\r\n\tmovlw\t0xd8\r\n\taddwfc\t_uc_asm_irq_temp1,f,c\t\t\t\/\/(1 = file register, 0 = access ram)\r\n\tmovff\t_uc_asm_irq_temp1,TMR0H\t\t\t\/\/Store new value (high byte first)\r\n\tmovff\t_uc_asm_irq_temp,TMR0L\r\n\t#endasm\r\n<\/code><\/pre>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; #asm GLOBAL _uc_asm_irq_temp GLOBAL _uc_asm_irq_temp1 \/\/Reset timer for next rollover movff TMR0L,_uc_asm_irq_temp \/\/read_current_timer_value (read low byte loads high byte) movff TMR0H,_uc_asm_irq_temp1 movlw 0xfb addwf _uc_asm_irq_temp,1,0 \/\/(1 = file register, 0 = access ram) movlw 0xd8 addwfc _uc_asm_irq_temp1,1,0 \/\/(1 = file register, 0 = access ram) movff _uc_asm_irq_temp1,TMR0H \/\/Store new value (high byte first) movff [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-596","post","type-post","status-publish","format-standard","hentry","category-issues"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/comments?post=596"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/596\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/596\/revisions\/598"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}