PIC Assembler.

"Jonathan Kirwan" <jkirwan@easystreet.com> wrote in message
news:s3n4i39m1r9l7ouq5buog5tsbrhm42js97@4ax.com...
On Fri, 26 Oct 2007 20:34:27 GMT, "ian field" <dai.ode@ntlworld.com
wrote:

If I'm after ground shaking simplicity in an editor, how about the older
DOS
edit in a command line window, which is very similar to the editor in the
user interface of an old Quickbasic compiler I might still have somewhere.

Yes, in fact it is built from the same code base. (At some point in
time, I found and read a copy on the web of all the source to these
things including QBASIC.)

Then there's the old Debug program, which IIRC was for entering assy' into
the original PCs - pity I can't remember the commands & syntax!

Yes. I have a web page on the subject. Not a good one, but it would
be a start of some kind:

http://www.infinitefactors.org/jonk/x86lrn.html

Jon
Thanks.
 
On Oct 27, 1:10 am, "ian field" <dai....@ntlworld.com> wrote:
"Marra" <cresswellave...@talktalk.net> wrote in message

news:1193360493.191387.182070@k79g2000hse.googlegroups.com...







On 24 Oct, 00:24, "john jardine" <john.jard...@idnet.co.uk> wrote:
"ian field" <dai....@ntlworld.com> wrote in message

news:kcpTi.15009$qv1.3845@newsfe2-gui.ntli.net...

"Richard Seriani" <richard_s...@cox.net> wrote in message
news:vPjTi.11299$BT5.19@newsfe18.lga...

"ian field" <dai....@ntlworld.com> wrote in message
news:V_2Ti.20084$0z6.19665@newsfe7-win.ntli.net...
Does anyone have a link to any tutorials for PIC assembly?

Over the past few months I've been trying many permutations of
Google
search string, but most of the tutorials I've found assume previous
experience at writing assy for microprocessors.

Another problem is most of what I've found is HTML which is untidy
to
save for later study and many pages lose their image files after
being
saved to disk (anyone know why that happens?). Any help appreciated.

TIA.
Ian,

Try these. Some are better than others and some have mistakes - but,
you'll be able to spot those within a short time.

http://www.mikroe.com/en/books/picbook/picbook.htm
http://www.winpicprog.co.uk/pic_tutorial.htm
http://www.mstracey.btinternet.co.uk/pictutorial/picmain.htm

Saving these to your hard drive can be done with a right-click and
save
as. It creates two files, one is the html document and the other is a
file
folder with the graphics. At least, it does on my Windoz machine.

In a later post, someone also recommended the PIC Elmer 160 tutorial.
That
is a good one and each of the lessons downloads as a PDF.

snip

Many thanks, the first link is *very* interesting - I may already have
the
other 2 saved. The Elmer 160 starts off simple enough but the code
examples
quickly get heavy going, I need to go over a lot of simpler code over
and
over until I get the hang of it.

It's absolutely essential that you get to write the few lines needed to
flash an LED. If you can get there and can see why you've caused the LED
to
flash then -ALL- other PIC programming is downhill.
The "mstracey" link that Richard supplied, will do this, (upto "tutorial
#5") but more importantly, the how's and why's of the individual
instructions are described nicely.

Try and ignore anything written by Microchip.
Sadly though, you may have to make use of Microchip's, bloated, inane
piece
of s***, known as "MPLAB", but remember, the hoops it forces you to jump
through, are nothing to do with actual PIC programming but more reflect
the
mindset of Microchip's C pogrammers.- Hide quoted text -

- Show quoted text -

I have had no problems with MPLAB and it doies provide a simulator.

I have had trouble with the Microchip FFT that the multiply routine
had a bug.
I fixed it and sent it back to them.

To repeat an earlier question - would I find an earlier version of MPLAB
easier to get started, or would I seriously disadvantage myself by denying
myself of the advanced features of newer versions?

It seems a lot of people prefer to use a stand alone text editor, I'd
welcome any advice as to which choice to make.
Use the latest version of MPLAB, you'd be a fool not too.

MPLAB comes into its own when you have all the other tools tied into
it, like the C compiler and the ICD2 programmer/debugger. Then you
only need one package to edit, compile, program, debug, and simulate.
If you don't have an MPLAB compatible programmer, and/or a compiler
that can be "integrated" into MPLAB, then you don't need to use MPLAB
at all.

There is nothing wrong with the MPLAB text editor. It supports the all-
important colour syntax highlighting, and has most of the usual
features of a good editor.

Dave.
 
Marra wrote:
It is quite remarkable what you can make a PIC do if you put in some
effort.
It sure is. :)

