My 1802 target for LCC just defines and initializes globals in the
static assembly so that, for example, if you restart it, the original initializers are not refreshed. Is that standard C?
I'm working now on a target that splits the code off for ROM and I
need a way to initialize RAM globals.
bill rowe <bill.row...@gmail.com> writes:
My 1802 target for LCC just defines and initializes globals in the
static assembly so that, for example, if you restart it, the original initializers are not refreshed. Is that standard C?
I'm working now on a target that splits the code off for ROM and II'm not certain what behavior you're describing.
need a way to initialize RAM globals.
This program:
#include <stdio.h>
int global = 10;
int main(void) {
printf("%d ", global);
global = 20;
printf("%d\n", global);
}
must print "10 20" every time it's executed. If it prints "10 20"
the first time and "20 20" the second time, the implementation is
not conforming. (Replace printf by some other mechanism if the
target doesn't support stdio.)
--
Keith Thompson (The_Other_Keith) Keith.S.T...@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
On Monday, November 2, 2020 at 4:29:09 PM UTC-5, Keith Thompson wrote:
bill rowe <bill.row...@gmail.com> writes:well, for some definition of "every time it's executed" ;-) In a small computer where there's no operating system, the C program gets loaded
My 1802 target for LCC just defines and initializes globals in theI'm not certain what behavior you're describing.
static assembly so that, for example, if you restart it, the original
initializers are not refreshed. Is that standard C?
I'm working now on a target that splits the code off for ROM and I
need a way to initialize RAM globals.
This program:
#include <stdio.h>
int global = 10;
int main(void) {
printf("%d ", global);
global = 20;
printf("%d\n", global);
}
must print "10 20" every time it's executed. If it prints "10 20"
the first time and "20 20" the second time, the implementation is
not conforming. (Replace printf by some other mechanism if the
target doesn't support stdio.)
by itself and the loaded binary has the initialized variables in it.
If, after it has run and printf'd, you reset the computer to run it
again without reloading the binary, it will print 20 twice.
That's fine if you know about it, the real kicker is if the code has
to go in ROM and the data in RAM so it's only *ever* loaded once. I
need a mechanism to get my LCC generated program to copy init values
to the RAM "*every* time it's executed" or restarted. I can work
around it by init'ing the globals at the top of main but i'm hoping
someone has a more integrated approach.
My 1802 target for LCC just defines and initializes globals in the
static assembly so that, for example, if you restart it, the
original initializers are not refreshed. Is that standard C?
I'm working now on a target that splits the code off for ROM and I
need a way to initialize RAM globals.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 292 |
Nodes: | 16 (2 / 14) |
Uptime: | 203:50:17 |
Calls: | 6,617 |
Calls today: | 1 |
Files: | 12,168 |
Messages: | 5,316,475 |