diff options
author | Christian Pointner <equinox@mur.at> | 2012-06-06 00:40:07 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2012-06-06 00:40:07 +0000 |
commit | 61428482f2b6222c7e95e9483eedafd9f5611661 (patch) | |
tree | 24572005b1af796b966ff46d4e32cc409a682005 /software/idm/idm.asm | |
parent | minor fixes (diff) |
added ringbuffer ptr handling
git-svn-id: https://svn.spreadspace.org/mur.sat@505 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/idm/idm.asm')
-rw-r--r-- | software/idm/idm.asm | 118 |
1 files changed, 114 insertions, 4 deletions
diff --git a/software/idm/idm.asm b/software/idm/idm.asm index d36422a..2b796fd 100644 --- a/software/idm/idm.asm +++ b/software/idm/idm.asm @@ -31,6 +31,10 @@ ;; ------------------------------------- ;; DEFINES ;; constants +BUF_STARTH EQU 020h +BUF_STARTL EQU 000h +BUF_ENDH EQU 023h +BUF_ENDL EQU 0BFh ;; I/O Pins ;; PortA @@ -49,10 +53,17 @@ FILTER_EN EQU .7 ;; variables ;; all Pages -CNT0 EQU H'0070' -CNT1 EQU H'0071' -CNT2 EQU H'0072' -TMP EQU H'0073' +CNT0 EQU H'0070' +CNT1 EQU H'0071' +CNT2 EQU H'0072' +TMP EQU H'0073' + +FLAGS EQU H'007F' + + ;; bits +;; FLAGS +UNDERRUN EQU .0 +OVERRUN EQU .1 ;; ------------------------------------- ;; OFFSET @@ -80,6 +91,105 @@ int_spi retfie ;; ------------------------------------- + ;; SUBROUTINES +wbuf_reset + movlw BUF_STARTH + movwf FSR0H + movlw BUF_STARTL + movwf FSR0L + bcf FLAGS,OVERRUN + return + + ;; ------------------- +wbuf_next + btfsc FLAGS,UNDERRUN + goto wbuf_move_ptr + + movf FSR1H,w + xorwf FSR0H,w + btfss STATUS,Z + goto wbuf_move_ptr + + movf FSR1L,w + xorwf FSR0L,w + btfss STATUS,Z + goto wbuf_move_ptr + + bsf FLAGS,OVERRUN + return + +wbuf_move_ptr + bcf FLAGS,UNDERRUN + addfsr FSR0,1 + + movf FSR0H,w + sublw BUF_ENDH + btfss STATUS,C + goto wbuf_wraparound + btfss STATUS,Z + return + movf FSR0L,w + sublw BUF_ENDL + btfsc STATUS,C + return + +wbuf_wraparound + movlw BUF_STARTH + movwf FSR0H + movlw BUF_STARTL + movwf FSR0L + return + + + ;; ------------------- +rbuf_reset + movlw BUF_STARTH + movwf FSR1H + movlw BUF_STARTL + movwf FSR1L + bsf FLAGS,UNDERRUN + + ;; ------------------- +rbuf_next + btfsc FLAGS,OVERRUN + goto rbuf_move_ptr + + movf FSR0H,w + xorwf FSR1H,w + btfss STATUS,Z + goto rbuf_move_ptr + + movf FSR0L,w + xorwf FSR1L,w + btfss STATUS,Z + goto rbuf_move_ptr + + bsf FLAGS,UNDERRUN + return + +rbuf_move_ptr + bcf FLAGS,OVERRUN + addfsr FSR1,1 + + movf FSR1H,w + sublw BUF_ENDH + btfss STATUS,C + goto rbuf_wraparound + btfss STATUS,Z + return + movf FSR1L,w + sublw BUF_ENDL + btfsc STATUS,C + return + +rbuf_wraparound + movlw BUF_STARTH + movwf FSR1H + movlw BUF_STARTL + movwf FSR1L + return + + ;; ------------------------------------- ;; INIT init ;; BANK 4 |