Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Assembler vs Basic language

Status
Not open for further replies.
M

mikesmixes

Guest
Hey guys, I want to use an LCD screen for displaying Speed, Temp, Revs, doors open and other stuff for the car. I see there is a topic on a motor bike revs and speed lcd display.

here is the big question, which is better, Assembler or basic language.
I have studied MPlab and know assembler, but after doing work with PicBasic i find that, basic is easier and quicker for LCD o/p and for reading i/p's. Theres is alot of code needed for assembler just to right to an LCD or even count inputs and log them.

Any thoughts on this. Also would i need interrupts for the above mensioned project. I am using the PIC16F877.

Thanks.
 
:?

I can see I am treading a fine line here to a severe flaming..... but.....

Assembler is better and everone knows it!!! :wink: LOL

Seriously tho, you are probably correct in that basic is probably quicker to develop, but by it's very design is more retrictive, I always code is asm, it suits my needs, I have over 10years code and routines and painfull, hard-learnt lessons to fall back on....

Final thought, if you want to program straight forward stuff, you don't care how it works, as long as it does, and you don't dream-pic-code, then basic is probably for you. If you want to master pics, then I think asm is the only choice.
 
Ill agree with Matt here.

#Advantages of basic
easy of coding
quick development times
less learning curve

#advantages of assemble
smaller programs
greater programming flexability
leads to greater understanding of the MCs abilities


I started out using basic and for the types of projects Ive done/doing its worked well for me. I do want to learn more about assemble for quicker coding and smaller programs though. Having a knowledge of both wouldn't be a bad thing.
 
Yeah, I agree that if it works, use it.
I have just started out using PicBasic only because i am doing projects involving LCD's.

I also agree that Assembler is moe "challenging" and it help you understand what you are writing and how the project works.

I am just having trouble with interrupts for assembler, anyone got tuts for those using assembler.

I use MPLAB from microchip. (only cos in my course we used it so i been tought it.)

Although im glad to see that many will go for assembler.

Does anyone have any code for LCD (tuts) stuff using assembler????

TRhanks.
 
The different languages are good for different things. Personaly I hate assembler and avoid it like the plague :wink: . Higher level languages (like basic and C) let you ignore a lot of anoying things about assembler (I really don't want to have to manage the stack manually) and focus on your application. However you do lose some code density and speed with high level languages - but thats ok for most applications - and you can speed up your development.

Knowing assembly is important though. you can write much better C or basic if you know the assembly that it will get translated into. And sometimes you need to step through assembly code to catch some bugs that don't show up in your C code. And there are times that you need to do things that require precice timing or need to be so compact and fast that assembly is the only way.

Assembler is more flexible but the disadvantage to that is that its easy to get yourself into trouble. High level languages force you to follows some rules that keep you from making mistakes. If you are good with C though you can do almost everything you can do in assembly.

As with everything your tools depend on your problem If you need to cram something into 1K of Flash then you probably need to use assembly. Writing a 65K progam in assembly would be a bear though.

Brent
 
I agree with you all. However, I prefer asm. The fact that you can write complex program in asm if you prepared for it.

That is, you only have to copy and paste as writing asm if you did it before. And all who want to write long code need to understand and use MC frequently, that is you had yourself a large "library". For examples, SSP module, Initialize module, ISR module... It's like you write a C code, but you can easily organize your program with your own code. And you can optimize your code if you want.

There are many module writen such as: div16bit, add32bit, .... don't worry, we all can search, copy and paste. For example, Nigel's tutorial is very good for beginners. They can copie and paste.

As writing in C or other high level languages, you also can generate it into asm then optimize your program in asm. There is no problems. Try with CCS C.

However, as writing under asm, I see many "clever key" and I prefer writing in asm.
 
without bothering to read what the others have written cause i'm short on time,

Go with assembler. As you want to develop more and more complex programs, assembler is the best way to go. It is the most time accurate compared to any other code a compiler creates, thus assembly gives you more control over timing and precisision.

When people say that it is quite challenging to learn assembly, let me put it this way, assembly is easy to learn, but Basic is even more easier to learn. Their both easy.

And it is free and more supported in these forums.

Edit: head over to www.winpicprog.co.uk for some great tutorials that teach assembly for *free*
 
:roll:

You are right, asm is easy to learn, but difficult to master, also I have found (it may just be me being thick!) but you have to KEEP using asm to stay on top of it.....

For example, I have just been porting some code over from an 877 to a 18f452, it should have been easy right???? NO, the data sheet asures you that it is backward compatible with the 877 (as they always do!) BUT all instructions are NOT supported, there is 1 instr that is not on the 452....

In basic this probably (should be) dealt with by the compiler, but in asm the compiler just thinks this unsuported instr is another lable (label if u r from the usa!), hence the code throws a wobbler and strange numbers start coming out of the serial port (in my particular case).

This is were the agony of choosing asm over basic or other high level languages comes in, you have to single step thro each instruction to try and find the bug, this can (and almost always does) take hours, why? Because you read the instruction and you asm "brain" knows this is ok, after all you have been using this instr for over 10years, EVERYONE KNOWS that it is correct........... it took me the best part of 4hours to find!! :wink:

But I still love coding in it, it's a real buzz when you get it to work. I have written some bad delphi for the pc, and never come close to that feeling of achievment.

Oh well enough ranting......... btw, the mystery instr???? well maybe I should let you all experience the pleasure of finding it yourselves? what do you reckon??? :)
 
