{"id":169,"date":"2012-08-09T13:33:55","date_gmt":"2012-08-09T13:33:55","guid":{"rendered":"http:\/\/www.electronic-products-development.com\/?p=169"},"modified":"2022-02-18T15:37:49","modified_gmt":"2022-02-18T15:37:49","slug":"useful-macros","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/mplab\/assembler\/useful-macros","title":{"rendered":"Useful Macros"},"content":{"rendered":"<h4>PIC12 and PIC16<\/h4>\n<pre><code>\r\n;***********************************************\r\n;********** USEFUL DEFINES AND MACROS **********\r\n;***********************************************\r\n#define\tskip_if_c\tbtfss\tstatus,c\r\n#define\tskip_if_nc\tbtfsc\tstatus,c\r\n#define\tskip_if_z\tbtfss\tstatus,z\r\n#define\tskip_if_nz\tbtfsc\tstatus,z\r\n\r\n;compare file to w, skip if f=w\r\ncpfseq_macro\tmacro\treg\r\n\txorwf\treg,w\r\n\tskip_if_z\r\n\tendm\r\n;\r\n;compare file to w, skip if f&lt;&gt;w\r\ncpfsneq_macro\tmacro\treg\r\n\txorwf\treg,w\r\n\tskip_if_nz\r\n\tendm\r\n;\r\n;compare file to w, skip if f&gt;=w\r\ncpfsgt_eq_macro\tmacro\treg\r\n\tsubwf\treg,w\r\n\tbtfss\tstatus,c\r\n\tendm\r\n;\r\n;compare file to w, skip if f&gt;w\r\ncpfslt_macro\tmacro\treg\r\n\tsubwf\treg,w\r\n\tbtfsc\tstatus,c\r\n\tendm\r\n\r\n;16 BIT COMPARE MACRO - UNBANKED\r\ncompare_a_b_16bit_agtb_bgta_aeqb macro\treg_a_h, reg_a_l, reg_b_h, reg_b_l\r\n\tmovfp\treg_b_h,wreg\r\n\tsubwf\treg_a_h,w\t\t\t\t;A_h - B_h\r\n\tbtfss\tstatus,z\t\t\t\t;is result zero (A and B high are the same)?\r\n\tgoto\t$+d'05'\t\t\t\t\t;no\r\n\tmovfp\treg_b_l,wreg\t\t\t\t;yes - do low byte\r\n\tsubwf\treg_a_l,w\t\t\t\t; A_l - B_l\r\n\tbtfsc\tstatus,z\t\t\t\t;is result zero (A and B low are the same)?\r\n\tgoto\t$+4\t\t\t\t\t;yes - a and b are equal\r\n\tbtfsc\tstatus,c\t\t\t\t;is A higher than B ?\r\n\t;a &gt; b\t\t\t\t\t\t;Yes\r\n\t;b &gt; a\t\t\t\t\t\t;No\r\n\t;a = b\r\n\tendm\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PIC12 and PIC16 ;*********************************************** ;********** USEFUL DEFINES AND MACROS ********** ;*********************************************** #define skip_if_c btfss status,c #define skip_if_nc btfsc status,c #define skip_if_z btfss status,z #define skip_if_nz btfsc status,z ;compare file to w, skip if f=w cpfseq_macro macro reg xorwf reg,w skip_if_z endm ; ;compare file to w, skip if f&lt;&gt;w cpfsneq_macro macro reg xorwf reg,w skip_if_nz [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-169","post","type-post","status-publish","format-standard","hentry","category-assembler"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/169","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=169"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/169\/revisions"}],"predecessor-version":[{"id":537,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/169\/revisions\/537"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}