ON 20060619@7:51:53 PM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm#38887.8276967593 [csblondin-sympatico-] Code:
16bit substract, with valid carry & zero flag. if you can do better (smaller), tell me! this is the best I could do. ;------------------------------ ;19/6/2006 ;code by Christian Blondin ;]b[e]l[t]o[i]d[9]7[@s@p@a@m@]e[m]a[i]l.c]o[m -> delete the [][][[] @spam@ ;rsc-mirror3.netfirms.com/pic.html -> coming up. ; ;code is for PIC16 instruction set (PIC10F, 12F, 16F...) ;remove the last two lines if you don't need a valid zero flag. movf f02,W ;get subwf f00,F ;f00-f02 (STATUS,C=!BORROW) btfss STATUS,C ;skip if borrow=0 (C=1) incf f03,F ;else inc f03 movf f03,W ;50% redundant subwf f01,F ;f01-f03 STATUS,C=!BRW btfsc STATUS,Z ;skip if MSbyte<>zero movf f00,F ;else, check LSbyte for zero. ;------------------------------ON 20060619@7:59:15 PM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm#38887.8276967593 [csblondin-sympatico-] Replied to post 38887.8276967593 by csblondin-sympatico- |Insert 'performs [f01|f00] = [f01|f00] - [f03|f02]. (f00 and f02 being the low-bytes, f01 and f03 the hi-bytes) this version (better) keeps [f03|f02] intact: movf f02,W subwf f00,F ;f00-f02 (STATUS,C=!BORROW) movf f03,W btfss STATUS,C ;skip if borrow=0 (C=1) addlw 01 subwf f01,F ;f01-f03 STATUS,C=!BRW btfsc STATUS,Z ;skip if MSbyte<>zero movf f00,F ;else, check LSbyte for zero.' at: '' Christian Blondin shares this code:
ERROR: Can't email. 553 Invalid address syntax ON 20060619@11:05:49 PM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm# James Newton[JMN-EFP-786] change |Replace: '' with: '' ON 20060620@5:59:16 AM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm# Christian Blondin[csblondin-sympatico-] I have agreed to maintain this page. ON 20060620@6:01:21 AM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm# Christian Blondin[csblondin-sympatico-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sub\index.htm&version=22 ERROR: Can't email. 553 Invalid address syntax ON 20060620@6:11:20 AM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm#38888.2578703704 Christian Blondin[csblondin-sympatico-] See also: in a new file at: http://www.piclist.com/techref/microchip/math/sub/16bsubCZ16bit substract, with valid carry & zero flag. if you can do better (smaller), tell me! this is the best I could do. ;------------------------------ ;19/6/2006 ;code by Christian Blondin ;]b[e]l[t]o[i]d[9]7[@s@p@a@m@]e[m]a[i]l.c]o[m -> delete the [][][[] @spam@ ;rsc-mirror3.netfirms.com/pic.html -> coming up. ; ;code is for PIC16 instruction set (PIC10F, 12F, 16F...) ;remove the last two lines if you don't need a valid zero flag. movf f02,W ;get subwf f00,F ;f00-f02 (STATUS,C=!BORROW) btfss STATUS,C ;skip if borrow=0 (C=1) incf f03,F ;else inc f03 movf f03,W ;50% redundant subwf f01,F ;f01-f03 STATUS,C=!BRW btfsc STATUS,Z ;skip if MSbyte<>zero movf f00,F ;else, check LSbyte for zero. ;------------------------------
ERROR: Can't email. 553 Invalid address syntax ON 20060620@6:14:51 AM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm# Christian Blondin[csblondin-sympatico-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sub\index.htm&version=24 ERROR: Can't email. 553 Invalid address syntax ON 20060620@6:22:57 AM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm# Christian Blondin[csblondin-sympatico-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sub\index.htm&version=25 ERROR: Can't email. 553 Invalid address syntax ON 20060620@6:24:09 AM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm# Christian Blondin[csblondin-sympatico-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sub\index.htm&version=26 ERROR: Can't email. 553 Invalid address syntax ON 20060620@6:24:47 AM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm#38888.2672106481 Christian Blondin[csblondin-sympatico-] See also: in a new file at: http://www.piclist.com/techref/microchip/math/sub/16bsubCZ.htm 16bit substract with valid carry & zero flag. ERROR: Can't email. 553 Invalid address syntax ON 20060620@6:25:56 AM at page: http://www.piclist.com/techref/microchip/math/sub/16bsubCZ.htm# Christian Blondin[csblondin-sympatico-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sub\16bsubCZ.htm&version=0 ERROR: Can't email. 553 Invalid address syntax ON 20060620@6:30:41 AM at page: http://www.piclist.com/techref/microchip/math/sub/index.htm# Christian Blondin[csblondin-sympatico-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sub\index.htm&version=28 ERROR: Can't email. 553 Invalid address syntax ON 20060620@5:14:10 PM at page: http://www.piclist.com/techref/microchip/math/sub/16bsubCZ.htm# Christian Blondin[csblondin-sympatico-] edited the page. Difference: http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sub\16bsubCZ.htm&version=1 ERROR: Can't email. 553 Invalid address syntax16bit substract, with valid carry & zero flag. if you can do better (smaller), tell me! this is the best I could do. ;------------------------------ ;19/6/2006 ;code by Christian Blondin ;]b[e]l[t]o[i]d[9]7[@s@p@a@m@]e[m]a[i]l.c]o[m -> delete the [][][[] @spam@ ;rsc-mirror3.netfirms.com/pic.html -> coming up. ; ;code is for PIC16 instruction set (PIC10F, 12F, 16F...) ;remove the last two lines if you don't need a valid zero flag. ;performs [f01|f00] = [f01|f00] - [f03|f02] while keeping f03|f02 intact. ;(f00 and f02 being the low-bytes, f01 and f03 the hi-bytes) movf f02,W subwf f00,F ;f00-f02 (STATUS,C=!BORROW) movf f03,W btfss STATUS,C ;skip if borrow=0 (C=1) addlw 01 subwf f01,F ;f01-f03 STATUS,C=!BRW btfsc STATUS,Z ;skip if MSbyte<>zero movf f00,F ;else, check LSbyte for zero. ;------------------------------