For me Assembly is easy to use for microcontroller i never looked or tried yet in Basic...i realized that why should not try it. :D
 
bmcculla said:
As with everything your tools depend on your problem If you need to cram something into 1K of Flash then you probably need to use assembly. Writing a 65K progam in assembly would be a bear though.

I think this comes closest to the thruth. If you're programming on a 1K chip then even the best compiler won't allow you to do much more then few simple things. The code a compiler generates will simply fill 1K in no time.

But indeed, imagine a project with a topline 68pin 18F chip with 65K of ROM. You can imagine this would be a project far more complicated then the typical 'read a keypad and drive a lcd' project. (Or else you used a overkill µC :lol: ). Now writing a program for such a big project in assembler will take ages and, when done, the code will be so large (over 100000 lines?) that it will just be one big mess. In this case a high level compiler will be a much better solution. You can still write critical parts in assembly and call them from the C program...

One more thing, I prefer C over basic. simply for the fact that C exists on all platforms wich makes porting something a hell of a lot easyer
 
Went away for the weekend.

I think for my application of an LCD screen showing speed, rpm and temperature, i will go with basic. I am just learning it now.

I have used assembler for many other programs. Although i can see you guys have had MANY more years of PIC's then me. Porting....????

Anyone got some nice code examples using the PIC16F877 with a/d conversion, and one more thing, when writing to the LCD whats the min delay you have to do after writing data to the screen?
 
mikesmixes said:
Anyone got some nice code examples using the PIC16F877 with a/d conversion, and one more thing, when writing to the LCD whats the min delay you have to do after writing data to the screen?

My tutorials include A2D conversion and LCD use, including using the busy flag which makes it as fast as possible.
 
thanks for the websites.
I shall have a look and then let you know if i got any questions.

cheers
 
:wink:

Sorry mike, sometimes the acronyms just flow.......

Porting = converting code from 1 micro to another, in my case an 16f877 to an 18f452, microchip (and I imagine other manufactures) will ASSURE u that this is as easy as falling of a log, so simple in fact that they often only devot 1 or 2 small paragraphs to it....... as with most things in life, don't belive the hype!!

I have backed myself into corners before with this, 16c73->16c73b, what could be easier right?? Well the 16c73b doens't boot as cleanly as the 73, see the errata!! 16c73b -> 16f73...... 16f73 is more suseptable to mains spikes.... not 1 comment on any data sheet about that 1!

Just a warning, when porting to a new chip, always, always read the errata data sheets, they are a bit of a "oh by the way, when you can't get it to work, this is probably what the problem is!" :wink:
 
ahhh, thanks for the explanation! cleared thigs up abit. I dont do that much programming that i need to port. lol.

do u program in both assembler and basic?
I been looking at the lcd screen tutorial, in basic, everyone does "pause 100" after each "lcdout" command. i tried to put 3 text strings on a screen but the forst one was fine, the second flashed slowly and the 3rf flashed faster. I think this is due to the pauseing.......any solutions?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top