PIC basic to ASM learning
Watch
Announcements
Hi,
I am able to program PICs (not expertly
) in PIC basic, but for technical reasons I need to be able to add some ASM (assembler) blocks into my programs. I've no experience with ASM.
Is there anyone who can help me with this please?
Camerart.
I am able to program PICs (not expertly

Is there anyone who can help me with this please?
Camerart.
0
reply
Report
#2
What architecture? x86, x64 or other? Assembly is easy to learn (even x64) but it's only practical for a few select tasks (e.g. at work I'm often analyzing crash-dumps). With intrinsic code (in c/c++) where 'hidden' instructions can be directly accessed, one can argue assembly is not needed at all.
0
reply
(Original post by elohssa)
What architecture? x86, x64 or other? Assembly is easy to learn (even x64) but it's only practical for a few select tasks (e.g. at work I'm often analyzing crash-dumps). With intrinsic code (in c/c++) where 'hidden' instructions can be directly accessed, one can argue assembly is not needed at all.
What architecture? x86, x64 or other? Assembly is easy to learn (even x64) but it's only practical for a few select tasks (e.g. at work I'm often analyzing crash-dumps). With intrinsic code (in c/c++) where 'hidden' instructions can be directly accessed, one can argue assembly is not needed at all.
Thanks for your reply.
I am using a 18F2431 PIC which has special motor control attributes, and the program is written using a simulator (by Oshonsoft). This simulator doesn't support the special motor control attributes needed, so sections of the program need to be in Assembly. I can't understand c++.
Camerart.
0
reply
Report
#4
If it doesn't support them, does the hardware? Are you actually going to be controlling a motor? If not, have the simulated program just log what it would have done to a file / window / whatever.
0
reply
(Original post by unprinted)
If it doesn't support them, does the hardware? Are you actually going to be controlling a motor? If not, have the simulated program just log what it would have done to a file / window / whatever.
If it doesn't support them, does the hardware? Are you actually going to be controlling a motor? If not, have the simulated program just log what it would have done to a file / window / whatever.
0
reply
Report
#6
(Original post by Camerart)
The hardware in the 18F2431 is designed to control motors, and I intend to control a motor with it.
The hardware in the 18F2431 is designed to control motors, and I intend to control a motor with it.
But you're developing the program on a simulator, rather than the real hardware, right?
So is the issue that you don't have a proper development kit that will generate the right code for the hardware, or that you want to test the program with the inadequate simulator?
0
reply
(Original post by unprinted)
Yes, I got that.
But you're developing the program on a simulator, rather than the real hardware, right?
So is the issue that you don't have a proper development kit that will generate the right code for the hardware, or that you want to test the program with the inadequate simulator?
Yes, I got that.
But you're developing the program on a simulator, rather than the real hardware, right?
So is the issue that you don't have a proper development kit that will generate the right code for the hardware, or that you want to test the program with the inadequate simulator?
I like the simulator and we are trying to get the administrator to work on this chip, and yes, I am trying to test the program with this simulator. I understand that it won't let me do that properly, so I will need to check it via a computer readout connected to the PIC itself once programmed with a mixture of Basic with ASM sections.
C
0
reply
Report
#8
While you're testing the program on the simulator, you just want to know what it's doing - that doesn't need any assembler, just PRINT statements (or whatever PIC BASIC has to show stuff).
For running on the hardware, you're going to need PIC assembler, if your development compiler doesn't have the functions you want, however it does that.
Personally I'd be using Forth, which enables you to interactively debug on the hardware itself...
For running on the hardware, you're going to need PIC assembler, if your development compiler doesn't have the functions you want, however it does that.
Personally I'd be using Forth, which enables you to interactively debug on the hardware itself...
0
reply
(Original post by unprinted)
While you're testing the program on the simulator, you just want to know what it's doing - that doesn't need any assembler, just PRINT statements (or whatever PIC BASIC has to show stuff).
For running on the hardware, you're going to need PIC assembler, if your development compiler doesn't have the functions you want, however it does that.
Personally I'd be using Forth, which enables you to interactively debug on the hardware itself...
While you're testing the program on the simulator, you just want to know what it's doing - that doesn't need any assembler, just PRINT statements (or whatever PIC BASIC has to show stuff).
For running on the hardware, you're going to need PIC assembler, if your development compiler doesn't have the functions you want, however it does that.
Personally I'd be using Forth, which enables you to interactively debug on the hardware itself...
I need to be able to add ASM for the QUAD and PWM into my basic program.
0
reply
Report
#10
(Original post by Camerart)
I can write the program on the simulator, then compile the ASM and HEX with it. I can't test it with the simulator, as it doesn't support the QUAD module, so I can only see results from the PIC once programmed and running, via a UART sending information of counters etc on a receiving computer.
I need to be able to add ASM for the QUAD and PWM into my basic program.
I can write the program on the simulator, then compile the ASM and HEX with it. I can't test it with the simulator, as it doesn't support the QUAD module, so I can only see results from the PIC once programmed and running, via a UART sending information of counters etc on a receiving computer.
I need to be able to add ASM for the QUAD and PWM into my basic program.
0
reply
(Original post by CJKay)
Look for the datasheet and go from there. PIC assembly is very simple, especially in comparison to other chips.
Look for the datasheet and go from there. PIC assembly is very simple, especially in comparison to other chips.
Remember Eric Morecombe's quote? "I am playing all the correct notes, but not necessarily in the correct order"
C
0
reply
Report
#12
(Original post by Camerart)
Nice to know it's simple, but what is the simple process that will help me learn assembler? So far I've read the data sheet, which is long and has all the instructions, and I have printed out the ASM words, and some examples. When it comes to figuring out how write the code correctly. I'm lost.
Remember Eric Morecombe's quote? "I am playing all the correct notes, but not necessarily in the correct order"
C
Nice to know it's simple, but what is the simple process that will help me learn assembler? So far I've read the data sheet, which is long and has all the instructions, and I have printed out the ASM words, and some examples. When it comes to figuring out how write the code correctly. I'm lost.
Remember Eric Morecombe's quote? "I am playing all the correct notes, but not necessarily in the correct order"
C
0
reply
(Original post by CJKay)
You'll just have to Google some tutorials or something. If I remember how I learned it I'll get back to you, but that was a long time ago.
You'll just have to Google some tutorials or something. If I remember how I learned it I'll get back to you, but that was a long time ago.
0
reply
Report
#14
Whilst I've not got any experience with PIC microcontrollers (I've mostly worked on ATMega chips) my understanding is a lot of the hardware interaction is from manipulating register values (bytes of memory to setup various features and read/write data).
Learning this in ASM is going to be chip specific and probably a long process. This may be slightly simpler if you can write blocks of ASM in your PICAXE BASIC code but you'll still need to understand what the ASM is doing. If you go down this route you probably need to start off with something very basic (e.g. read in a gpio and set another gpio to mirror the input).
You may be better off learning a bit about C Programming and using that as a slightly higher level than ASM, you could still be manipulating register values but at least you should be able to use symbolc register names which will potentially work across various chips in the same family.
Learning this in ASM is going to be chip specific and probably a long process. This may be slightly simpler if you can write blocks of ASM in your PICAXE BASIC code but you'll still need to understand what the ASM is doing. If you go down this route you probably need to start off with something very basic (e.g. read in a gpio and set another gpio to mirror the input).
You may be better off learning a bit about C Programming and using that as a slightly higher level than ASM, you could still be manipulating register values but at least you should be able to use symbolc register names which will potentially work across various chips in the same family.
0
reply
(Original post by mfaxford)
Whilst I've not got any experience with PIC microcontrollers (I've mostly worked on ATMega chips) my understanding is a lot of the hardware interaction is from manipulating register values (bytes of memory to setup various features and read/write data).
Learning this in ASM is going to be chip specific and probably a long process. This may be slightly simpler if you can write blocks of ASM in your PICAXE BASIC code but you'll still need to understand what the ASM is doing. If you go down this route you probably need to start off with something very basic (e.g. read in a gpio and set another gpio to mirror the input).
You may be better off learning a bit about C Programming and using that as a slightly higher level than ASM, you could still be manipulating register values but at least you should be able to use symbolc register names which will potentially work across various chips in the same family.
Whilst I've not got any experience with PIC microcontrollers (I've mostly worked on ATMega chips) my understanding is a lot of the hardware interaction is from manipulating register values (bytes of memory to setup various features and read/write data).
Learning this in ASM is going to be chip specific and probably a long process. This may be slightly simpler if you can write blocks of ASM in your PICAXE BASIC code but you'll still need to understand what the ASM is doing. If you go down this route you probably need to start off with something very basic (e.g. read in a gpio and set another gpio to mirror the input).
You may be better off learning a bit about C Programming and using that as a slightly higher level than ASM, you could still be manipulating register values but at least you should be able to use symbolc register names which will potentially work across various chips in the same family.
Not wishing to change the subject, but part of this project is to re-program an Orange radio https://www.hobbyking.com/hobbyking/..._Receiver.html which has an Atmega 328p chip controlling the RF22s radio module. If you would like to help with this please let me know. (Very valuable)
Any help with the above ASM would be very helpful. So far I've turned a LED on by touching another pin

