> Does anyone have an example or explanation of how to encapsulate i/o in > assembly and C? You've probably done this lots of times, just didn't associate it with the word "encapsulation". A common example is a module that handles the UART for you. You might have UART_PUT and UART_GET subroutines. The only code that accesses the UART hardware directly is in this module, and all other code calls UART_GET or UART_PUT to receive or transmit a byte. Encapsulation is generally good practice, but it can be taken too far in small resource-limited systems that are running at the edge of their speed or space capabilities. On a recent project I had a 16F877 that implemented an external 8 bit data bus with various devices hanging off it. Creating a subroutine to talk to each device would have been nice, but would have required too many cycles in a few places. I had two key loops that each had to be less than 40 cycles long. In this case I used macros to access the bus devices. This provides encapsulation at the source code level only, and therefore may not be true "encapsulation". In otherwords, nice software structure is definitely good, but you can't let it get in the way of solving the problem. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu