In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Rsadeika wrote: So, here is my idea, below I have inserted a piece of code that I used in another thread. This is the standard pause, turn on an led, and then pause, turn off the led. The reason I chose this example is because it is pretty simple in code style, and it has an element to it where it could be used in asm, and SX/B What I am talking about is the pause command aspect. In SX/B I noticed that the code is not optimized, and it has been stated many times before that SX/B is a learning tool, and the compiler is not optimized. What that means is, when you use the pause command, I will just stick with that command for the time being, in SX/B it is like a macro, the code, that makes up the pause command, gets used, or expanded, with each use of pause. So, what I am thinking is that, first off, piddle with the pause part of the listed code so it looks like a command, name the command wait. That way we could have a good example of a macro wrapper implementing a subroutine, that could be the profile for all other entries into the lib. Then discuss where in the main code you would have to put the include statement, and what the structure of the new wait command is supposed to look like within the include file. The reason I chose the pause or wait as the candidate, is because once the wait command gets worked out in asm then it could be tried out as an optimized replacement for the pause command in SX/B. That way it would be a learning experience as to how to use a library with SX/B. I left the code example in SX52 format, but it is a very simple task to make it work in SX28 format. Any ideas, maybe somebody has a better suggestion. Thanks Ray ******CODE For starters I guess: WAIT macro call _wait endmacro _wait: Loop ;If I remember correctly this would time in at 1.3 seconds at 50MHz ; one of the improvements could be to make this 1 second at all frequencies. decsz Counter1 jmp Loop decsz Counter2 jmp Loop decsz Counter3 jmp Loop ret ************************************ ;;; ;; Tut003.src ;;; device sx52 device oschs3 ;High speed crystal, 1MHz - 75MHz IRC_CAL IRC_FAST ;For use with external crystal/oscillator freq 50_000_000 reset Main ;Label where the program starts ;Data memory ;org $08 org $0A ;SX52 -> $0A, SX28 -> $08 Data memory ; satrt Counter1 ds 1 Counter2 ds 1 Counter3 ds 1 ;End of data ;Code memory org $0 ;Code memory start position Main mov w,#$1f ; mov m,w mov !rd,#%11111110 Loop decsz Counter1 jmp Loop decsz Counter2 jmp Loop decsz Counter3 jmp Loop clrb rd.0 Loop1 decsz Counter1 jmp Loop1 decsz Counter2 jmp Loop1 decsz Counter3 jmp Loop1 setb rd.0 jmp Loop jmp $ ;I like to use this to end my code ;at this point it is in endless loop. end ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=103848#m104138 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)