In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote: This is it. You can call Assign with identical names from different locations, but the entry is only generated once. 1 07F8 0F7F device SX28,oschs1,turbo,stackx,optionx ;sx device options 2 =00000000 irc_cal IRC_SLOW 3 =02FAF080 freq 50_000_000 ;cpu frequency 4 07FF 0A07 reset main 5 expand 6 7 =00000000 Irx1value = 0 ;define variables for possible labels 8 =00000000 Irx2value = 0 9 10 Assign macro Name ;create a macro 11 if I??Name??value == 0 12 I??Name??value = 1 ;prevent multiples 13 I??Name 14 jmp @??Name ;create this label from the parameter passed 15 endif 16 endm ;done 17 18 =00000000 org 0 19 Assign rx1 20 m if Irx1value == 0 21 =00000001 m Irx1value = 1 ;prevent multiples 22 =00000000 m Irx1 23 0000 0010 m jmp @rx1 ;create this label from the parameter passed 0001 0A04 24 m endif 26 Assign rx2 27 m if Irx2value == 0 28 =00000001 m Irx2value = 1 ;prevent multiples 29 =00000002 m Irx2 30 0002 0010 m jmp @rx2 ;create this label from the parameter passed 0003 0A05 31 m endif 33 Assign rx1 ;create entry from 2nd location 34 m if Irx1value == 0 35 m Irx1value = 1 ;prevent multiples 36 m Irx1 37 m jmp @rx1 ;create this label from the parameter passed 38 m endif 40 41 =00000004 rx1 42 0004 0C01 mov w,#1 43 =00000005 rx2 44 0005 01C4 add w,fsr 45 0006 000C ret 46 =00000007 main 47 0007 0A07 jmp main 48 Cross Reference 12 symbols Symbol Type Value Line __SASM DATA 00000001 0000 __SX_FREQ DATA 02FAF080 0003 __SX_IRC_CAL DATA 00000000 0002 __SX_RESET RESB 00000A07 0004 fsr RESV 00000004 0044 Irx1 ADDR 00000000 0022 Irx1value VAR 00000001 0007 Irx2 ADDR 00000002 0029 Irx2value VAR 00000001 0008 main ADDR 00000007 0046 rx1 ADDR 00000004 0041 rx2 ADDR 00000005 0043 The idea is to create compile variables for each possible label, initialized to 0. Inside Assign, those variables will be set to 1, so a second call with an identical name does not generate code. regards peter ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=244787#m245771 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)