Initialising a stack for a new thread
-
void thread();
...
static uint8_t stack[40];
*(uint16_t *)(stack + sizeof(stack) - 2) = uint16_t(&thread);
stack_pointer = stack + sizeof(stack) - 21;When the new thread was switched to the program would restart. The address is on the right place on the stack. The stack is large enough. Weird answer later.
-
void thread();
...
static uint8_t stack[40];
*(uint16_t *)(stack + sizeof(stack) - 2) = uint16_t(&thread);
stack_pointer = stack + sizeof(stack) - 21;When the new thread was switched to the program would restart. The address is on the right place on the stack. The stack is large enough. Weird answer later.
Shouldn't this be under coding horrors?
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
Shouldn't this be under coding horrors?
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
It would better fit under CPU design horrors. It turned out that I was writing the address in the wrong byte order. This otherwise little-endian system has a big-endian stack!
-
It would better fit under CPU design horrors. It turned out that I was writing the address in the wrong byte order. This otherwise little-endian system has a big-endian stack!
-
Atmel AVR, specifically a ATMega168 micro-controler.
-
Atmel AVR, specifically a ATMega168 micro-controler.
-
It would better fit under CPU design horrors. It turned out that I was writing the address in the wrong byte order. This otherwise little-endian system has a big-endian stack!
Timothy Baldwin wrote:
This otherwise little-endian system has a big-endian stack!
That seems more than a little bizarre!
Steve
-
Shouldn't this be under coding horrors?
Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
Depends on who wrote it. "Subtle bugs" = mine "Coding Horrors" = everyone elses But anyway, with the low traffic it would be ok to merge the two boards. "Subtle Horrors", maybe?
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist -
Depends on who wrote it. "Subtle bugs" = mine "Coding Horrors" = everyone elses But anyway, with the low traffic it would be ok to merge the two boards. "Subtle Horrors", maybe?
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighistCoding Bugs: It's What's For Dinner!™
Software Zen:
delete this;
Fold With Us![^]