In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Rsadeika wrote: The new code is a fully functinal, adjusted to run on the SX48/52 proto board. After a couple of written brow beatings, I finaly got it. Hopefully I will not get lazy again, and revert back to my old ways. David mentioned that you first have to get the concept of variable memory and program memory straight in your head. So, here goes. From the compiler point of view, for the beginer, there are two areas in processor memory, one for the variables and one for the program space. From the programmers point of view, I have to define or designate which is which. As an aside, for the 16bit x86 assembly people, think DATA segment (DS) and CODE segment (CS). Start with the variables, for the SX28 it is $08, for the SX52 it is $0A. So, when you code org $0A, SX48/52 specific, the compiler is alerted that everything after this point is going to be variables, and to be put into the variable memory space. For the program, or code, you would use RESET plus a label, for example RESET Main. The compiler is alerted and it will place the code into the program memory. I lean towards stucture, so I know what is what. The trick is that you want keep the contents seperate, if you place a variable, or at least what you want to be treated as a variable, into the program space, that is going to be a problem. So now you are thinking, where does variable space end and where does the program space begin, from a programmers poit of view. For the variables it is org $08 or $0A, as explained earlier. And RESET for the program, or code. You have to be very aware of this, you do not want to be putting code into variable space and vice-versa. Best thing that I can recomend is, take some example code, like Guenther's , which I have at the end of this post, run it first, to make sure it works, then use the spider (debugger) to play around with. Change some of the org values around an see what happens. If I went astray somewhere, somebody put me back on track. I feel that this concept is very, very important, and you may want to make sure that it is well embedded in the brain. I know some of this was being talked about in another thread, but I wanted to keep as simple as possible, and not get into the minutae of achitecture, and other stuff. ******CODE ;;; ;; 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 $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=100433#m100960 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)