I did a dual cooker for a large manufacturer and it did multi tasking
between the 2 ovens and a scrolling VF display.
The busiest I kept a PIC was with a caller-id project using a software
modem. It re-times the recovered data bits and clocks them out one pin and
back into another pin. That pin feeds a serial bit-bang receive routine
that stuffs the received bytes into a circular queue. All interrupt driven
of course. The main level code takes bytes out of the queue and displays
them on a Hitachi based LCD. There were very few exta cycles available when
it is receiving data. Did this on a 16F84 at 4MHz.
 
On Fri, 26 Oct 2007 15:26:24 -0700, "David L. Jones"
<altzone@gmail.com> wrote:

snip
Use the latest version of MPLAB, you'd be a fool not too.
Unless you fit under one of the exceptions I mentioned elsewhere.

There are times when an older version is a better or only choice.

Jon
 
On Fri, 26 Oct 2007 15:10:59 GMT, "ian field" <dai.ode@ntlworld.com>
wrote:

To repeat an earlier question - would I find an earlier version of MPLAB
easier to get started, or would I seriously disadvantage myself by denying
myself of the advanced features of newer versions?

It seems a lot of people prefer to use a stand alone text editor, I'd
welcome any advice as to which choice to make.
While you're in the learning process, use MPLAB exclusively. And, for
that matter, the latest version.

If you screw around with oddball tools and toolchains, you're going to
spin yourself in circles, shooting at multiple moving targets, and
you'll never get anything done.

Anything else at this stage of your learning is just absolutely crazy.

Tom
 
ian field wrote:

If I'm after ground shaking simplicity in an editor, how about the older DOS
edit in a command line window, which is very similar to the editor in the
user interface of an old Quickbasic compiler I might still have somewhere.
I have used 'edit' but notepad is far nicer to use.

Graham
 
"Tom2000" <abuse@earthlink.net> wrote in message
news:9oe6i3tsp6u12c7a8v809v8kvgg26aqjhg@4ax.com...
On Fri, 26 Oct 2007 15:10:59 GMT, "ian field" <dai.ode@ntlworld.com
wrote:


To repeat an earlier question - would I find an earlier version of MPLAB
easier to get started, or would I seriously disadvantage myself by denying
myself of the advanced features of newer versions?

It seems a lot of people prefer to use a stand alone text editor, I'd
welcome any advice as to which choice to make.


While you're in the learning process, use MPLAB exclusively. And, for
that matter, the latest version.

If you screw around with oddball tools and toolchains, you're going to
spin yourself in circles, shooting at multiple moving targets, and
you'll never get anything done.

Anything else at this stage of your learning is just absolutely crazy.

Tom
Thanks, is there a C compiler that integrates into that?
 
On Sat, 27 Oct 2007 14:39:36 GMT, "ian field" <dai.ode@ntlworld.com>
wrote:

"Tom2000" <abuse@earthlink.net> wrote in message
news:9oe6i3tsp6u12c7a8v809v8kvgg26aqjhg@4ax.com...
On Fri, 26 Oct 2007 15:10:59 GMT, "ian field" <dai.ode@ntlworld.com
wrote:


To repeat an earlier question - would I find an earlier version of MPLAB
easier to get started, or would I seriously disadvantage myself by denying
myself of the advanced features of newer versions?

It seems a lot of people prefer to use a stand alone text editor, I'd
welcome any advice as to which choice to make.


While you're in the learning process, use MPLAB exclusively. And, for
that matter, the latest version.

