1 ; common macros & equs etc.
3 ;**********************************************************************
5 ; Include this at the top of each file.
6 ; Does the following things:
7 ; includes the PIC18F458 definitions file (register and bit names)
8 ; switches to decimal by default
10 include /usr/share/gputils/header/p18f458.inc
13 ;****************************************************************************
16 ;----------------------------------------
17 ; ifbit1(REGISTER,BITNUMBER)
18 ; executes the next instruction but only if bit BITNUMBER
19 ; in REGISTER (which must be in the access bank) is set
20 ifbit1 macro REGISTER, BITNUMBER
21 btfsc REGISTER, BITNUMBER, 0
24 ;----------------------------------------
25 ; ifbit0(REGISTER,BITNUMBER)
26 ; executes the next instruction but only if bit BITNUMBER
27 ; in REGISTER (which must be in the access bank) is clear
28 ifbit0 macro REGISTER, BITNUMBER
29 btfss REGISTER, BITNUMBER, 0
32 ;----------------------------------------
34 ; writes BYTE through the serial port
35 ; serial port hardware must be suitably initialised
36 ; serial port transmit interrupts must be disabled
37 ; will spin until the byte is transmitted
42 ; macro to call subroutine to transmit over serial port for debugging
43 ; takes 8-bit value, puts in W, invokes debug_serial_transmit
45 debug macro debugvalue
50 debug macro debugvalue
52 call polling_serial_transmit
56 ;----------------------------------------
58 ; reads REGISTER once and writes it to the serial port in hex
59 ; for conditions etc. see "debug", above
64 DEBUGHF_VALUE equ 0x040 ; getting on towards end of access bank
65 ; FIXME if all of program used udata that
68 debughf macro register
69 movff register, DEBUGHF_VALUE
70 call debughf_subroutine
80 ; transmits top nybble of DEBUGHF_VALUE in hex
81 ; through serial port, as above, and swaps nybbles
84 ; DEBUGHF_VALUE BBBBaaaa aaaaBBBB (BBBB was sent)
86 swapf DEBUGHF_VALUE,1,0
87 movf DEBUGHF_VALUE,0,0
91 bn debughf_digit_ifnot_ge10
93 debughf_digit_ifnot_ge10
95 goto polling_serial_transmit
98 debughf macro register
104 ;****************************************************************************