Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

USB/Bluetooth/WiFi Stacks For Assembly Programming

Status
Not open for further replies.

Hooseria

Newbie level 5
Joined
Sep 15, 2010
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,357
Hi
A while back (2010) I took good advice From Betwixt on learning assembly. I am currently quite proficient at it.

My problem now resides in comms it seems that the microchip guys are going the C route, all of microchip solutions code are in C. I need to proceed with WiFi addition to my project. Is there any chance of me sticking to assembly for embedded WiFi. I have even looked at TI's MSP430 with their CC3000's inclusive TCP/IP stack. So the question is, is there a microchip WiFi module with inclusive stack, that I can use with my assembly programming, and avoid having to call on C routines from Assembly, which I was told is not possible.

What solutions are there for USB/Bluetooth/WiFi, for assembly programming even if I have to move away from microchip.
 

I don't understand the exact problem. If you want to write pure assembly language embedded software, what does hinder you?You can take advantage from existing library sources in C-language by translating it to assembly. You can also call C functions from assembly, but it's a bit more involved.

Personally I doubt the the reasonability of your approach, particularly if you go for complex pieces of software like TCP/IP stacks. You should realize that high level languages allow coding at a more abstracted level, freeing you from trivial operations.

Learning assembly language is a different thing, it's required for understanding compiler operation details and debugging. Assembly code constructs are often required to access special processor features that are not yet or not fully supported by compilers.
 
I agree with the points made by FvM.

There is nothing preventing you from configuring the registers of a USB/Bluetooth/WiFi module, they typically use the standard serial interfaces available on most microcontrollers.

Writing a protocol stack with assembly is, although tedious, certainly doable.

And as FvM pointed out, most assemblers support calls to object code resulting from compiled C source code, therefore a protocol stack written in C source code can most likely be incorporated into assembler code.

So get to work. :lol:

BigDog
 

Hi and thanks for the reply.

I am currently trying to read C18 with the aim of slowly porting to assembly. I was hoping to get a hint of whether it was a wasted attempt.
With microcontrollers, I only know assembly, as a hobbyist it was my chosen language, Point of departure to get started. I need to take my very successful assembly project into the comms arena ( I chose WiFi). I have read the exhausting microchip TCP/IP stack help "book". However I feel more comfortable in assembly.

Also my googling led me to believe you cannot call the stack from an assembly program. My "intelligent generator project which runs on assembly" (to which I want to add WiFi/ bluetooth/ Ethernet/ or USB, will apparently only qualify to the task at hand if it was in C18.

Listen, it would be a remarkable learning curve and a source of great elation if I convert just one stage of the stack to assembly but this going to take a lot of time.

Can you advise or show me an example a very simple one, of calling C18 routines from assembly. I am currently using MPLABX.

If you suggest I go the conversion route, my most recent Google led me to further research something called an .LST file. Just before replying here, I quickly ran a downloaded c18 program but could not find this elusive .LST file.

Thanks again

- - - Updated - - -

Thanks BigDog, FvM

Taking advice from the qualified got me this far.

Point taken, ignore last part of my reply above.

Any examples on calling on the stack from assembly?
 

I am currently trying to read C18 with the aim of slowly porting to assembly. I was hoping to get a hint of whether it was a wasted attempt.
With microcontrollers, I only know assembly, as a hobbyist it was my chosen language, Point of departure to get started. I need to take my very successful assembly project into the comms arena ( I chose WiFi). I have read the exhausting microchip TCP/IP stack help "book". However I feel more comfortable in assembly.

There are a number of WiFi/Ethernet/Bluetooth modules which incorporate an embedded protocol stack into their designs, which greatly simplifies the configuration and utilization requirements from the coding prospective.

A few of the manufacturers offering modules with embedded protocol stacks are Lantronix, Moxa, WIZnet, BlueGiga, Roving Networks, etc.


Also my googling led me to believe you cannot call the stack from an assembly program. My "intelligent generator project which runs on assembly" (to which I want to add WiFi/ bluetooth/ Ethernet/ or USB, will apparently only qualify to the task at hand if it was in C18.

Listen, it would be a remarkable learning curve and a source of great elation if I convert just one stage of the stack to assembly but this going to take a lot of time.

Can you advise or show me an example a very simple one, of calling C18 routines from assembly. I am currently using MPLABX.

Calling C routines from within an assembler first requires the C source code to be compiled, using a C compiler, to an object file which is then linked into the resulting executable.

You would essentially need to create an object level library or archive which can be then called from within the assembler.

And as it is not a technique I would ordinarily undertake some research would be required.


If you suggest I go the conversion route, my most recent Google led me to further research something called an .LST file. Just before replying here, I quickly ran a downloaded c18 program but could not find this elusive .LST file.

Often, the assembler listing file (LST or LIST) is only output when the appropriate compiler options are passed to the compiler or feature enabled in the IDE.

I do not have MPLABX or MPLAB available to me at the moment, however the Microchip forum has several threads concerning the topic including:

How do I view the assembly output of compiled C?

**broken link removed**

BigDog
 

There are two points to be considered when calling C-functions from assembly.

The first point is about the calling conventions (how parameters are transferred to the called functions). It should be described in the compiler's user manual.

The second point involves the runtime prerequisites of the C library. Needless to say that you have to setup a stack, it will be also used in complex assembly programming. But depending on the operation of the functon, it may also call RTL (run time library) functions. PIC18 e.g. does at least 16 bit and larger arithmetics through RTL. So parts of the RTL has to be linked to the application code as well.
 
The second point involves the runtime prerequisites of the C library. Needless to say that you have to setup a stack, it will be also used in complex assembly programming. But depending on the operation of the functon, it may also call RTL (run time library) functions. PIC18 e.g. does at least 16 bit and larger arithmetics through RTL. So parts of the RTL has to be linked to the application code as well.

I fully agree, managing the required software implemented stack and RTL calls would present the largest hurdles.



The attached presentations actually discusses calling MPASM routines from C18 AND calling C18 routines from MPASM.

The compiler presentation also discusses generation of the assembly listing file and the necessary compiler options.

Reference: Section: 3.2.2 Managing the Software Stack, Page:36

And

Reference: Section: 3.2.3 Mixing C and Assembly, Page:36 to 40

Interestingly, in some later versions of the compiler guide, these sections have been omitted.


Also my googling led me to believe you cannot call the stack from an assembly program. My "intelligent generator project which runs on assembly" (to which I want to add WiFi/ bluetooth/ Ethernet/ or USB, will apparently only qualify to the task at hand if it was in C18.
....
....
Can you advise or show me an example a very simple one, of calling C18 routines from assembly. I am currently using MPLABX.

Possibly a more prudent and straightforward approach would be to incorporate your assembly code through assembly routine calls from C code.

In any event, you will need to learn many aspects of the C language, compiler and linker behavior to succeed in this endeavor.

Additional examples of MPASM assembly routine calls can be found within the C18 installation directory under /src directory.

Preserving registers when calling ASM functions from C18


BigDog
 

Attachments

  • 05. Assembler.pdf
    256.7 KB · Views: 296
  • 07. Compiler.pdf
    177.1 KB · Views: 83

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top