In SX Microcontrollers, SX/B Compiler and SX-Key Tool, verobel wrote: Fellow SXers; I have been slowly learning SX assembler and SX/B over the last few weeks, following 2 books by Al Williams and Gunther Daubach.. My goal is to transfer Robot1 and Speedo1 basic stamp programs to SX28. My initial attempts both failed.. although I was able to get Robot1 compiled in SX/B..but didn't know enough to figure out what was wrong.. so I backtracked and started reading the 2 books and many Nuts&Volts articles by Jon Williams. There is alot of ground to cover but fortunately lots of support in text. I got to pg. 75 Unit 5 and have piezo tones coming out using Program5.1 but then got stuck on similar tone gen. program on pg. 75 in SX/B: my File Prog5d2.SXB. Initially it would not compile because I didn't release _PARAM1 has two underscores. I also could not compile because the IDE would not open a file called Prog5.2.SXB.. works ok with Prog5d2.SXB. Now it compiles but doesn't 'play the music' ..so I've been trying to figure out why.. so I debug/step thru that auto generated code.. and see alot of stuff.. like system param setup (30 lines), system initialize (35 lines), and expansion code for for-next loops, lookup, gosub.. which brings me to the questions.. I have backed up to easier sample program (by parallax) Toggle.SXB example (to keep it simple) ..it does: DO PAUSE BlinkDelay ' delay TOGGLE AlarmLed ' toggle LED state LOOP which assembles to (only lines of interest shown): 140 0037 0CFA MOV __PARAM2,#250 ; PAUSE BlinkDelay ' delay 0038 0029 141 0039 0C04 MOV __PARAM3,#4 003A 002A 142 003B 0C1C MOV __PARAM4,#28 003C 002B 143 003D 02EB DJNZ __PARAM4,@$ 003E 0010 0A3D 144 0040 02EA DJNZ __PARAM3,@$-3 0041 0010 0A3D 145 0043 02E9 DJNZ __PARAM2,@$-10 0044 0010 0A39 146 147 0046 0CFB MOV FSR,#__TRISB ; TOGGLE AlarmLed ' toggle LED state 0047 0024 148 0048 0420 CLRB IND.1 149 0049 005F MODE $0F 150 004A 0200 MOV !RB,IND 004B 0006 151 004C 0018 BANK $00 152 004D 0C02 XOR RB,#%00000010 004E 01A6 153 154 004F 0010 JMP @__DO_1 ; LOOP ' loop forever 0050 0A37 155 =00000051 __LOOP_1: so I was stepping thru and thinking I am calling a PAUSE routine with 1 param: blinkdelay but the code looks like it is working with 3 params ( line 141-145) and it loops quite a bit in there (needlessly?) ..is this really necessary.. or how does this work? I can see how the toggle works and the DO LOOP. Perhaps someone could explain a bit more about what the intialize code does and when and if it can be dropped.. or for that matter, how it could be dropped? Then a similar explanation for subroutine pass code would be nice. This program (above) works.. I'm just trying to understand what is going on.. so when I look back at the bigger program for tone display.. I can sort out subrt, lookup, pause, and toggle code.. in an effort to figure out why it is not working. I have attached a copy of Prog5d2.SXB ..perhaps someone could scan that too, to spot any obvious problems.. I might have done a typo. Thanks all. John ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=163425 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)