1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-25 21:33:44 +00:00
C02/work/structs.c02

83 lines
1.7 KiB
Plaintext
Raw Normal View History

2018-03-08 19:35:00 +00:00
/* Test C02 define directive */
#pragma origin 1000
char d, i;
2019-05-13 03:34:47 +00:00
char lo, hi;
2018-03-08 19:35:00 +00:00
char index, name[8], data[128];
2019-05-13 03:34:47 +00:00
int addr;
//Define Structures
struct point {
char x, y;
};
struct line {
struct point bgnpnt, endpnt;
};
2018-03-08 19:35:00 +00:00
struct record {
2019-05-13 03:34:47 +00:00
/* This is a Record */ //Extra Comment
char name[8]; //Name
char index; //Index
int addr; //Address
struct point pnt; //Point
char data[128]; //Data
2018-03-08 19:35:00 +00:00
};
2019-05-13 03:34:47 +00:00
//Declare Structure Variables
struct point pnt;
struct point bgnpnt, endpnt;
struct line lin;
2018-03-08 19:35:00 +00:00
struct record rec;
//Display Structure Info
2019-05-13 03:34:47 +00:00
printf(?pnt.x,"?pnt.x=%d\t");
printf(@pnt.x,"@pnt.x=%d\n");
printf(?pnt.y,"?pnt.y=%d\t");
printf(@pnt.y,"@pnt.y=%d\n");
printf(@rec,"@rec=%d\n");
printf(?rec.name,"?rec.name=%d\t");
printf(@rec.name,"@rec.name=%d\n");
printf(?rec.index,"?rec.index=%d\t");
printf(@rec.index,"@rec.index=%d\n");
2019-05-13 03:34:47 +00:00
printf(?rec.addr,"?rec.addr=%d\t");
printf(@rec.addr,"@rec.addr=%d\n");
printf(?rec.pnt,"?rec.pnt=%d\t");
printf(@rec.pnt,"@rec.pnt=%d\n");
printf(?rec.data,"?rec.data=%d\t");
printf(@rec.data,"@rec.data=%d\n");
2019-05-13 03:34:47 +00:00
//Get Member LSB & MSB
hi = >rec.addr; lo = <rec.addr;
hi = >&rec.data; lo = <&rec.data;
2018-03-08 19:35:00 +00:00
//Set Structure Members
strdst(&rec.name); strcpy(name);
rec.index = index;
2019-05-13 03:34:47 +00:00
rec.addr = $ABCD;
rec.pnt.x = 33;
rec.pnt.y = 44;
2018-03-08 19:35:00 +00:00
for (i = 0; i<=128; i++)
rec.data[i] = d;
//Pass Entire Structure into Function
2018-03-09 01:07:31 +00:00
blkput(@rec, &rec);
2019-05-13 03:34:47 +00:00
//Print Structure Members
setdst(rec.name); putln("rec.name=\"%s\"");
2018-03-09 01:07:31 +00:00
//Copy Struct Member
memdst(&data); memcpy(@rec.data, &rec.data);
2018-03-08 19:35:00 +00:00
//Get Structure Members
index = rec.index;
2019-05-13 03:34:47 +00:00
addr = rec.addr;
2018-03-08 19:35:00 +00:00
for (i = 0; i<129; i++)
d = rec.data[i];
//Treat Structure Like an Array
2018-03-08 19:35:00 +00:00
for (i = 0; i<140; i++)
d = rec[i];