Hey Guys, I was thinking about making a library for POSTINC1 & POSTINC2. Let me know what you think. Would it be a useful lib?
I find this quite useful and fast! It will be even more useful when the compile supports whereis on variables and arrays. These are quite easy to use as they are, but there are a few reasons for a library: 1. Naming can be improved 2. Can write to FSR1L/FSR1H with a word variable instead having to make a word variable in your code. although I wonder if this could be done in the device files. 3. It will be more understandable to users with naming and since there are notes in a library 4. May be able to support word, dword and byte*x variables through a lib. However, I think 16F pics do not have POSTINC and will either not be able to use the library, or the library can support a fake POSTINC for reading/writing arrays. Which is best? Libs using this could use if defined() to see if the PIC supports it, otherwise use other code. I see this will also be useful in the sd_card and hard_disk libraries for the 512 byte buffer. Currently those libs have a "extra speed" constant (user option) that uses about 20k of instructions to do what POSTINC1 could do instead with less instructions. Here's an example (untested). I suppose I need suggestions for naming. alias mem1_next_low is FSR1L alias mem1_next_high is FSR1H Procedure set_mem1_next'put(word in address) is pragma inline var byte address_bytes[2] at address mem1_next_low = address_bytes[0] mem1_next_high = address_bytes[1] end procedure Function set_mem1_next'get() return word is pragma inline var word address var byte address_bytes[2] at address address_bytes[0] = mem1_next_low address_bytes[1] = mem1_next_high return address end Function Alias mem1_next is POSTINC1 --------- So usage would be: set_mem1_next = 0x400 -- or whereis(my_array) serial_hw_data = mem1_next serial_hw_data = mem1_next As you may know, POSTINC1 is used in the current USB libs. Instead of set_mem1_next pesudo variables, can they be made in the device files? A library would not be needed except for points 3 & 4 above. var volatile byte FSR1L shared at 0xFE1 var volatile byte FSR1H shared at 0xFE2 var volatile word FSR1 shared at 0xFE1 var volatile alias set_mem1_next is FSR1 Matt. -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
