Pic assem to sx assem error
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.
·
·: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
http://www.doughale.com/SXtools/Install/PIC2SX.exe
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
·
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)········
Post Edited (Kramer) : 10/2/2007 3:48:08 PM GMT
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
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 ;
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
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)········
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My goal is to live forever...Or die trying.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·