If you screw around with oddball tools and toolchains, you're going to
spin yourself in circles, shooting at multiple moving targets, and
you'll never get anything done.

Anything else at this stage of your learning is just absolutely crazy.

Tom



Thanks, is there a C compiler that integrates into that?

For the 18F series, the Microchip C18 compiler is pretty nice. The
student edition is free.

(If you'd like to try the 18F series, you might look at the 18F1320
as your first chip. Get a sample from Microchip. It's a good
all-around processor.)

And most, if not all, popular C compilers integrate nicely into the
MPLAB IDE. I use the CCS PCH compiler for my 18F work, and the
integration is seamless.

Tom
 
ian field wrote:
"Tom2000" <abuse@earthlink.net> wrote in message
news:9oe6i3tsp6u12c7a8v809v8kvgg26aqjhg@4ax.com...
On Fri, 26 Oct 2007 15:10:59 GMT, "ian field" <dai.ode@ntlworld.com
wrote:


To repeat an earlier question - would I find an earlier version of
MPLAB easier to get started, or would I seriously disadvantage
myself by denying myself of the advanced features of newer versions?

It seems a lot of people prefer to use a stand alone text editor,
I'd welcome any advice as to which choice to make.


While you're in the learning process, use MPLAB exclusively. And,
for that matter, the latest version.

If you screw around with oddball tools and toolchains, you're going
to spin yourself in circles, shooting at multiple moving targets, and
you'll never get anything done.

Anything else at this stage of your learning is just absolutely
crazy. Tom



Thanks, is there a C compiler that integrates into that?
If you really want to use C on a PIC, then I again recommend the 18F parts.
Microchip makes a C compiler available on a 90-day (IIRC) trial basis. At
the end of 90 days, you uninstall and reinstall. Microchip is fully aware
that allot of people are doing this, they don't seem to mind.

C on the 16F's is a crap shoot since the PIC wasn't designed to be used as a
C platform. There are a couple of decent compilers available but they are
not really cheap. My advice is to don't bother wasting your time with SDCC
unless you like checking the output of the compiler as part of the debugging
process.

:)
 
On Sat, 27 Oct 2007 10:01:44 -0500, "Anthony Fremont"
<nobody@noplace.net> wrote:

ian field wrote:
"Tom2000" <abuse@earthlink.net> wrote in message
news:9oe6i3tsp6u12c7a8v809v8kvgg26aqjhg@4ax.com...
On Fri, 26 Oct 2007 15:10:59 GMT, "ian field" <dai.ode@ntlworld.com
wrote:


To repeat an earlier question - would I find an earlier version of
MPLAB easier to get started, or would I seriously disadvantage
myself by denying myself of the advanced features of newer versions?

It seems a lot of people prefer to use a stand alone text editor,
I'd welcome any advice as to which choice to make.


While you're in the learning process, use MPLAB exclusively. And,
for that matter, the latest version.

If you screw around with oddball tools and toolchains, you're going
to spin yourself in circles, shooting at multiple moving targets, and
you'll never get anything done.

Anything else at this stage of your learning is just absolutely
crazy. Tom



Thanks, is there a C compiler that integrates into that?

If you really want to use C on a PIC, then I again recommend the 18F parts.
Microchip makes a C compiler available on a 90-day (IIRC) trial basis. At
the end of 90 days, you uninstall and reinstall. Microchip is fully aware
that allot of people are doing this, they don't seem to mind.
This is something I didn't know about -- the ease of uninstalling and
then reinstalling the C18 compiler to get more time. It's just enough
of a hassle, perhaps, to encourage larger businesses to pay their
bills. And enough of a reminder for smaller ones to consider the idea
seriously and periodically -- eventually, the timing of the reminder
will find a more generous mind and the check will be forthcoming. I
can see some logic in the approach. For hobbyists, it would be no
necessary barrier but Microchip probably doesn't want to materially
inhibit widespread hobbyist use of their parts.

