In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: To Bean's point, you can save a lot of program memory with subroutines -- and by encapsulating "big" SX/B instructions into subroutines and functions. PAUSE, for example, can generate a bit of code and we use it all the time so it make sense to put it into a subroutine where the actual PAUSE instruction is only compiled once. This subroutine is in almost every one of my programs: [code]' Use: DELAY_MS mSecs ' -- delays program in milliseconds SUB DELAY_MS IF __PARAMCNT = 1 THEN tmpW1 = __PARAM1 ELSE tmpW1 = __WPARAM12 ENDIF PAUSE tmpW1 ENDSUB[/code] The definition line for this subroutine is: [code]DELAY_MS SUB 1, 2 ' delay in milliseconds[/code] Since I use these so much, I actually have them in external files so that I can put them into any program without copy-and-pasted. I've attached those files for you. Look for any SX/B instruction that it time-associated, things like PAUSE, PAUSEUS, SERIN, SEROUT, etc. -- these are all good candidates for encapsulation into a subroutine or function to reduce code space. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=204365#m204380 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)