Shop OBEX P1 Docs P2 Docs Learn Events
Pic assem to sx assem error — Parallax Forums

Pic assem to sx assem error

datacpsdatacps Posts: 139
edited 2007-10-04 13:08 in General Discussion
I am trying to convert an old pic code I had done for me sometime ago and I don't understand assembly that is why I would rather use SX/B but this code is close enough to translate to SX assembly with a little help from members here. I am sold on the sx chip and want to convert and use the sx chip on all my projects/ I get a few errors like

·:loop
·;
·; Determine Initial firing angle
·;

·setangle
call··· getisync··············
mov·· countl,isync Nsave it
call··· getisync··············
cjne·· countl,isync,setangle
call··· getisync······························
cjne·· countl,i sync, setangle
······
error 45 label must begin in column
I have a lot of these errors so fixing one will fix a lot of the code

·mov mode, #1···· ;turn on green LED
·then:·error 4·mode is a reserved word
I got of few of these
I·would like to use the sx chip for this project if I can convert the code over.. It was an old pic tools code made by parallax a few years back.
·

Comments

  • Doug HaleDoug Hale Posts: 23
    edited 2007-10-02 03:50
    Try this, I haven't used it in a long time, let me know what happens.

    http://www.doughale.com/SXtools/Install/PIC2SX.exe
  • BeanBean Posts: 8,129
    edited 2007-10-02 12:00
    Remove the space before "setangle", and put a colon after it.

    It looks like there is a variable named "mode", that name will have to be changed.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I know what I know, don't confuse me with the facts...
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2007-10-02 15:40
    Having just a piece of the code really makes it hard to point you toward SX/B rather than SASM. There really isn't any overview of what tasks the program is trying to accomplish or any information about i/o.

    So, if you really want to go to SX/B, could you post the whole original PIC program for review?

    What is the target chip?··There are dozens of different PIC chips with special functions.· If you are using a 16C84, conversion is easy.· But if you have CANbus included in your project, it is nearly impossible as that is licensed software/firmware from Bosh.

    In between the extremes, the SXes can often duplicate certain portions of hardware in software called Virtual Peripherials.· The PIC code may be useless in those areas, but there is another way.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Everything in the world is purchased by labour; and our passions are the only causes of labor." -- David·Hume (1711-76)········
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 10/2/2007 3:48:08 PM GMT
  • PJMontyPJMonty Posts: 983
    edited 2007-10-02 17:14
    Datacps,

    Go to this page:

    www.sxlist.com/cgi-bin/mpasm2sasm2.exe

    It's an online PIC assembly to SX assembly converter that is hosted on James Newton's SXList site. I've used it and found it works great.

    With regards to your label issue, the error is pretty clear. Labels have to start in column one. If you look at your code, you'll see a label called "setangle" which has a space in front of it. Since there is a space, the label isn't starting column one, which is exactly what the error message is telling you.

    Thanks,
    PeterM
  • datacpsdatacps Posts: 139
    edited 2007-10-04 01:38
    ok guys here more of the code perhaps if you copy and paste you can see what I am talking about. This code and circuit I want to enter in the contest.. I think I can win first place with it and I know you guys will have a lot of fun with it too. If it is not enough I would prefer to IM or email it to who ever will help me with it.. If I win any money I will send you some.. I tried the conversion but still get errors..


    DEVICE SX28,OSC4MHZ,TURBO

    IFDEF __SASM ;SASM Directives
    DEVICE STACKX,OPTIONX
    IRC_CAL IRC_SLOW

    ELSE ;Parallax Assember Directives
    DEVICE STACKX_OPTIONX
    ENDIF


    ;
    DEBUG SETTINGS

    FREQ 4_000_000

    ;
    INITIALIZATION ROUTINE
    ;Och to 4fh for picl6c7ll
    counth ds 1 ;
    count1 ds 1 ;
    temp ds 1 ;
    bitcnt ds 1 ;
    i_sync ds 1 ;
    trigger ds 1 ;
    ttrig ds 1 ;
    mode1 ds 1 ;
    mintrig ds 1 ;
    maxtrig ds 1 ;
    vibrate ds 1 ;
    cyccnt ds 1 ;ut
    t_option ds 1 ;
    flag ds 1 ;flag bits
    ;flag.0 ;
    ;flag.1 ;
    ;flag.2 ;
    ;fLAG.3 ;1=
    ;flag.4 ;0=
    ;flag.5
    ;flag.6 ;1= do not run in turbo mode
    ;flag.7 ;image of Z status bit

    i_w ds 1 ;temp "w" save
    i_s ds 1 ;temp "status" save
    bgtemp ds 1 ;temporary location
    second ds 1 ;second counter for led update
    SD EQU RB.1 ;SERIAL OUTPUT DATA (TEST), ACTIVE HIGH
    SK EQU RB.2 ;SERIAL SHIFTCLOCK (TEST),
    LE EQU RB.3 ;SERIAL LATCH ENABLE (TEST),


    ORG 0
    ;jmp reset

    ;interupt Vector


    ORG 4
    jmp int_srv
    ;entered here from either power-up or WD timeout

    ; ORG lOh
    :reset
    clr intcon ;clear interrupt flags & disable int's
    clr flag ;clear all flags
    mov t_option,#084h ;RTCC prescale 1:32, INT on falling ed

    ;initilize I/O ports


    clrb status.5 ;Select bank 0
    mov ra,#019h ;clear port A
    ;mov rb,#0flh ;clear port B
    mov w,t_option ;get option byte
    setb status.5 ;select bank 1
    mov option,w ;Set option register
    mov trisa,#16h ;0=output pin, 1=input pin
    mov trisb,#Olh ;0=output pin, 1= input pin
    clrb status.5 ;select bank 0


    ;initialize interrupt system


    mov second, #60
    clrb flag.0 ;
    mov intcon,#30h ;TIMERO and INT interrupts enable
    setb gie ;kick off interrupts

    ;
    ; Main Program start up
    ;


    mov countl,#60

    :loop
    jb flag.1,$ ;
    jnb flag.1,$ ;e
    djnz countl,:loop ;
  • PJMontyPJMonty Posts: 983
    edited 2007-10-04 05:27
    Datacps,

    Since it's a code snippet, there are some errors that I assume don't happen with the full source code. For example, the first error I get is that "int_srv" is not defined. Since the line in question is "jmp int_srv", it means that the sub-routine called "int_srv" is somewhere else in the rest of the code.

    The next error is that "int_con" isn't defined. This might be a PIC thing since the comment says it clears the interrupt flags and disables the interrupt. You can't generically disable all interrupts in the SX. You either enable or disable interrupts on a source by source basis. In other words, you turn the RTCC interrupt on or off, you set bit changes to generate interrupts or not, etc.

    The next error is that "option" isn't defined. Again, this looks like a PIC specific error. In this case, you're trying to set some options. In the SX this is done via the MODE command. Look in the SX-Key v2.0 manual (a PDF installed on your computer when installing the IDE) starting on page 167 for the information needed here. This will also solve your "trisa_a" and "tris_b" issues which come next. Those lines are just trying to set some bits to output and some to inputs. The SX code is similar but different. Page 167 to 173 explains what to do.

    BTW, line 64 ("mov t_option,#084h ;RTCC prescale 1:32, INT on falling ed") may need modification. Check out page 174 for the info you need to verify this line of code.

    The next error is slightly sneaky. The line reads, "mov trisb,#Olh ;0=output pin, 1= input pin". The error says that "Olh isn't defined." The trick is that the code is supposed to be a zero followed by a one followed by the letter "h". This would be defining the number 1 as a hex number. However, the code has a capital letter "o" followed by a lowercase "L" followed by the letter "h". In the a font like Courier, the letter "O" and the number "0" look identical, as do lowercase "L" and the number "1". Modify the code to use numbers (as intended) instead of letters.

    I recommend you go to the Microchip site and download the datasheets for whatever PIC processor this code was originally written for. You need to do some research to fine out how interrupts work on that chip, as well as how the various options are set.

    Thanks,
    PeterM
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2007-10-04 10:51
    In summary, bits and pieces just don't make any sense to us. We can fix them, but they won't work together unless we understand to whole idea.

    Either the whole original PIC code is needed or a clear explanation of the intended project. We all can understand that you may not want to post that because you are in a competition. But in that case, you really need to find someone that you can trust to help out privately and one-to-one.

    Since it appears you don't understand assembly in either PIC or SXes, you may be expecting too much, too soon. If might be better to start from scratch with SX/B.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Everything in the world is purchased by labour; and our passions are the only causes of labor." -- David·Hume (1711-76)········
    ···················· Tropically,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • BeanBean Posts: 8,129
    edited 2007-10-04 13:08
    I agree with Kramer, I would suggest you just re-write the code in SX/B. Then you will have a better understanding of it. And be able to modify it easier.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My goal is to live forever...Or die trying.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
Sign In or Register to comment.