I've just finished porting my conditional macros to SASM for use with this new IDE. http://www.sxlist.com/techref/ubicom/sasmcond.src is the include and http://www.sxlist.com/techref/ubicom/sasmtemp.src is a template with some test code and it includes the sasmcond file. These generate very tight asm code based on standard conditional structures like: DoSelect DoCase 23,eq,24 clr 25 DoCase 26,eq,27 clr 28 DoSelect DoCase 29,eq,30 clr 31 DoIf 32,EqN,32 clr 33 DoElseIf 34,Lt,35 clr 36 DoElse clr 37 DoEndIf DoCase 27,eq,25 clr 25 DoCaseElse clr 25 DoCaseEnd DoCaseElse clr 25 DoCaseEnd binjump intI,:zero, :notzero, :done, :outsideloop, :insideloop GotoW :zero, :notzero, :done, :outsideloop, :insideloop Which generates: 6530 ;And now, lets KICK IT UP A BIT!!! 6531 6532 DoSelect 6552 DoCase 23,eq,24 6619 026A 0018 m bank ??000E1 ;non-global 6631 026B 0218 m mov w, ??000E1 6641 026C 0018 m bank ??000DF ;non-global 6653 026D 0197 m xor w, ??000DF 6658 026E 0743 m sz 6707 m ;mp +FAIL 6711 0271 0079 clr 25 6712 DoCase 26,eq,27 6724 =00000272 m ??000E2 = $ 6725 m ;mp +SUCCEED 6740 =026F0274 m :FAIL =??000E3 6793 0274 0018 m bank ??000EB ;non-global 6805 0275 021B m mov w, ??000EB 6815 0276 0018 m bank ??000E9 ;non-global 6827 0277 019A m xor w, ??000E9 6832 0278 0743 m sz 6881 m ;mp +FAIL 6885 027B 007C clr 28 6886 DoSelect 6906 DoCase 29,eq,30 6973 027C 0018 m bank ??000F2 ;non-global 6985 027D 021E m mov w, ??000F2 6995 027E 0018 m bank ??000F0 ;non-global 7007 027F 019D m xor w, ??000F0 7012 0280 0743 m sz 7061 m ;mp +FAIL 7065 0283 007F clr 31 7066 DoIf 32,EqN,32 7095 0284 0C20 m mov w, #??000F7 7139 0285 0019 m bank ??000F5 ;non-global 7151 0286 0180 m xor w, ??000F5 7156 0287 0743 m sz 7211 =00000288 m :ComeFrom=$ 7212 m ;mp +FAIL 7216 028A 0061 clr 33 7217 DoElseIf 34,Lt,35 7225 =0000028B m :ComeFrom=$ 7226 m ;mp +SUCCEED 7241 =0288028D m :FAIL =??000F9 7293 028D 0019 m bank ??000102 ;non-global 7305 028E 0203 m mov w, ??000102 7315 028F 0019 m bank ??000100 ;non-global 7353 0290 0082 m mov w, ??000100 - w 7357 0291 0603 m snc 7381 =00000292 m :ComeFrom=$ 7382 m ;mp +FAIL 7386 0294 0064 clr 36 7387 DoElse 7403 =00000295 m :ComeFrom=$ 7404 m ;mp +SUCCEED 7419 =02920297 m :FAIL =??000104 7423 0297 0065 clr 37 7424 DoEndIf 7444 =02950298 m :FAIL =??00010E 7456 DoCase 27,eq,25 7468 =00000298 m ??000112 = $ 7469 m ;mp +SUCCEED 7484 =0281029A m :FAIL =??000113 7537 029A 0018 m bank ??00011B ;non-global 7549 029B 0219 m mov w, ??00011B 7559 029C 0018 m bank ??000119 ;non-global 7571 029D 019B m xor w, ??000119 7576 029E 0743 m sz 7625 m ;mp +FAIL 7629 02A1 0079 clr 25 7630 DoCaseElse 7640 =000002A2 m ??00011C = $ 7641 m ;mp +SUCCEED 7657 =029F02A4 m :FAIL =??00011D 7660 02A4 0079 clr 25 7661 DoCaseEnd 7676 =02A202A5 m :SUCCEED=??000122 7699 =029802A5 m :SUCCEED=??000122 7741 DoCaseElse 7751 =000002A5 m ??00012B = $ 7752 m ;mp +SUCCEED 7768 =027902A7 m :FAIL =??00012C 7771 02A7 0079 clr 25 7772 DoCaseEnd 7787 =02A502A8 m :SUCCEED=??000131 7810 =027202A8 m :SUCCEED=??000131 7852 7853 binjump intI,:zero, :notzero, :done, :outsideloop, :insideloop 7861 02A8 0011 m page $ 7867 02A9 0652 m jb intI.2, @MAIN:insideloop ;=4 02AA 0010 0B45 7873 02AC 0632 m jb intI.1, ??00013E 02AD 0AB3 7894 02AE 0712 m jnb intI.0,@MAIN:zero 02AF 0010 0B24 7911 02B1 0010 m jmp @MAIN:notzero 02B2 0B34 7922 =000002B3 m ??00013E 7937 02B3 0712 m jnb intI.0,@MAIN:done 02B4 0010 0B43 7954 02B6 0010 m jmp @MAIN:outsideloop 02B7 0B44 8010 8011 GotoW :zero, :notzero, :done, :outsideloop, :insideloop 8062 02B8 0403 m clc 8066 02B9 0361 m rl WReg ;need long jumps 8067 m ;WARNING: Insure OPTION:RWT = 0 8100 =000002BA m ??000141 = $ 8101 02BA 01E2 m add PC,W ;jump to the jump 8110 02BB 0B24 m jmp MAIN:zero 8120 02BC 0B34 m jmp MAIN:notzero 8130 02BD 0B43 m jmp MAIN:done 8140 02BE 0B44 m jmp MAIN:outsideloop 8150 02BF 0B45 m jmp MAIN:insideloop Note that there is a bug in SASM that makes it impossible to define a variable in a macro without causeing any local labels after the macro is used to be unreachable. Peter has provided me with a fix for that bug (as well as others) which is not generally available and which makes the use of these macros a lot more attractive. Here is a list of the macros and what they do: ; BinJump ,
[,
] ; Call with the first parameter of the register to tbe tested and ; the following parameters a list of addresses to jump to based on ; the value of the register. ; More effecient than a long jump table for 4 or fewer addresses ; GotoW
[,
] ; Implements a jump table using space in the first low half page of memory. ; must be invoked after all
's are defined. ; Uses BinJump for less than 5 addresses ; Condition enum (IsZero,Eq,Lt,LE,IsNotZero,NE,Gt,GE,EqN,LtN,LEN,NEN,GtN,GEN) ; enum values ending in N indicate that the second operand will be a constant ; Condition := [, | , , | , , ] ; Skz , [IsZero | IsNotZero] ; Generates a skip if the reg is zero or not zero ; Skc , [Eq | Lt | LE | NE | Gt | GE], ; Generates a skip if reg1 compaires as specified to reg2 ; Skc , [EqN | LtN | LEN | NEN | GtN | GEN], ; Generates a skip if reg compaires as specified to constant ; StackPUSH, StackPOP, StackTOS and stack1... ; Provide a compile time stack to record and retrieve the addresses of ; locations were jumps need to be compiled once the jump-to address is ; known. Used by the following macros: ; Repeat ; ; [forever | while | until ] ; ; compiles Skz or Skc with jumps to implement a structured loop ; DoIf ; ; [ ; DoElseIf ; ; ]... ; [ ; DoElse ; ; ] ; DoEndIf ; ; Compiles Skz or Skc with jumps to implement a structured conditional ; As many DoElseIf statements as desired may be included because each DoElseIf ; links to the next one at run time so that if the first DoElseIf condition ; is true, after its statements a jump will be compiled that will jump to ; the simular jump after the next DoElseIf statements. To avoid this extra ; run time, use DoSelect. ; DoSelect ; [ ; DoCase ; ; ]... ; [ ; DoCaseElse ; ; ] ; DoEndSelect ; ; Compiles Skz or Skc with jumps to implement a structured conditional ; A limited number of DoCase statments can be compiled because each ; case compiles a jump to the end of the select after the statements ; following the case condition and recording the position were these ; jumps must be org'd takes up space on the "stack" provided by ; StackPUSH, StackPOP and stack1...15 Next, I'll port the memory management macros so I don't have to screw with what page I'm in... --- James Newton, Host of sxlist.com 1-619-652-0593 VM 1-208-279-8767 FAX mailto:jamesnewton@sxlist.com SX FAQ: http://www.sxlist.com -----Original Message----- From: Peter Montgomery [mailto:pjmonty@csi.com] Sent: Friday, July 19, 2002 10:40 To: SXList Subject: [sxtech] New Beta SX-Key software from Parallax! Importance: Low Hi, As some of you (or may not) remember, I released a modified version of the SX-Key software late last year. It was posted on James Newton's site with the promise of more releases to come. For those of you who thought I had given up, the exact opposite is true. I was hired by Parallax to complete the feature request list, and the result of that work is finally available to everyone as a public beta. It can be downloaded at: http://www.parallaxinc.com/html_files/downloads/downloads_sx.htm While there are numerous enhancements and changes, here are a few important ones: 1 - A new, multi-file editor 2 - Scrollbars! 3 - Colored syntax highlighting. 4 - Multiple Un-Do. 5 - Integrated SASM as the new, default assembler. This allows the use of INCLUDE files. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body