Camerart.
0
reply
Report
#16
(Original post by Camerart)
Not wishing to change the subject, but part of this project is to re-program an Orange radio https://www.hobbyking.com/hobbyking/..._Receiver.html which has an Atmega 328p chip controlling the RF22s radio module. If you would like to help with this please let me know. (Very valuable)
Not wishing to change the subject, but part of this project is to re-program an Orange radio https://www.hobbyking.com/hobbyking/..._Receiver.html which has an Atmega 328p chip controlling the RF22s radio module. If you would like to help with this please let me know. (Very valuable)
I would also highly encourage using C and a native avr compiler rather than going down the arduino (based around C++) route for the 328p and also learn about interrupt routines as that can make the code much more efficient.
(Original post by Camerart)
Any help with the above ASM would be very helpful. So far I've turned a LED on by touching another pin
Any help with the above ASM would be very helpful. So far I've turned a LED on by touching another pin

0
reply
(Original post by mfaxford)
I've not personally done much with the RFM22B (although I do have a couple of play with) but I know lots of people that have used them (there's even been one on a cube sat). I've done a bit of work with the newer RFM69. One word of warning, if you want to stay legal check the allowed bands, power and duty cycle that can be used license free (I think you're limited to a small range of frequencies around 434MHz and 10mW for license free usage - IR2030 is likely the best starting place for that in the UK). I believe the RFM22 is end of Life now (although still available) so if this for a new project you might be better looking at something else.
I would also highly encourage using C and a native avr compiler rather than going down the arduino (based around C++) route for the 328p and also learn about interrupt routines as that can make the code much more efficient.
That sounds like a decent start, I'm afraid I can't help much as I've not worked with PICs and don't do much with ASM - although I'm sure there are forums around dedicated to the sort of thing you're doing.
I've not personally done much with the RFM22B (although I do have a couple of play with) but I know lots of people that have used them (there's even been one on a cube sat). I've done a bit of work with the newer RFM69. One word of warning, if you want to stay legal check the allowed bands, power and duty cycle that can be used license free (I think you're limited to a small range of frequencies around 434MHz and 10mW for license free usage - IR2030 is likely the best starting place for that in the UK). I believe the RFM22 is end of Life now (although still available) so if this for a new project you might be better looking at something else.
I would also highly encourage using C and a native avr compiler rather than going down the arduino (based around C++) route for the 328p and also learn about interrupt routines as that can make the code much more efficient.
That sounds like a decent start, I'm afraid I can't help much as I've not worked with PICs and don't do much with ASM - although I'm sure there are forums around dedicated to the sort of thing you're doing.
The UK frequencies are between 458.5 - 459.5 MHz.
I need to add some ASM sections into PICbasic any thing on 'comparing two numbers' and 'if this then that' would be very useful.
C.
Thanks.
0
reply
Report
#18
(Original post by Camerart)
Please let me know about anything regarding the RFM22B as it is the one in the radio modules I have. If you are able to program later modules such as the RFM69 or similar, I'll also be interested, especially if they have an interface so I can use them. (I'm not natural at reading programs other than BASIC) I need to be able to send data and hopefully video (not high quality)
The UK frequencies are between 458.5 - 459.5 MHz.
Please let me know about anything regarding the RFM22B as it is the one in the radio modules I have. If you are able to program later modules such as the RFM69 or similar, I'll also be interested, especially if they have an interface so I can use them. (I'm not natural at reading programs other than BASIC) I need to be able to send data and hopefully video (not high quality)
The UK frequencies are between 458.5 - 459.5 MHz.
The RFM modules I've seen are generally all configured over SPI and you use that same interface to send it data to packetise and transmit. For any sort of video you're going to have to do a fair bit of processing so I'm not sure how feasible it is. It may help to know what sort of thing you're trying to achieve.
0
reply
(Original post by mfaxford)
The RFM22B datasheet suggests it only goes up to 453MHz, It may be configurable for higher but you'll be out of spec for the onboard filtering so there could be a significant impact on how well it works.
The RFM modules I've seen are generally all configured over SPI and you use that same interface to send it data to packetise and transmit. For any sort of video you're going to have to do a fair bit of processing so I'm not sure how feasible it is. It may help to know what sort of thing you're trying to achieve.
The RFM22B datasheet suggests it only goes up to 453MHz, It may be configurable for higher but you'll be out of spec for the onboard filtering so there could be a significant impact on how well it works.
The RFM modules I've seen are generally all configured over SPI and you use that same interface to send it data to packetise and transmit. For any sort of video you're going to have to do a fair bit of processing so I'm not sure how feasible it is. It may help to know what sort of thing you're trying to achieve.
In an effort to lower the frequency of models for use in wooded areas, where higher frequencies get lost. I need different transmitter/receiver pairs with the lowest frequencies, for controlling the models while also receiving video of a quality for observation. While bearing in mind aerial length. Also frequencies not too close to one another.
So say 35Mhz for control and 459Mhz for data/video would be good.
I've looked at your suggestion of later models and a quick skim of the RFM69 data sheet and it seems a better idea to go with later models, than the RFM22B.
I think it might be better to start another 'Thread'. 'Programming radio modules' Does this sound ok?
C.
0
reply
Report
#20
(Original post by Camerart)
I need to add some ASM sections into PICbasic any thing on 'comparing two numbers' and 'if this then that' would be very useful.
C.
Thanks.
I need to add some ASM sections into PICbasic any thing on 'comparing two numbers' and 'if this then that' would be very useful.
C.
Thanks.
Comparison in ASM is done via instructions that set flags e.g. in x86/x64 there is a CMP instruction that is exactly the same as the subtract (SUB) instruction except it doesn't modify the destination operand...
mov r1, 14
mov r2, 14
mov r3, 14
sub r1, r2 ;sets r1 to 0 and thus sets the ZERO flag
jz label ;jump to label if ZERO flag is set
;random code here
label:
cmp r2, r3 ;sets the ZERO flag but r2 is still 14 as CMP differs from sub and doesn't modify the destination
jz label ;create infinite loop
0
reply
X
Quick Reply
Back
to top
to top