please dont rip this site

Converting from SXKey to SASM

Replace all occurances of <> with !=

Replace all = in if statements with == (you will get "Missing right parethesis" as the error if you forget this)

Replace all OR in if statements with ||

Replace all AND in if statements with &&

Replace all NOT in if statemetns with !

Local directives must be on the VERY NEXT line after the macro statement.

Parameters are passed to Macros in SASM by name and in SXKey by value. If you have a macro that compiles some code and then a jump to an address which is passed as a parameter, and you call the macro with <macroname> $ when $ is, for example, 0010, in the SXKey, the macro will compile a jump to 0010. In SASM the macro will compile a jump to the value of $ at the time the jump is compiled (it will always make an endless loop). You can override this by calling the macro with <macroname> ?$ but if the macro compiles the jump with jmp @\1 it will cause an "Symbole <#> is not defined" error; instead, you must compile the jump with jmp C<@$??\1> (see the SASM manual section 4.4.2 "Token Pasting"). You can also compensate by defining a local var in the macro, setting the var to \1 before any code is compiled and then useing the var rather than the parm when the jump is compiled.

Debugging macros is somewhat hindered by the fact that the line number of the error is reported at the line where the macro is called followed by the line where the actual error occurs in the list file, but if there are errors, you can't get a list file with Ctrl-L... however, the list file is generated and can be opened seperatly to show the actual error in the macro. 

In the SX Key assembler, dot values (like the bit number of a port pin) are actually multiplied by $100 and added to the main number. E.g. RA.1 is $105. So... if you defined a constant like RS232Tx = RA.1 and then later wanted a mask to xor against the port to toggle the bit (I know, read-modify-write, this is just an example) you could do something like xor ra, #(1<<(RS232Tx / $100)) and it would make the correct mask. Just in case it isn't clear, the advantage of this is that if, later down the road, you changed RS232Tx = RA.2, the mask would automatically correct itself. SASM Keeps these values as fractions (apparently) so RA.1 is $5.1. After stratching around for a while, I found that the DOT operator (.) also works to convert a dot value back into a bit number. So if you have RS232Tx = RA.1 the value of .RS232Tx is 1. And, believe it or not, ..RS232Tx is .1. Confused yet? Ok, anyway, the mask can be made with xor ra,#(1<<(.RS232Tx))

I had found a problem in SASM that kept me from using it in place of the SXKey for anything more than small projects until Peter Montgomery fixed it for me. If you look at lines 17, 20, and 23 you can see that an equate IN A MACRO defines a global label at the point that the macro is called. Notice that the same program compiles just fine in the SXKey (next listing)
I just wish the SXKey would work in a command line mode and produce an output that could be used with the SX-DEV from SVTEVS. I've been playing with their development system and it is really, really, nice... So far, anyway.
Yes, I can do :mytest2 = 1 or even add LOCAL mytest2 but then mytest2 is not a global value... So I have no way to number or track values between macro invocations.
I could also use MAIN:LOOP rather than :LOOP, but that sort of defeats the purpose of local labels doesn't it?
I would be set if:
 DEVICE  SX28L
        mymacro     MACRO
          mytest2 = 1
          ENDM
 org 0000
 ;--------------- SX INTERRUPT  VECTOR --------------------
 ; INTERRUPT                     
 RETI            ; RETURN FROM INTERRUPT
 ;---------------------------------------------------------
 ;----------------   Place YOUR CODE here ------------------
SX_RESET
 mov     !RC,#01111111b
MAIN
 ;   mytest1 = 1
 ;   mymacro
:LOOP XOR RC,#80h
 ;   mytest3 = 1
 mymacro
 JMP :LOOP
     1                  ;******* Little program: blinking LED connected to port RC.7 *****
     2                 
     3  0FFB  0F7F                      DEVICE  PINS28,OPTIONX
     4                 
     5                  mymacro MACRO
     6                   mytest2 = 1
     7                   ENDM
     8  =00000000                       org     0000
     9                 
    10                  ;--------------- SX INTERRUPT  VECTOR --------------------
    11  =00000000       INTERRUPT                              
    12  0000 000E                      RETI                    ; RETURN FROM INTERRUPT
    13                  ;---------------------------------------------------------
    14                 
    15                  ;----------------   Place YOUR CODE here ------------------
    16  0001  0C7F      SX_RESET        mov     !RC,#01111111b ;   0002  0007
    17  =00000003       MAIN
    18                  ;       mytest1 = 1
    19                  ;       mymacro
    20  0003  0C80      :LOOP           XOR     RC,#80h
        0004  01A7
    21                  ;       mytest3 = 1
    22                          mymacro
    23  =00000001    m   mytest2 = 1
    25  0005  0A00                      JMP     :LOOP
****** testsasm.asm(23) Line 25, Error 3, Pass 2: Symbol <mytest2:LOOP> is not defined
    26                  ;----------------------------------------------------------
    27                 
    28                  ;=== Don't use SASM's 'RESET' directive, always place this code at the end of your source ---
    29                 
    30  =000007FF                       ORG     07FFh           ;Reset Vector for 2K code configuration
    31  07FF  0A01                      JMP     SX_RESET
    32                  end

Cross Reference
6 symbols

Symbol                  Type   Value      Line
INTERRUPT               ADDR   00000000   0011
MAIN                    ADDR   00000003   0017
MAIN:LOOP               ADDR   00000003   0020
mytest2                  VAR   00000001   0023
RC                      RESV   00000007   0020
SX_RESET                ADDR   00000001   0016



In the SX Key, this compiles just fine. It understands that the mytest2 = 1 is NOT defining a lable for the MAIN area.

              ;******* Little program: blinking LED connected to port RC.7 *****
                    DEVICE  SX28L,STACKX_OPTIONX
              mymacro     MACRO
               mytest2 = 1
               ENDM
000-                    org0000

              ;--------------- SX INTERRUPT  VECTOR --------------------
000-    ; INTERRUPT                      
000- 00E                  RETI            ; RETURN FROM INTERRUPT
              ;---------------------------------------------------------

              ;----------------   Place YOUR CODE here ------------------
001- C7F 007    SX_RESET  mov     !RC,#01111111b
003-      MAIN
              ;   mytest1 = 1
              ;   mymacro
003- C80 1A7    :LOOP        XOR       RC,#80h
              ;   mytest3 = 1
005-              mymacro
=00000001        mytest2 = 1
005- A03                  JMP       :LOOP
              ;----------------------------------------------------------

              end

Comments:

See:


file: /Techref/scenix/SXKEY2SASM.htm, 15KB, , updated: 2004/10/8 13:50, local time: 2024/12/24 05:32,
TOP NEW HELP FIND: 
3.144.235.195:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/techref/scenix/SXKEY2SASM.htm"> Converting from SXKey to SASM</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .