What the hell is a bootloader?

Go To Last Post
49 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Peoples,

Since embarking on my quest for microcontroller greatness and enlightenment, I have learnt heaps of information. Ask me last year what a "pull-up" resistor or a "register" is and i'd have been stumped.

I wrote an unofficial doco for a company's board which has prooven to be extramly popular, and so the company has approched me to write the official doco for their next board (not bad for a 15yo!) based on a mitsubishi chip instea dof an ATMEL.

To my question, what's a bootloader? All the datasheets and forums speak of them(it?) but i've never come across a situation where I needed one. Now I have to write a doco, I think it's about time I learn some obscure micro terms.

I think that the world of micros are facinationg, but very hard to get started - everyone just asssumes you know everything. perhaps I'll make this forum into a "dictionary" of terms for newB's.

- Deam :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

a) A bootloader is a person who helps people don their boots.

b) A bootloader is a program on a processor which runs at power up and reads in from mass storage a larger program. The PC BIOS has a bootloader. In microprocessors, the bootloader accepts then runs a new program from an external source and stores this in Flash non-volatile memory, or for testing, in RAM, for some kinds of microprocessors.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

LOL!

So the bootloader is a small program (like DOS) that loads the actual program off external memory?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I dont think "bootloader" qualifies as an obscure term really.. Anyways, it's not much like DOS, and both the bootloader and the application code reside in the flash memory of the microcontroller. Bootloaders are great for alot of reasons: you can send the new code very quickly relative to normal programming, you dont need standalone programming hardware so (for example) an end-user could easily do a firmware update with just a cheap serial cable. The downfall is that your code space is decreased by the bootloader itself, and if you need to change the bootloader, a standalone programmer will be necessary because the bootloader cant write over itself. If you look through the projects sections, you will find at least two bootloaders, and I know there are lots more out there (megaload, lawicel, etc) ... its quite a big subject really.

Edit: and not all bootloaders are created equal IMO. Some of them require you to pull a certain pin to ground or perform a reset to enter and/or leave the bootloader, the best ones however automatically enter and leave the bootloader based on input from the PC. Also you should note that just because you are using a bootloader, you dont have to reserve use of the UART or USART for just the bootloader, you can still use it to communicate "per normal" with other devices.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Grasshopper you will find the term boot enters the electonics lexicon via the term bootstrapping. This in turn comes from the saying to pull your self up by your bootstraps.

Keep it simple it will not bite as hard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
the bootloader cant write over itself

This is not true on the AVRs !
Also the bootloader space can be written.
Maybe, it can be dangerous, if power fails during this action and thus the old bootloader was removed but the newer one was not completely programmed.

But on some 8051 derivates the bootloader was factory programmed in a separate ROM space. Then an API was documented, which allow to call all needed bootloader functions from a flash area to build your own custom bootloader.

The advantage of this method, the manufacturing can be changed and also the programing algorithm, but the API provide always the same functions. So never changing of the custom bootloader was needed.

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What the hell is a bootloader?

Not hell, rather heaven - because it usually resides in the uppermost addresses :D

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Honestly, for each genuine reply there's a smartarsed one to follow it!

Anyway, thanks for the clarification. BTW, sutton, "Grasshopper"? The guy at a company I correspond to reffers me as Grasshopper, from the excellent series Red Dwarf. Is this where you got that from?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dean
Many years ago, (in fact you would have to double the number of your present tender years to have been born when it was on) there was a TV show in which the lead character was called, in a friendly way, Grasshopper by an old sage of a Buddist like monk. The use of the name Grasshopper would be followed by words of ancient lore and wisdom. :)

Keep it simple it will not bite as hard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, another term, "stack". Don't hit me - until now i've been using good 'ol BASCOM Basic and didn't ever have a use for these terms. Now i'm learning Assembler, it's good to know. Can anyone help?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sutton,

Oh. I think i'll stick with Red Dwarf :lol: .

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

While you are defineing terms, what the heck is a "doco" :?:

Laurence Boyd II

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Doco is Australian slang for a document. Australians use this form of abbreviation a lot. The one with whom I used to work used the abbreviation "sarvo" which was apparently short for "this afternoon".

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dean
For stack think of stacking things up ie boxes.

Keep it simple it will not bite as hard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A stack is a data structure where the data that went in last comes out first. You could say that its a LIFO (Last In - First Out) structure. This differs from eg a queue (where things come out in the order they went in, or FIFI for First In - First Out).

The action of putting something (on top) of the stack is called a PUSH, and the action of removing the top item from the stack is called a POP.

The stack data structure can be used for a lot of things, but what You most likely heard of here is its usage as a means to hold return addresses when calling subroutines.

So, without any guarantees for correct syntax, we could have:

main:
   CALL sub_x
   <...stuff here...>

sub_x:
  <...and some stuff here...>
   CALL sub_y
   <...more stuff here...>
   RET

sub_y:
   <...and yet more here...>
   RET

Initially the stack with return addresses is empty. After the call to x, but before the call to y, we will have one item on the stack, namely the address of the instruction following CALL sub_x. (At <...stuff here...>).

When the instruction CALL sub_y is executed the address to the next instruction is PUSHed on the stack, and the call is made (trasfer of control to y. We now have two items on the stack.

Eventually we reach the RET instruction. Where should we return? To the address that is on the top of the stack, so we do that (and POP it as it is "consumed").

Now execution continues with the second part of the x subroutine until we reach it's RET instruction, which returns to the address that now is on top of the stack (which also is POPed).

Now we are back in the main program again. (At <...stuff here...>).

Some AVRs have this stack of return addresses implemented in dedicated hardware, and with a very limited size. IIRC the AT90S1200 has a stack that can hold three adresses, limiting the number of "nested calls" You can do.

Other (most?) AVRs have the stack in RAM, and given nothing else resides there allows for subroutine calls nested several hundred calls deep for the AVRs with large RAM.

(From time to time You'll see people talking about stack initialization here. This is about telling the assembler at what RAM address the bottom of the stack is. On AVRs the stack grows towards smaller RAM addresses so it is common practice to place the bottom of the stack at the end of RAM.)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Wed. Aug 18, 2004 - 07:07 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The action of putting something (on top) of the stack is called a PUSH, and the action of removing the top item from the stack is called a POP.

The teaching device often used is the spring-loaded "stack" of plates at the head of a cafeteria/buffet line. In the simplest sense, you can tell whether the stack is empty (no plates) or you can see the "top of the stack". To add a plate, you "push (down)" the plate and it becomes the new top-of-stack, and then becomes the only item available for mainipulation. When a plate is taken, it is "popped" off the stack, then revealing the new top-of-stack or the empty stack marker.

Who knows--maybe that is where the idea came from in the first place.

Any introductory computer science text should cover stacks (and many other concepts such as queues, linked-lists, a few types of sorts, etc.).

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One should perhaps additionally point out that the MCU core handles the PUSHing/POPing stuff in a truly automated way, i.e. the human programmer doesn't have to provide the RAM address *where* to store something nor issue any dedicated "please store something now" commands: using a call/rcall instruction or entering an 'interrupt service routine' will inspire the MCU to store the adress of the *next* to-be-executed-after-the-call instruction in the stack area.

The ret /reti instruction tells the MCU to retrieve the previously saved address from the stack RAM area and continue code execution with whatever instruction happens to be at that address in the program memory (flash EPROM only as long as we deal with AVRs).

If the programmer uses the push and pop instructions the MCU still takes care of the (stack area) addressing automatically, but *what* (= which data) is stored will be defined by the command - "push r16" will store whatever currently is in r16 to the stack RAM area, "pop r16" will take data from where the "stack pointer" (SPL/SPH register pair on AVRs) points to and load it to r16.

Note: each stack access will cause the MCU core to decrement (a dedicated 'push' instruction, a call or invoking an interrupt) or increment ('pop', ret or reti) the SPL/SPH pointer value (as Johan already pointed out, the stack "grows downwards" from higher to lower memory addresses when you add something to it - imagine a hornet's nest dangling from a tree branch, growing bigger through the summer).

This of course means that if you don't 'evenly balance' the pushing/popping actions the MCU will sooner or later read back data from the wrong position causing lots of funny things to happen.

BTW: "Interrupts" in AVRs are 'automatic calls' induced by certain events (a signal on an input pin, a timer overflow, data arrived in UDR, etc.) as opposed to calls caused by deliberatly issued instructions. The start address of the 'interrupt subroutine' code in program memory is hardwired by design (the "interrupt vector table").

HTH

Andreas

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, everyone. I swear (all the time :lol: ) that going from BASIC to assembler is like learning micros all over again!

Anyway, to answer an earlier question, my "doco" is short for "documentation", although it's common slang for document - as mentioned. I wrote an unofficial documentation for a company's AVR based board (see www.en-tech.i8.com - link halfway down home page) as they didn't provide any. It's now very popular and over 16,000 words (39+ pages), so the New South Wales comapny that makes it is making me write the official doco for their new board (which only runs on assembler). I get to keep all the equipment free as payment (not bad for a 15yo!) but I confess, it's based on a Mitsubishi micro rather than an AVR.

Mitsubishi's micro only has C and ASSEMBLER, and you have to pay through the nose for the rights to program in C, so I have to learn ASSEMBLER and leave behind my beloved BASIC :cry: for now. It's strange, I now the hardware side inside out, backwards, and in a parallel universe, but the programming side is still quite new to me. I use BASCOM basic as it's easy and I already program in Visual Basic.

BTW, thanks for all the great analogies! Has anyone got a link to a good ASM tutorial?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dean
If you like Red Dwarf have you seen the low budget cult film Dark Star?
Classic with a webbed footed beach ball and a talking bomb with a god complex.

Keep it simple it will not bite as hard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dean
A bright guy like you should be spending some time at Amazon.com...and getting some doco and refs for yourself...and not wasting so much time on trivial matters here.
Read and study. Hard.
Just my 2 pesos.

Isn't a smoking section in a restaurant sort of like a peeing section in a pool?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yep, thats how I taught myself Bascom, Logo (LCSI's Microworlds program) and Visual Basic.

Also, Sutton, !!!! That's sounds very interesting (and funny!). have you seen "Cube" and "Cube 2"? The original Cube is great and filmed on a rock-bottom budget.

xxyx...whatever,

Quote:
and getting some doco and refs for yourself...and not wasting so much time on trivial matters here.
? I love electronics! And I DO study hard! :lol:

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just to make things really complicated:

Quote:
the stack "grows downwards" from higher to lower memory addresses when you add something to it - imagine a hornet's nest dangling from a tree branch, growing bigger through the summer

I couldn't figure this one out at first. Waddyamean "dangling"? Then i realized that is a question of of inner visualisations": Is memory address 0 (zero) at the top or at the bottom?

In my world the memory address 0 (zero) is at the top of my visualised memory map. So if the stack starts at "RAMEND" and grows towards lower adresses it really grows upwards when i close my eyes and look...

Sort of the human variant of the little/big-endian-thing, huh?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

!!! Ok, this is strarting to make my brain hurt - and that's very rare! I need somthing to learn the basics of ASSEMBLER so I can start to work out the rest.

So, is a stack like a stack of papers, where each paper has a command? I assume the micro then reads each command in the stack. Why would you want to POP (remove) a "paper"? Also, can there be multiple stacks?

Last bit of the analagy, although you can only manipulate the top sheet of "paper", does the micro read the top or the very bottom sheet first?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
So, is a stack like a stack of papers, where each paper has a command?

No, a stack is like a stack of papers, and each paper has a return address written on it.

To explain the stack, the CALL and the RET-instructions well we'll have to introduce some knowledge of how (almost) all computers execute machine code instructions (although we'll be talking in assember rather than op-codes, but that will do nicely for now):

So, we know that the instructions comprising the program is placed in the program memory (for an AVR thats the FLASH). To execute this program the processor needs to fetch the instructions one after the other and execute them. Most of the time the processor fetches instructions in order of their sequwnce in the program memory, but when doing jumps, call or returns this fetch order is broken.

Enter a "register" that I will call PC (for Program Counter). This contains the program memory address of the next instruction to be fetched (it ponits to the next instruction.

To execute instructions, now the processor have to do this:

1. Fetch the instruction at the address pointed out by PC.
2. Increment PC (to eventually be ready to fetch the next instruction).
3. Analyze the instruction and execute it.
4. Iterate from 1.

Lets assume that we have these two instructions at addresses 12-13 in program memory:

12: LOAD r8,99
13: ADD r8,98

and that the value of PC is 12. So the Load -instruction is fetched. Next PC is incremented to 13. Then the instruction is analyzed and executed.

Now we go back to step 1 above and fetch an instruction again. This time PC is 13 and... Well, You ought to see it by now.

So what about the jumps, calls and returns? Well for a jump (JUMP address) step 3 above amouts to: Extract the address from the instruction and place it in PC. Let's say we are executing an instruction at address 42 and that this instruction is JUMP 123. The execution proper (step 3) of a JUMP instruction amounts to this: Take the address in the instruction and put it in PC. So step 3 will place 123 in PC. When we get back to step 1 the next instruction to fetch is the one at address 123. We got exactly what we wanted!

In step 2 the PC will be incremented to 43, which would be good if the instruction wasn't a flow-control instruction. For a jump the increment is of no practical use, but as You see we come out of the instruction cycle with everythinh in its right place anyway.

The stack hasn't come into action Yet, but...

Now on to the call. Assume that our instruction resides at address 65 and is CALL 456. To begin with, note that step 2 above has incremented PC to 66. Executing the CALL does two things:

3a: Push the contents of PC onto the stack.
3b: Copy the address in the CALL instruction to the PC.

So now we have the address 66 on top of the stack and the next instruction to execute is at program memory address 456.

Eventually the subroutine will run into a RET instruction, and lets assume that it is located at address 468. AStep 2 above will increment PC to 469 but that value will soon be discarded by the execution proper of the RET: Pop the address onthe top of the stack to PC. Now PC contains 66, and on the next iteration through the steps above the instruction at that address will be fetched and executed.

And if this long rant made any sense at all You'll now see that it's addresses to instructions that resides on the stack, not instructions per se.

(We'll talk about using the stack for subroutine parameters some other time. Just let me know!)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Woah, thanks for the novel! Stephen King has nothing on this...

Anyway, it'll take a while to digest. Im not used to having trouble learning new things, what the hell have I gotten into?!?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Take a look at www.avrbeginners.net . In particular, the stack section.

Regards,
Alejandro.
http://www.ocam.cl

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Awenstrien,

Juuuust too late. I already knew about AVRBeginners.net when I first set out on the wild world of microcontrollers, but discarded it in favour of BASCOM as most of the ultra-technical aspects were "hidden from view". Now that i'm using a micro that exclusivly uses ASSEMBLER, I started to read the site yesterday. JohanEkdahl - what's with the name by the way? - I reread your post after school today and now I seem to have a clear grasp of the stack. Now I know what it doesm how do I use it? AVRBeginners has a few lines of code labeled "initialise the stack", with no further explanation.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So you can push any register on the stack for later use?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:lol: Took me a moment to work out what "RTFM" is - don't elaborate! Anyway, nifty. Now I have a source for all the assembler commands.

Where's the reference for all the names of all the registers and their corresponding number? The datasheet gizmit you pointed to only seems to mention a few and doesnt give their number.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah. Looks like i've got a LONG way until I can write the software aspect of my manual - i've at least got the hardware down pat...

I'm gonna miss the simplicity of BASIC, where's my FOR commands when you need em - ASSEMBLER may be powerfull, but it 'aint user-friendly :cry:

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dean

Not noticed being mentioned in this thread yet.
When you call a subroutine, be it by an interrupt or software call the call puts the return address only on to the stack. So the first thing you must do is save the Sreg then the last thing write it back. You will notice this in the software examples you will have been looking at ( I hope).

Also do not forget to push and pop the working registers that are used by the called routine.

As the stack uses the same Sram area as the working code be aware there is always the chance of the programe Sram requirement being such it collides with stack space.

Mike

Keep it simple it will not bite as hard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

?!?!?!?!

Bloody Hell, I need a university degree to attempt this! Is C any easier - ASSEMBLER and C are my only options for the new mitsubishi micro.

Is there any way to get BASCOM to work with a non-AVR micro by providing a new def file?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes, you can push any of the AVR's 32 registers onto the stack. In addition the PC register is pushed onto the stack by the CALL instructions, as well as by the hardware when an interrupt occurs (in some architectures the hardware will push additional registers as well during an interrupt). Since you are looking at a different processor, there may be some limitations as to what can directly be pused onto the stack. Just like the AVR, in which you cannot directly push SREG onto the stack, some architectures may require indirect methods to push certain registers.

The obvious use for the stack is to store return addresses. It is also used to preserve any registers that you may need for later, like the status register during an interrupt routine. The stack can also be used to pass parameters to a subroutine. How the stack is used is pretty much up to you as the application developer. However, you will always need at leaast a minimal stack, as the CPU expects to have one, in order to support interrupts and calls.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abcminiuser wrote:
?!?!?!?!

Bloody Hell, I need a university degree to attempt this! Is C any easier - ASSEMBLER and C are my only options for the new mitsubishi micro.

Is there any way to get BASCOM to work with a non-AVR micro by providing a new def file?

- Dean :twisted:

Yes C would be easier, since you no longer need to worry about things like the stack. (at least not directly) You still need to be aware of it's presence, and to make sure that you don't overflow it. the same holds true for any language, even BASCOM. The other advantage of C is that most of the skills you learn in programming C, are applicable to any other platform where you program in C. The same cannot be said for assembler, since the language will be entirely different from processor to processor. (note it's still a good idea to learn assembler eventually, and while the languages may vary from processor to processor, the fundamentals remain the same)

Is theere not a GCC port for the processor you are looking at?

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The micro is the Mitsubishi M30624FGMFP. It's a 16-bit micro and as far as the developer's know, only Assembler and C can be used.

This may be a dumb question (but i'm full of em now that i'm "relearning" micros), so I'll put on my dunce cap. As far as I know, an 8-bit micro, 8 bits make up the regester, with each register able to store numbers between 0 and 255 (one byte). To store larger numbers, I assume they add two together to store larger numbers. Overflows occur when the number being stored/manipulated my the register is too large, causing the data to "overflow" as it trys to manipulate a bit that dosn't exist. In my Mitsubishi M30624FGMFP, it's 16-bit, so assumably it uses 16 bits to a register. If this is so, it would give greater accuracy as larger numbers can be stored. Am I right?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

you don't increase acuracy. Since you can always chain registers to store larger values. What you do gain, is efficiency in handeling those larger values.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok. Another: Where is the stack stored? My guess is that its stored in the SRAM, with the data being POPed into a register for calculation/use.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes, typically the stack is stored in ram. Where in ram depends on how you set it up.

Note some small processors, like the AVR's with no sram, have a small 'hardware' stack. This hardware stack, is still a small area of SRAM, but it's exclusively resurved for stack operations.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go my powers of deduction. Anyway, i'll ask more as I think of it.

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abc-man

A little time reading an introductory text would make this all a bit less frustrating. You'll go at a snail's pace by stringing random questions on this forum.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, ok, point taken. Anyway I think I know everything required to get started now, except for the &^%(*&^(*^(*&%^$(*% stack. At least AVRBeginners has a section devoted to this.

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In cowboy days, they might have said thay you have a burr in your shorts.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

?!?!

Anyway, this is getting OT. What's with everyone suddenly using oddball avitars, anyway?

Thanks to the guy who sent me a novel-and-a-half sized email about the *&^%(*^)( stack - i'll read it when I get time, I just got the board that i'm writing about today in the mail. I know what the stack is and what it does, I just need to learn how the *&&_) hell to initialise and use it - why doesn't the bloody micro work it out itself?

- Dean :twisted:

Make Atmel Studio better with my free extensions. Open source and feedback welcome!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A few (final?) things from me:

Quote:
What's with everyone suddenly using oddball avitars, anyway?

Maybe for the obvious reason that we are...

Getting the hang of all this h/w and close-to-h/w stuff can be difficult, and will take time. Mix practice with theory - You have to get on a bike if You want to learn how to ride one.

Use the simulator in AVR Studio - it is an invaluable tool for "visualization" of what a program does. (BTW: It will show eg. the stack pointer register. Keep an eye on it while executing a RCALL instruction!)

Consider assembly programming a good vehicle for understanding h/w issues but consider moving to C/C++ eventually.

Not in any way meaning to pat any head I must say that I am impressed by You!

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abcminiuser wrote:
I just need to learn how the *&&_) hell to initialise and use it - why doesn't the bloody micro work it out itself?

- Dean :twisted:

Initializing the stack, usually implies telling the micro where to put it. Aas to why the hardware doens't do this itself, the answer to that is simple, to be flexable. If the micro were to hardcode the stack address, you would have little or no means to make it bigger, or place it in an area that is out of the way of the requirements for your own application. Aslo, depending on the micro, it may have no idea how much ram you actually have, so it would have no idea where it would be safe to put the stack.

as for the avatars, as far as I can tell, I"m the only one with a new one around here. I finally decided that it was tiem to put one up for myself. If you ever met foamy (my avatar [www.illwillpress.com]), and then met me, you would understand why I chose this one.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

glitch wrote:

as for the avatars, as far as I can tell, I"m the only one with a new one around here. I finally decided that it was tiem to put one up for myself. If you ever met foamy (my avatar [www.illwillpress.com]), and then met me, you would understand why I chose this one.

My felicitations Glitch for your new avatar.
As a matter of fact, i was considering replacing my old avatar by a new one.
Maybe i'll stick to my old one and just post the new one.
If you see the new picture and you know me, then you know why. :lol: :lol:

Regards,

- - big bang - -

Take a good look around. Admire our world, our galaxy, the whole universe. Then you just feel there must be a
'Theory of everything'

Maybe, someday, the human race is ready to discover it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

[Okay.. getting more OT]

Quote:
I finally decided that it was tiem to put one up for myself. If you ever met foamy (my avatar [www.illwillpress.com]), and then met me, you would understand why I chose this one.

Wicked Avatar, wondered where it came from! I'll check it out when I get home from work (never sure if stuff like that is SFW, at least in an open-cubicle environment!).

Regards,

-Colin

PS: For anyone who doesn't know, mine is the CF-105 or more commonly called "Avro Arrow", see http://www.avroarrow.org/

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Still OT:

c_oflynn wrote:
(never sure if stuff like that is SFW, at least in an open-cubicle environment!).

This one is DEFINATELY NOT safe at work, unless you work in a VERY casual environment.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OT:

abcminiuser wrote:
:lol: Took me a moment to work out what "RTFM" is - don't elaborate!

Welcome to the wonderful world of computer jargon. :D

Go to the Jargon page for more great definitions:
http://www.catb.org/~esr/jargon/