C on the 16F's is a crap shoot since the PIC wasn't designed to be used as a
C platform.
I've looked over the generated assembly code and it isn't all that
fantastic, but it's not all that bad, either. Livable. But I
wouldn't call it a crap shoot. It generally works, as long as you
have enough flash available.

There are a couple of decent compilers available but they are
not really cheap.
There is that.

My advice is to don't bother wasting your time with SDCC
unless you like checking the output of the compiler as part of the debugging
process.
Hehe. I haven't ever tried it, but the web site says that "work is in
progress" on the 16F, so I see your point here. I note that SDCC
targets the 8051 -- which makes me wonder if it supports analyzing
call trees with the idea of placing local stack frame variables into
static memory (when recursion isn't required.) On the 8051, this is a
big help most of the time and on other processors it _may_ be useful,
as well.

Jon
 
Jonathan Kirwan wrote:
On Sat, 27 Oct 2007 10:01:44 -0500, "Anthony Fremont"
nobody@noplace.net> wrote:

ian field wrote:
"Tom2000" <abuse@earthlink.net> wrote in message
news:9oe6i3tsp6u12c7a8v809v8kvgg26aqjhg@4ax.com...
On Fri, 26 Oct 2007 15:10:59 GMT, "ian field"
dai.ode@ntlworld.com> wrote:


To repeat an earlier question - would I find an earlier version of
MPLAB easier to get started, or would I seriously disadvantage
myself by denying myself of the advanced features of newer
versions?

It seems a lot of people prefer to use a stand alone text editor,
I'd welcome any advice as to which choice to make.


While you're in the learning process, use MPLAB exclusively. And,
for that matter, the latest version.

If you screw around with oddball tools and toolchains, you're going
to spin yourself in circles, shooting at multiple moving targets,
and you'll never get anything done.

Anything else at this stage of your learning is just absolutely
crazy. Tom



Thanks, is there a C compiler that integrates into that?

If you really want to use C on a PIC, then I again recommend the 18F
parts. Microchip makes a C compiler available on a 90-day (IIRC)
trial basis. At the end of 90 days, you uninstall and reinstall.
Microchip is fully aware that allot of people are doing this, they
don't seem to mind.

This is something I didn't know about -- the ease of uninstalling and
then reinstalling the C18 compiler to get more time. It's just enough
of a hassle, perhaps, to encourage larger businesses to pay their
bills. And enough of a reminder for smaller ones to consider the idea
seriously and periodically -- eventually, the timing of the reminder
will find a more generous mind and the check will be forthcoming. I
can see some logic in the approach. For hobbyists, it would be no
necessary barrier but Microchip probably doesn't want to materially
inhibit widespread hobbyist use of their parts.
Exactly. :) Microsoft uses this technique by allowing their software to
be copied (til now). They also make sure the youngsters (students) have
cheap and easy access to their software as well. Like crack, they give it
away....at first. ;-)

C on the 16F's is a crap shoot since the PIC wasn't designed to be
used as a C platform.

I've looked over the generated assembly code and it isn't all that
fantastic, but it's not all that bad, either. Livable. But I
wouldn't call it a crap shoot. It generally works, as long as you
have enough flash available.
Yeah, I should have used better words than that. The pay compilers are
decent, but outside of that ......

There are a couple of decent compilers available but they are
not really cheap.

There is that.

My advice is to don't bother wasting your time with SDCC
unless you like checking the output of the compiler as part of the
debugging process.

