extra SX/B system code... use or remove?
verobel
Posts: 81
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·······
·
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·······
·
SXB
766B
Comments
All the loops in the assembly is how to make a PAUSE in assembly.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1
"USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
spkr PIN RB.0 'OUTPUT ' Make speaker output
I also noticed the NOSTARTUP cleared out a lot of assembly code
I also notice you removed 'toggle spkr' in favor of spkr = ~spkr
movin' on, John
Are you using the latest compiler ? If you look at the top of the listing it will show the compiler version. The latest is 1.51.03.
You can download the latest version from here: http://forums.parallax.com/attachment.php?attachmentid=43436
Unzip the file and copy the files to C:\Program Files\Parallax Inc\SX-Key v3.2.3\Compilers\SXB
Overwrite the existing files.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap used 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
SX-Video Display Modules www.sxvm.com
Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1
"USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
Post Edited (Bean (Hitt Consulting)) : 1/5/2007 1:14:29 AM GMT