Hehe. I haven't ever tried it, but the web site says that "work is in
progress" on the 16F, so I see your point here. I note that SDCC
targets the 8051 -- which makes me wonder if it supports analyzing
call trees with the idea of placing local stack frame variables into
static memory (when recursion isn't required.) On the 8051, this is a
big help most of the time and on other processors it _may_ be useful,
as well.
See, that's just the thing. I've never used SDCC on a PIC, just on the
8052. Given that, I can only imagine the code it generates for PICs
especially with their "in progress" disclaimer.

I do like this ARM stuff I've been playing with lately. C or assembler,
it's a beautiful place to tinker. :)
 
"Michael A. Terrell" <mike.terrell@earthlink.net> wrote in message
news:47225643.A3EB84BE@earthlink.net...
Eeyore wrote:

Had a scrolling VFD in one of my 8051 designs as it happens.


A good programmer could have fixed that problem.
At the moment I can't even get my head round the PIC ORG instruction!
 
On Mon, 29 Oct 2007 21:05:08 GMT, "ian field" <dai.ode@ntlworld.com>
wrote:

"Michael A. Terrell" <mike.terrell@earthlink.net> wrote in message
news:47225643.A3EB84BE@earthlink.net...
Eeyore wrote:

Had a scrolling VFD in one of my 8051 designs as it happens.


A good programmer could have fixed that problem.

At the moment I can't even get my head round the PIC ORG instruction!
That is often explained poorly from the point of view of assembly.
Best way to understand it is to "think like a linker" not like an
assembler.

Imagine the simplest linker case. It starts out with a blank sheet of
paper, with nothing at all written down on it. The assembler is
allowed to write notes into the .OBJ files and the linker has to read
these notes and modify this initially blank sheet. The assembler is
allowed to do the following:

(1) provide a string of bytes
(2) specify an address

And let's add this assumption: both the assembler and the linker
share the idea that upon start they each will assume that the address
begins as zero, if not otherwise given.

So the assembler converts sequences of instructions into strings of
bytes and writes these as type (1) strings into the OBJ file. Also,
if the assembler "sees" an ORG statement, it writes out any prior
accumulation of a string of bytes and finishes that record and then
writes out a new type (2) record providing that address given in the
ORG statement. Then the assembler goes back to its default of just
writing out strings of bytes.

The linker on the other hand, starts out with two things -- that blank
sheet and an initial assumed address of zero. (In other words, a
'pointer' that points to the top of the blank sheet.) It then reads
up the strings of bytes from the OBJ and places them down on the blank
sheet, one by one, just appending one to the other as it reads. In
the process of that, it also moves the address along down the page as
it goes, so that the internal address always points to the next
available place on the sheet to write. If the linker encounters an
ORG, or type (2) record, then it simply moves the address pointer as
indicated and then continues adding bytes from the strings, starting
then at that point.

ORG just moves the linker's address pointer for the current memory
page it is working on.

In the end, the final memory page may be somewhat disconnected --
there may be blank areas where nothing was written. How it handles
generating the final executable file in those cases will depend on
what makes sense in that context. But that's about all that goes on,
earlier.

Now, most linkers permit multiple pages. These are called "segments"
but basically these are named pages. (Often, there is permitted one
"unnamed" page, as well.) Each of these segments has its own separate
pointer about where the next string is to be written on that page (the
"current location on that page.") The linker keeps track of what the
current page is and what the current location on that page is, also.
If the linker sees strings of bytes in the OBJ, it just appends them
at the current location on the current page and moves the current
location, accordingly.

The assembler or compiler is permitted to jump tracks, so to speak,
and instruct the assembler to move to a different page or segment, at
any time. Additional strings are then written to that page, instead
of an earlier one. So the expanded list of records would be:

(1) provide a string of bytes
(2) specify an address
(3) specify a named or unnamed page

There can also be so-called "absolute pages" and "relative pages." By
this, the assembler or compiler can have two types of pages -- one
which is forced to a specific location in memory and others where the
linker is permitted some freedom about moving them around when it
needs to composite the final executable. Those which must go at
specific locations are placed first, usually. Then those which can be
moved around are inserted or added where ever they can fit. The order
in which this takes place can vary -- for example, it could be sorted
by name and placed in that order.

Also, it is possible to support segments which overlap -- by this,
another type of page is permitted which can be grouped in such a way
that allocations overlap (the pages are laid down on top of each other
like transparencies might be in order to composite a final image.)
These are so-called "common segments." FORTRAN uses these types, for
example, and so does some BASIC implementations.

Does that help?

Jon
 
"Jonathan Kirwan" <jkirwan@easystreet.com> wrote in message
news:84jci31svako135nfm2uqj0labt0hnu046@4ax.com...
On Mon, 29 Oct 2007 21:05:08 GMT, "ian field" <dai.ode@ntlworld.com
wrote:

"Michael A. Terrell" <mike.terrell@earthlink.net> wrote in message
news:47225643.A3EB84BE@earthlink.net...
Eeyore wrote:

Had a scrolling VFD in one of my 8051 designs as it happens.


A good programmer could have fixed that problem.

At the moment I can't even get my head round the PIC ORG instruction!

That is often explained poorly from the point of view of assembly.
Best way to understand it is to "think like a linker" not like an
assembler.

Imagine the simplest linker case. It starts out with a blank sheet of
paper, with nothing at all written down on it. The assembler is
allowed to write notes into the .OBJ files and the linker has to read
these notes and modify this initially blank sheet. The assembler is
allowed to do the following:

(1) provide a string of bytes
(2) specify an address

And let's add this assumption: both the assembler and the linker
share the idea that upon start they each will assume that the address
begins as zero, if not otherwise given.

So the assembler converts sequences of instructions into strings of
bytes and writes these as type (1) strings into the OBJ file. Also,
if the assembler "sees" an ORG statement, it writes out any prior
accumulation of a string of bytes and finishes that record and then
writes out a new type (2) record providing that address given in the
ORG statement. Then the assembler goes back to its default of just
writing out strings of bytes.

The linker on the other hand, starts out with two things -- that blank
sheet and an initial assumed address of zero. (In other words, a
'pointer' that points to the top of the blank sheet.) It then reads
up the strings of bytes from the OBJ and places them down on the blank
sheet, one by one, just appending one to the other as it reads. In
the process of that, it also moves the address along down the page as
it goes, so that the internal address always points to the next
available place on the sheet to write. If the linker encounters an
ORG, or type (2) record, then it simply moves the address pointer as
indicated and then continues adding bytes from the strings, starting
then at that point.

ORG just moves the linker's address pointer for the current memory
page it is working on.

In the end, the final memory page may be somewhat disconnected --
there may be blank areas where nothing was written. How it handles
generating the final executable file in those cases will depend on
what makes sense in that context. But that's about all that goes on,
earlier.

Now, most linkers permit multiple pages. These are called "segments"
but basically these are named pages. (Often, there is permitted one
"unnamed" page, as well.) Each of these segments has its own separate
pointer about where the next string is to be written on that page (the
"current location on that page.") The linker keeps track of what the
current page is and what the current location on that page is, also.
If the linker sees strings of bytes in the OBJ, it just appends them
at the current location on the current page and moves the current
location, accordingly.

The assembler or compiler is permitted to jump tracks, so to speak,
and instruct the assembler to move to a different page or segment, at
any time. Additional strings are then written to that page, instead
of an earlier one. So the expanded list of records would be:

(1) provide a string of bytes
(2) specify an address
(3) specify a named or unnamed page

There can also be so-called "absolute pages" and "relative pages." By
this, the assembler or compiler can have two types of pages -- one
which is forced to a specific location in memory and others where the
linker is permitted some freedom about moving them around when it
needs to composite the final executable. Those which must go at
specific locations are placed first, usually. Then those which can be
moved around are inserted or added where ever they can fit. The order
in which this takes place can vary -- for example, it could be sorted
by name and placed in that order.

Also, it is possible to support segments which overlap -- by this,
another type of page is permitted which can be grouped in such a way
that allocations overlap (the pages are laid down on top of each other
like transparencies might be in order to composite a final image.)
These are so-called "common segments." FORTRAN uses these types, for
example, and so does some BASIC implementations.

Does that help?

Jon
Thanks - I've saved your reply so I can refer back to it later when I've
learned more about all the stuff that has to be written in the ASM file
before the program coding even starts. The book I've just started (PIC in
practice) skips over all this stuff until chapter 6, there is a reference to
a file called "Header.ASM" which is apparently to be included in all the
projects in the book but there is next to no explanation of the first group
of lines that set things up before the coding is entered.
 

Welcome to EDABoard.com

Sponsor

Back
Top