looking for sysvar list

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

looking for sysvar list

Post by cborn »

Hi,
is there a system variable list somewhere ?
I was experimenting a bit for a sysvar viewer but probably such sysvar list already exsist.

I had a little struggle to make mine since i want it al 'int' or al 'char' since that is easier to use.
but a char is 8bits and valid for a single byte sysvar and int is 16bit and valid for a doublebyte sysvar

this is my TEST and a bit off nonsence

Code: Select all

 /* zcc +zx -vn sysRAM017.c -o sysRAM017 -lndos -create-app */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

unsigned int sysword(unsigned char *a[])
 {
  int word;
  word = (int)*a[0]  +256 * (int)*a[1] ;
  printf("x: %d %d %d \n", *a[0], *a[1], word);
  return word ;
 }

int sword(unsigned char *a , unsigned char *b)
 {
  unsigned int word = *a  +256 * *b  ;
  return word ;
 }

//  - - - - - - - - - - - - - - -

int sysvar()
{
unsigned int rmtp , rmtop ,mrtop ;
unsigned char  *RAMTOP     = 23730 ;
unsigned char  *RAMTOP2    = 23731 ;
unsigned char  *RAMTP[2]   = 23730 ;
unsigned int   *_RAMTOP    = 23730 ;
rmtp =*RAMTOP  +256 * *RAMTOP2  ;
rmtop=*RAMTP[0]+256 * *RAMTP[1] ;
mrtop=RAMTP ;

printf("\xC");  //cls
printf("a:\n  char *RAMTOP  %3d\n  RAMTOP  %3d\n", *RAMTOP , RAMTOP ) ;
printf("  char *RAMTOP2 %3d\n  RAMTOP2 %3d\n", *RAMTOP2, RAMTOP2 ) ;
printf("  int rmtp=*RAMTOP   +256 * *RAMTOP2 =  %5d\n", rmtp ) ;
printf("  int mrtop=RAMTOP  %5d\n", mrtop ) ;
printf("b:\n  char *RAMTP[0] %3d\n  RAMTP[0] %3d\n", *RAMTP[0] , RAMTP[0] ) ;
printf("  char *RAMTP[1] %3d\n  RAMTP[1] %3d\n", *RAMTP[1] , RAMTP[1] ) ;
printf("  int rmtop=*RAMTP[0]+256 * *RAMTP[1] =  %5d\n", rmtop ) ;
printf("c:\n  int *_RAMTOP %5d  _RAMTOP %5d\n",  *_RAMTOP ,  _RAMTOP ) ;
printf("d: sysword( *RAMTP  )           %5d \n",sysword(*RAMTP) ) ;
printf("e: sysword( *_RAMTOP)           %5d \n",sysword(*_RAMTOP) ) ;
printf("f: sword(*RAMTOP   , *RAMTOP2 ) %5d \n",sword(*RAMTOP   , *RAMTOP2   ) ) ;
printf("g: sword(RAMTOP    , RAMTOP2 )  %5d \n",sword(RAMTOP   , RAMTOP2   ) ) ;
printf("h: sword(RAMTP[0] , RAMTP[1]) %5d \n",sword(RAMTP[0] , RAMTOP[1] ) ) ;
return ;
}
//--------------------------------------
void main()
{
sysvar();
return ;
}
so now i have this:

Code: Select all

 /* zcc +zx -vn sysRAM018.c -o sysRAM018 -lndos -create-app */
 #include <stdio.h>
 #include <stdlib.h>
 
int sysword(unsigned char *a , unsigned char *b)
 {
  unsigned int sysword = *a  +256 * *b  ;
  return sysword ;
 }
//  - - - - - - - - - - - - - - -
int sysvar()
{
unsigned char  *RAMTOP1 = 23730 ;
unsigned char  *RAMTOP2 = 23731 ;
int RAMTOP= sysword(RAMTOP1 , RAMTOP2 );
printf("RAMTOP =%6d", RAMTOP );
return ;
}
//--------------------------------------
void main()
{
printf("\xC");  //cls
sysvar();
return ;
}
probably a bit to much for a 16bit value, but now they are all defined as CHAR and per adres reachable.
int *ramtop=23730; is shorter, but you cant fit a 8bit value in it as like with SCRCT needed , far as i understood.
probably i do to much, as usual.
like (edited):

Code: Select all

  /* zcc +zx -vn sysvar027.c -o sysvar027 -lndos -create-app */

 #include <stdio.h>

int sysword(unsigned char *a , unsigned char *b)
 {
  unsigned int sysword = *a  +256 * *b  ;
  return sysword ;
 }

//  - - - - - - - - - - - - - - -
int sysvar()
{
unsigned char  *KSTATE0 = 23552 ;
unsigned char  *KSTATE1 = 23553 ;
unsigned char  *KSTATE2 = 23554 ;
unsigned char  *KSTATE3 = 23555 ;
unsigned char  *KSTATE4 = 23556 ;
unsigned char  *KSTATE5 = 23557 ;
unsigned char  *KSTATE6 = 23558 ;
unsigned char  *KSTATE7 = 23559 ;

unsigned char  *LASTK   = 23560 ;
printf("LASTK  =%6d\n", *LASTK );

unsigned char  *REPDEL  = 23561 ;
printf("REPDEL =%6d\n", *REPDEL );

unsigned char  *REPPER  = 23562 ;
printf("REPPER =%6d\n", *REPPER );

unsigned char  *DEFADD1 = 23563 ;
unsigned char  *DEFADD2 = 23564 ;
int DEFADD= sysword(DEFADD1 ,DEFADD2 );
printf("DEFADD =%6d\n", DEFADD );

unsigned char  *KDATA   = 23565 ;
printf("KDATA  =%6d\n", *KDATA );

unsigned char  *TVDATA1 = 23566 ;
unsigned char  *TVDATA2 = 23567 ;
int TVDATA= sysword(TVDATA1 ,TVDATA2 );
printf("TVDATA =%6d\n", TVDATA );

unsigned char  *STRMS00 = 23568 ; // #-3 or #fd
unsigned char  *STRMS01 = 23569 ;
unsigned char  *STRMS02 = 23570 ; // #-2 or #fe
unsigned char  *STRMS03 = 23571 ;
unsigned char  *STRMS04 = 23572 ; // #-1 or #ff
unsigned char  *STRMS05 = 23573 ;
unsigned char  *STRMS06 = 23574 ; // #0
unsigned char  *STRMS07 = 23575 ;
unsigned char  *STRMS08 = 23576 ; // #1
unsigned char  *STRMS09 = 23577 ;
unsigned char  *STRMS10 = 23578 ; // #2
unsigned char  *STRMS11 = 23579 ;
unsigned char  *STRMS12 = 23580 ; // #3
unsigned char  *STRMS13 = 23581 ;
unsigned char  *STRMS14 = 23582 ; // #4
unsigned char  *STRMS15 = 23583 ;
unsigned char  *STRMS16 = 23584 ; // #5
unsigned char  *STRMS17 = 23585 ;
unsigned char  *STRMS18 = 23586 ; // #6
unsigned char  *STRMS19 = 23587 ;
unsigned char  *STRMS20 = 23588 ; // #7
unsigned char  *STRMS21 = 23589 ;
unsigned char  *STRMS22 = 23590 ; // #8
unsigned char  *STRMS23 = 23591 ;
unsigned char  *STRMS24 = 23592 ; // #9
unsigned char  *STRMS25 = 23593 ;
unsigned char  *STRMS26 = 23594 ; // #10
unsigned char  *STRMS27 = 23595 ;
unsigned char  *STRMS28 = 23596 ; // #11
unsigned char  *STRMS29 = 23597 ;
unsigned char  *STRMS30 = 23598 ; // #12
unsigned char  *STRMS31 = 23599 ;
unsigned char  *STRMS32 = 23600 ; // #13
unsigned char  *STRMS33 = 23601 ;
unsigned char  *STRMS34 = 23602 ; // #14
unsigned char  *STRMS35 = 23603 ;
unsigned char  *STRMS36 = 23604 ; // #15
unsigned char  *STRMS37 = 23605 ;

unsigned char  *CHARS1  = 23606 ;
unsigned char  *CHARS2  = 23607 ;
int CHARS= sysword(CHARS1 ,CHARS2 );
printf("CHARS  =%6d\n", CHARS );

unsigned char  *RASP    = 23608 ;
printf("RASP   =%6d\n", *RASP );

unsigned char  *PIP     = 23609 ;
printf("PIP    =%6d\n", *PIP );

unsigned char  *ERRNR   = 23610 ;
printf("ERRNR  =%6d\n", *ERRNR );

unsigned char  *FLAGS   = 23611 ; //
printf("FLAGS  =%6d\n", *FLAGS );

unsigned char  *TVFLAGS = 23612 ; //
printf("TVFLAGS=%6d\n", *TVFLAGS );

unsigned char  *ERRSP1  = 23613 ;
unsigned char  *ERRSP2  = 23614 ;
int ERRSP= sysword(ERRSP1 ,ERRSP2 );
printf("ERRSP  =%6d\n", ERRSP );

unsigned char  *LISTSP1 = 23615 ;
unsigned char  *LISTSP2 = 23616 ;
int LISTSP= sysword(LISTSP1 ,LISTSP2 );
printf("LISTSP =%6d\n", LISTSP );

unsigned char  *MODE    = 23617 ; //
printf("MODE   =%6d\n", *MODE );

unsigned char  *NEWPPC1 = 23618 ;
unsigned char  *NEWPPC2 = 23619 ;
int NEWPPC= sysword(NEWPPC1 ,NEWPPC2 );
printf("NEWPPC =%6d\n", NEWPPC );

unsigned char  *NSPPC   = 23620 ;
printf("NSPPC  =%6d\n", *NSPPC );

unsigned char  *PPC1    = 23621 ;
unsigned char  *PPC2    = 23622 ;
int PPC= sysword(PPC1 ,PPC2 );
printf("PPC    =%6d\n", PPC );

unsigned char  *SUBPPC  = 23623 ;
printf("SUBPPC =%6d\n", *SUBPPC );

unsigned char  *BORDCR  = 23624 ;
printf("BORDCR =%6d\n", *BORDCR );

unsigned char  *EPPC1   = 23625 ;
unsigned char  *EPPC2   = 23626 ;
int EPPC= sysword(EPPC1 ,EPPC2 );
printf("EPPC   =%6d\n", EPPC );

unsigned char  *VARS1   = 23627 ;
unsigned char  *VARS2   = 23628 ;
int VARS= sysword(VARS1 ,VARS2 );
printf("VARS   =%6d\n", VARS );

unsigned char  *DEST1   = 23629 ;
unsigned char  *DEST2   = 23630 ;
int DEST= sysword(DEST1 ,DEST2 );
printf("DEST   =%6d\n", DEST );

unsigned char  *CHANS1  = 23631 ;
unsigned char  *CHANS2  = 23632 ;
int CHANS= sysword(CHANS1 ,CHANS2 );
printf("CHANS  =%6d\n", CHANS );

unsigned char  *CURCHL1 = 23633 ;
unsigned char  *CURCHL2 = 23634 ;
int CURCHL= sysword(CURCHL1 ,CURCHL2 );
printf("CURCHL =%6d\n", CURCHL );

unsigned char  *PROG1   = 23635 ;
unsigned char  *PROG2   = 23636 ;
int PROG= sysword(PROG1 ,PROG2 );
printf("PROG   =%6d\n", PROG );

unsigned char  *NXTLIN1 = 23637 ;
unsigned char  *NXTLIN2 = 23638 ;
int NXTLIN= sysword(NXTLIN1 ,NXTLIN2 );
printf("NXTLIN =%6d\n", NXTLIN );

unsigned char  *DATADD1 = 23639 ;
unsigned char  *DATADD2 = 23640 ;
int DATADD= sysword(DATADD1 ,DATADD2 );
printf("DATADD =%6d\n", DATADD );

unsigned char  *ELINE1  = 23641 ;
unsigned char  *ELINE2  = 23642 ;
int ELINE= sysword(ELINE1 ,ELINE2 );
printf("ELINE  =%6d\n", ELINE );

unsigned char  *KCUR1   = 23643 ;
unsigned char  *KCUR2   = 23644 ;
int KCUR= sysword(KCUR1 ,KCUR2 );
printf("KCUR   =%6d\n", KCUR );

unsigned char  *CHADD1  = 23645 ;
unsigned char  *CHADD2  = 23646 ;
int CHADD= sysword(CHADD1 ,CHADD2 );
printf("CHADD  =%6d\n", CHADD );

unsigned char  *XPTR1   = 23647 ;
unsigned char  *XPTR2   = 23648 ;
int XPTR= sysword(XPTR1 ,XPTR2 );
printf("XPTR   =%6d\n", XPTR );

unsigned char  *WORKSP1 = 23649 ;
unsigned char  *WORKSP2 = 23650 ;
int WORKSP= sysword(WORKSP1 ,WORKSP2 );
printf("WORKSP =%6d\n", WORKSP );

unsigned char  *STKBOT1 = 23651 ;
unsigned char  *STKBOT2 = 23652 ;
int STKBOT= sysword(STKBOT1 ,STKBOT2 );
printf("STKBOT =%6d\n", STKBOT );

unsigned char  *STKEND1 = 23653 ;
unsigned char  *STKEND2 = 23654 ;
int STKEND= sysword(STKEND1 ,STKEND2 );
printf("STKEND =%6d\n", STKEND );

unsigned char  *BREG    = 23655 ;
printf("BREG   =%6d\n", *BREG );

unsigned char  *MEM1    = 23656 ;
unsigned char  *MEM2    = 23657 ;
int MEM= sysword(MEM1 ,MEM2 );
printf("MEM    =%6d\n", MEM );

unsigned char  *FLAGS_2 = 23658 ; //
printf("FLAGS_2=%6d\n", *FLAGS_2 );

unsigned char  *DFSZ    = 23659 ;
printf("DFSZ   =%6d\n", *DFSZ );

unsigned char  *S_TOP1  = 23660 ;
unsigned char  *S_TOP2  = 23661 ;
int S_TOP= sysword(S_TOP1 ,S_TOP2 );
printf("S_TOP  =%6d\n", S_TOP );

unsigned char  *OLDPPC1 = 23662 ;
unsigned char  *OLDPPC2 = 23663 ;
int OLDPPC= sysword(OLDPPC1 ,OLDPPC2 );
printf("OLDPPC =%6d\n", OLDPPC );

unsigned char  *OSPPC   = 23664 ;
printf("OSPPC  =%6d\n", *OSPPC );

unsigned char  *FLAGX   = 23665 ; //
printf("FLAGX  =%6d\n", *FLAGX );

unsigned char  *STRLEN1 = 23666 ;
unsigned char  *STRLEN2 = 23667 ;
int STRLEN= sysword(STRLEN1 ,STRLEN2 );
printf("STRLEN =%6d\n", STRLEN );

unsigned char  *TADDR1  = 23668 ;
unsigned char  *TADDR2  = 23669 ;
int TADDR= sysword(TADDR1 ,TADDR2 );
printf("TADDR  =%6d\n", TADDR );

unsigned char  *SEED1   = 23670 ;
unsigned char  *SEED2   = 23671 ;
int SEED= sysword(SEED1 ,SEED2 );
printf("SEED   =%6d\n", SEED );

unsigned char  *FRAMES1 = 23672 ;
unsigned char  *FRAMES2 = 23673 ;
unsigned char  *FRAMES3 = 23674 ;

unsigned char  *UDG1    = 23675 ;
unsigned char  *UDG2    = 23676 ;
int UDG= sysword(UDG1 ,UDG2 );
printf("UDG    =%6d\n", UDG );

unsigned char  *COORDX  = 23677 ;
unsigned char  *COORDY  = 23678 ;

unsigned char  *PPOSN   = 23679 ;
printf("PPOSN  =%6d\n", *PPOSN );

unsigned char  *PRCC1   = 23680 ;
unsigned char  *PRCC2   = 23681 ;
int PRCC= sysword(PRCC1 ,PRCC2 );
printf("PRCC   =%6d\n", PRCC );

unsigned char  *ECHOE1  = 23682 ;
unsigned char  *ECHOE2  = 23683 ;
int ECHOE= sysword(ECHOE1 ,ECHOE2 );
printf("ECHOE  =%6d\n", ECHOE );

unsigned char  *DFCC1   = 23684 ;
unsigned char  *DFCC2   = 23685 ;
int DFCC= sysword(DFCC1 ,DFCC2 );
printf("DFCC   =%6d\n", DFCC );

unsigned char  *DFCCL1  = 23686 ;
unsigned char  *DFCCL2  = 23687 ;
int DFCCL= sysword(DFCCL1 ,DFCCL2 );
printf("DFCCL  =%6d\n", DFCCL );

unsigned char  *SPOSUC  = 23688 ;
unsigned char  *SPOSUL  = 23689 ;
unsigned char  *SPOSLC  = 23690 ;
unsigned char  *SPOSLL  = 23691 ;

unsigned char  *SCRCT   = 23692 ;
printf("SCRCT  =%6d\n", *SCRCT );

unsigned char  *ATTRP   = 23693 ;
printf("ATTRP  =%6d\n", *ATTRP );
unsigned char  *MASKP   = 23694 ;
printf("MASKP  =%6d\n", *MASKP );

unsigned char  *ATTRT   = 23695 ;
printf("ATTRT  =%6d\n", *ATTRT );
unsigned char  *MASKT   = 23696 ;
printf("MASKT  =%6d\n", *MASKT );

unsigned char  *PFLAG   = 23697 ;
printf("PFLAG  =%6d\n", *PFLAG );

unsigned char  *MEMBOT00= 23698 ;
unsigned char  *MEMBOT01= 23699 ;
unsigned char  *MEMBOT02= 23700 ;
unsigned char  *MEMBOT03= 23701 ;
unsigned char  *MEMBOT04= 23702 ;
unsigned char  *MEMBOT05= 23703 ;
unsigned char  *MEMBOT06= 23704 ;
unsigned char  *MEMBOT07= 23705 ;
unsigned char  *MEMBOT08= 23706 ;
unsigned char  *MEMBOT09= 23707 ;

unsigned char  *MEMBOT10= 23708 ;
unsigned char  *MEMBOT11= 23709 ;
unsigned char  *MEMBOT12= 23710 ;
unsigned char  *MEMBOT13= 23711 ;
unsigned char  *MEMBOT14= 23712 ;
unsigned char  *MEMBOT15= 23713 ;
unsigned char  *MEMBOT16= 23714 ;
unsigned char  *MEMBOT17= 23715 ;
unsigned char  *MEMBOT18= 23716 ;
unsigned char  *MEMBOT19= 23717 ;

unsigned char  *MEMBOT20= 23718 ;
unsigned char  *MEMBOT21= 23719 ;
unsigned char  *MEMBOT22= 23720 ;
unsigned char  *MEMBOT23= 23721 ;
unsigned char  *MEMBOT24= 23722 ;
unsigned char  *MEMBOT25= 23723 ;
unsigned char  *MEMBOT26= 23724 ;
unsigned char  *MEMBOT27= 23725 ;
unsigned char  *MEMBOT28= 23726 ;
unsigned char  *MEMBOT29= 23727 ;

unsigned char  *NONAME1 = 23728 ;
unsigned char  *NONAME2 = 23629 ;
int NONAME= sysword(NONAME1 ,NONAME2 );
printf("NONAME =%6d\n", NONAME );

unsigned char  *RAMTOP1 = 23730 ;
unsigned char  *RAMTOP2 = 23731 ;
int RAMTOP= sysword(RAMTOP1 , RAMTOP2 );
printf("RAMTOP =%6d\n", RAMTOP );

unsigned char  *PRAMT1  = 23632 ;
unsigned char  *PRAMT2  = 23633 ;
int PRAMT= sysword(PRAMT1 , PRAMT2 );
printf("PRAMT  =%6d\n", PRAMT  );

return ;
}


//--------------------------------------

void main()
{
printf("\xC");  //cls
sysvar();
printf("\n\n\n");
return ;
}
any comment is very welcome
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

Hello
The return value from all unsigned ints and chars still is a signed integer.
what do i do wrong?

Code: Select all

 /* zcc +zx -vn sysRAM019.c -o sysRAM019 -lndos -create-app -zorg=50000 */
 #include <stdio.h>
unsigned int sysword(unsigned char *a , unsigned char *b)
 {
  unsigned int sysword = *a  +256 * *b  ;
  return sysword ;
 }
//  - - - - - - - - - - - - - - -
int sysvar()
{
unsigned char  *RAMTOP1 = 23730 ;
unsigned char  *RAMTOP2 = 23731 ;
unsigned int RAMTOP= sysword(RAMTOP1 , RAMTOP2 );
printf("RAMTOP =%6d", RAMTOP );
return ;
}
//--------------------------------------
void main()
{
printf("\xC");  //cls
printf("startadres set to 50000 at compile time,\n");
printf("RAMTOP has to be 49999 now.\n\n");
sysvar();
return ;
}
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

hmm
unsigned char *RAMTOP1 = 23730;

in my mind i set the memory location to 23730, but is not how it works.
an unknown memory location is filled with TWO bytes, as a 2byte string.
in gcc it will print 23730 with printf("%6d", RAMTOP1)
and give a segmentation error
or tells me i do some stupid with variating the source
sysRAM019.c:16:27: warning: initialization of ‘unsigned char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
unsigned char *RAMTOP1 = 23730 ;


so the 'c' system insist that i use an integer as pointer,
well, thats my conclusion.
and the difference for a 1 byte or 2 byte variable?
i hope to understand.
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

OK,
last message for now
i feel like a certain dog chacing its own tail.

Code: Select all

 /* zcc +zx -vn sysRAM_024.c -o sysRAM_024 -lndos -create-app -zorg=50000 */
 #include <stdio.h>
unsigned int sysword(unsigned char *a , unsigned char *b)
 {
  unsigned char x=*a , y=*b ;
  unsigned int sysword = x  +256 * y  ;
  return sysword ;
 }
//  - - - - - - - - - - - - - - -
int sysvar()
{
unsigned char  *RAMTOP1 = 23730 ;
unsigned char  *RAMTOP2 = 23731 ;
unsigned int *RMTP = 23730 ;

unsigned int RAMTOP= sysword(RAMTOP1 , RAMTOP2 );
unsigned int word ;

word =*RAMTOP1+ 256* *RAMTOP2 ;

printf(" RAMTOP1 =%6d\n", RAMTOP1 );

printf("*RAMTOP1 =%6d\n", *RAMTOP1 );

printf(" RAMTOP2 =%6d\n", RAMTOP2 );

printf("*RAMTOP2 =%6d\n", *RAMTOP2 );

printf(" RAMTOP  =%6d\n", RAMTOP  );

printf("*RAMTOP1 + 256* *RAMTOP2  =%6d\n", *RAMTOP1 + 256* *RAMTOP2  );

printf(" word  =%6d\n", word );

printf(" RMTP  =%6d\n", RMTP );

printf("*RMTP  =%6d\n", *RMTP );

return 0;
}
//--------------------------------------
void main()
{
printf("\xC");  //cls
printf("startadres set to 50000 at compile time,\n");
printf("RAMTOP has to be 49999 now.\n\n");
sysvar();
return ;
}
and in gcc
~/Desktop/try-C/c_in_zx/sysvars$ gcc sysRAM_024.c -o sysRAM024
sysRAM_024.c: In function ‘sysvar’:
sysRAM_024.c:17:27: warning: initialization of ‘unsigned char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
unsigned char *RAMTOP1 = 23730 ;
^~~~~
sysRAM_024.c:18:27: warning: initialization of ‘unsigned char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
unsigned char *RAMTOP2 = 23731 ;
^~~~~
sysRAM_024.c:19:22: warning: initialization of ‘unsigned int *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
unsigned int *RMTP = 23730 ;
^~~~~
~/Desktop/try-C/c_in_zx/sysvars$ ./sysRAM024

startadres set to 50000 at compile time,
RAMTOP has to be 49999 now.

Segmentation fault
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: looking for sysvar list

Post by dom »

You're printing with %d which prints the integer as if it is signed, if the value is unsigned you need to use %u.

Sometimes it's easier to look at the generated assembler to see what's going on if you're not too certain:

Code: Select all

unsigned int *RAMTOP = 23670;

__at(23670) unsigned int RAMTOP2;

unsigned int ramtop;

int main() {
        ramtop = *RAMTOP;

        ramtop = RAMTOP2;
}
Here we're doing the same thing in two different ways: using a pointer as you were using, the assignment of an integer is a little non-standard, but on a z80 sizeof(int) = sizeof(int *) so it's safe, and a fairly common paradigm. We're also using the (nonstandard) __at(NNN) placement syntax to demonstrate an alternate way of doing the same thing. This syntax indicates that a variable of the specified type is at the address indicated.

Compiling with the -a option yields:

Code: Select all

._RAMTOP
        defw    23670
        SECTION code_compiler

        ld      hl,(_RAMTOP)
        call    l_gint  ;
        ld      (_ramtop),hl
        ld      hl,(_RAMTOP2)
        ld      (_ramtop),hl
        ret

        SECTION bss_compiler
._ramtop        defs    2
        
        defc    _RAMTOP2     = 23670
The end effect is the same, l_gint does ld hl,(hl), however, using the __at syntax generates much better code and means that we don't need two bytes to hold the pointer.
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

thank %u

even the printing itselve has different behaviour.
just changing %d to %u does the job.

Now i can have a look at the extra home work.
thanks for explaining
and with _at() i can use the adres i insist to. thats a very nice feature.
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

Hi, i did not implement all the smart suggestions.
i have a resonable outcome now, exept for the LONG of FRAMES
its a to long code, but maybe i can put it in a 'structure' if i understand it al better.
its a workfile in working state ;-)

Code: Select all

/* zcc +zx -vn sysvar054g.c -o sysvar054g -lndos -create-app -lm */
//https://www.z88dk.org/forum/viewtopic.php?p=18855&sid=f20f74001e285d4504f236f59dbca6d2#p18855

 #include <stdio.h>
 #include <string.h>
 #include <math.h>

void preskey( int cls)
{
char key;
printf("Press a key");
scanf("%c",&key ) ;
if (cls == 1) {printf("\xC");}
return 0 ;
}

// - - - - - - - - - - - - - - - - - -
unsigned char byte2bitstr( int y )
{

char bitstr[9] ;
int x , z ;
printf("  ");
for (x=7 ; x>=0 ; x-- )
  {
  z=7-x;
  bitstr[z]= 48 + ((y & (1<<x))>0) ;
  }
  printf("%s" , bitstr);
  return bitstr ;
}

//  - - - - - - - - - - - - - - -
unsigned int sysword(unsigned char *a , unsigned char *b)
 {
  unsigned int sysword = *a  +256 * *b  ;
  return sysword ;
 }

//  - - - - - - - - - - - - - - -
unsigned int sysvar()
{
//__sfr __at(0x5C00) KSTATE; // SDCC special register function

int x , y ;
char bitstr[9] ;

unsigned char *KSTATE = 23552 ;
printf("%6u KSTATE  \n",KSTATE );

unsigned char  *KSTATE0 = 23552 ;
printf("%6u KSTATE0  =%6u\n",KSTATE0, *KSTATE0 );
unsigned char  *KSTATE1 = 23553 ;
printf("%6u KSTATE1  =%6u\n",KSTATE1, *KSTATE1 );
unsigned char  *KSTATE2 = 23554 ;
printf("%6u KSTATE2  =%6u\n",KSTATE2, *KSTATE2 );
unsigned char  *KSTATE3 = 23555 ;
printf("%6u KSTATE3  =%6u\n",KSTATE3, *KSTATE3 );
unsigned char  *KSTATE4 = 23556 ;
printf("%6u KSTATE4  =%6u\n",KSTATE4, *KSTATE4 );
unsigned char  *KSTATE5 = 23557 ;
printf("%6u KSTATE5  =%6u\n",KSTATE5, *KSTATE5 );
unsigned char  *KSTATE6 = 23558 ;
printf("%6u KSTATE6  =%6u\n",KSTATE6, *KSTATE6 );
unsigned char  *KSTATE7 = 23559 ;
printf("%6u KSTATE7  =%6u\n\n",KSTATE7, *KSTATE7 );

unsigned char  *LASTK   = 23560 ;
printf("%6u LASTK    =%6u\n",LASTK, *LASTK );

unsigned char  *REPDEL  = 23561 ;
printf("%6u REPDEL   =%6u\n",REPDEL, *REPDEL );

unsigned char  *REPPER  = 23562 ;
printf("%6u REPPER   =%6u\n",REPPER, *REPPER );

unsigned char  *DEFADD1 = 23563 ;
unsigned char  *DEFADD2 = 23564 ;
unsigned int DEFADD= sysword(DEFADD1 ,DEFADD2 );
printf("%6u DEFADD   =%6u\n", DEFADD1 , DEFADD );

unsigned char  *KDATA   = 23565 ;
printf("%6u KDATA    =%6u\n",KDATA, *KDATA );

unsigned char  *TVDATA1 = 23566 ;
unsigned char  *TVDATA2 = 23567 ;
unsigned int TVDATA= sysword(TVDATA1 ,TVDATA2 );
printf("%6u TVDATA   =%6u\n", TVDATA1 , TVDATA );

preskey(1);

unsigned char  *STRMSfd1 = 23568 ; // #-3 or #fd
unsigned char  *STRMSfd2 = 23569 ;
unsigned int STRMS_fd= sysword(STRMSfd1 ,STRMSfd2 );
printf("%6u STRMS_fd  =%6u\n",STRMSfd1, STRMS_fd );

unsigned char  *STRMSfe1 = 23570 ; // #-2 or #fe
unsigned char  *STRMSfe2 = 23571 ;
unsigned int STRMS_fe= sysword(STRMSfe1 ,STRMSfe2 );
printf("%6u STRMS_fe  =%6u\n",STRMSfe1, STRMS_fe );

unsigned char  *STRMSff1 = 23572 ; // #-1 or #ff
unsigned char  *STRMSff2 = 23573 ;
unsigned int STRMS_ff= sysword(STRMSff1 ,STRMSff2 );
printf("%6u STRMS_ff  =%6u\n",STRMSff1, STRMS_ff );

unsigned char  *STRMS001 = 23574 ; // #0
unsigned char  *STRMS002 = 23575 ;
unsigned int STRMS_00= sysword(STRMS001 ,STRMS002 );
printf("%6u STRMS_00  =%6u\n",STRMS001 , STRMS_00 );

unsigned char  *STRMS011 = 23576 ; // #1
unsigned char  *STRMS012 = 23577 ;
unsigned int STRMS_01= sysword(STRMS011 ,STRMS012 );
printf("%6u STRMS_01  =%6u\n",STRMS011 , STRMS_01 );

unsigned char  *STRMS021 = 23578 ; // #2
unsigned char  *STRMS022 = 23579 ;
unsigned int STRMS_02= sysword(STRMS021 ,STRMS022 );
printf("%6u STRMS_02  =%6u\n",STRMS021, STRMS_02 );

unsigned char  *STRMS031 = 23580 ; // #3
unsigned char  *STRMS032 = 23581 ;
unsigned int STRMS_03= sysword(STRMS031 ,STRMS032 );
printf("%6u STRMS_03  =%6u\n",STRMS031 , STRMS_03 );

unsigned char  *STRMS041 = 23582 ; // #4
unsigned char  *STRMS042 = 23583 ;
unsigned int STRMS_04= sysword(STRMS041 ,STRMS042 );
printf("%6u STRMS_04  =%6u\n",STRMS041, STRMS_04 );

unsigned char  *STRMS051 = 23584 ; // #5
unsigned char  *STRMS052 = 23585 ;
unsigned int STRMS_05= sysword(STRMS051 ,STRMS052 );
printf("%6u STRMS_05  =%6u\n",STRMS051 , STRMS_05 );

unsigned char  *STRMS061 = 23586 ; // #6
unsigned char  *STRMS062 = 23587 ;
unsigned int STRMS_06= sysword(STRMS061 ,STRMS062 );
printf("%6u STRMS_06  =%6u\n",STRMS061, STRMS_06 );

unsigned char  *STRMS071 = 23588 ; // #7
unsigned char  *STRMS072 = 23589 ;
unsigned int STRMS_07= sysword(STRMS071 ,STRMS072 );
printf("%6u STRMS_07  =%6u\n",STRMS071, STRMS_07 );

unsigned char  *STRMS081 = 23590 ; // #8
unsigned char  *STRMS082 = 23591 ;
unsigned int STRMS_08= sysword(STRMS081 ,STRMS082 );
printf("%6u STRMS_08  =%6u\n",STRMS081, STRMS_08 );

unsigned char  *STRMS091 = 23592 ; // #9
unsigned char  *STRMS092 = 23593 ;
unsigned int STRMS_09= sysword(STRMS091 ,STRMS092 );
printf("%6u STRMS_09  =%6u\n",STRMS091, STRMS_09 );

unsigned char  *STRMS0a1 = 23594 ; // #10
unsigned char  *STRMS0a2 = 23595 ;
unsigned int STRMS_0a= sysword(STRMS0a1 ,STRMS0a2 );
printf("%6u STRMS_0a  =%6u\n",STRMS0a1, STRMS_0a );

unsigned char  *STRMS0b1 = 23596 ; // #11
unsigned char  *STRMS0b2 = 23597 ;
unsigned int STRMS_0b= sysword(STRMS0b1 ,STRMS0b2 );
printf("%6u STRMS_0b  =%6u\n",STRMS0b1, STRMS_0b );

unsigned char  *STRMS0c1 = 23598 ; // #12
unsigned char  *STRMS0c2 = 23599 ;
unsigned int STRMS_0c= sysword(STRMS0c1 ,STRMS0c2 );
printf("%6u STRMS_0c  =%6u\n",STRMS0c1 , STRMS_0c );

unsigned char  *STRMS0d1 = 23600 ; // #13
unsigned char  *STRMS0d2 = 23601 ;
unsigned int STRMS_0d= sysword(STRMS0d1 ,STRMS0d2 );
printf("%6u STRMS_0d  =%6u\n",STRMS0d1 , STRMS_0d );

unsigned char  *STRMS0e1 = 23602 ; // #14
unsigned char  *STRMS0e2 = 23603 ;
unsigned int STRMS_0e= sysword(STRMS0e1 ,STRMS0e2 );
printf("%6u STRMS_0e  =%6u\n",STRMS0e1 , STRMS_0e );

unsigned char  *STRMS0f1 = 23604 ; // #15
unsigned char  *STRMS0f2 = 23605 ;
unsigned int STRMS_0f= sysword(STRMS0f1 ,STRMS0f2 );
printf("%6u STRMS_0f  =%6u\n",STRMS0f1, STRMS_0f );


preskey(1);

unsigned char  *CHARS1  = 23606 ;
unsigned char  *CHARS2  = 23607 ;
unsigned int CHARS= sysword(CHARS1 ,CHARS2 );
printf("%6u CHARS  =%6u\n",CHARS1 , CHARS );

unsigned char  *RASP    = 23608 ;
printf("%6u RASP   =%6u\n",RASP , *RASP );

unsigned char  *PIP     = 23609 ;
printf("%6u PIP    =%6u\n",PIP , *PIP );

unsigned char  *ERRNR   = 23610 ;
printf("%6u ERRNR  =%6u\n",ERRNR, *ERRNR );

unsigned char  *FLAGS   = 23611 ; //
printf("%6u FLAGS  =%6d   ",FLAGS, *FLAGS);
byte2bitstr( *FLAGS ) ;
printf("\n");

unsigned char  *TVFLAGS = 23612 ; //
printf("%6u TVFLAGS=%6u   ",TVFLAGS, *TVFLAGS );
byte2bitstr( *TVFLAGS ) ;
printf("\n");

unsigned char  *ERRSP1  = 23613 ;
unsigned char  *ERRSP2  = 23614 ;
unsigned int ERRSP= sysword(ERRSP1 ,ERRSP2 );
printf("%6u ERRSP  =%6u\n",ERRSP1 , ERRSP );

unsigned char  *LISTSP1 = 23615 ;
unsigned char  *LISTSP2 = 23616 ;
unsigned int LISTSP= sysword(LISTSP1 ,LISTSP2 );
printf("%6u LISTSP =%6u\n",LISTSP1 , LISTSP );

unsigned char  *MODE    = 23617 ; //
printf("%6u MODE   =%6u\n",MODE , *MODE );

unsigned char  *NEWPPC1 = 23618 ;
unsigned char  *NEWPPC2 = 23619 ;
unsigned int NEWPPC= sysword(NEWPPC1 ,NEWPPC2 );
printf("%6u NEWPPC =%6u\n",NEWPPC1 , NEWPPC );

unsigned char  *NSPPC   = 23620 ;
printf("%6u NSPPC  =%6u\n",NSPPC , *NSPPC );

unsigned char  *PPC1    = 23621 ;
unsigned char  *PPC2    = 23622 ;
unsigned int PPC= sysword(PPC1 ,PPC2 );
printf("%6u PPC    =%6u\n",PPC1 , PPC );

unsigned char  *SUBPPC  = 23623 ;
printf("%6u SUBPPC =%6u\n",SUBPPC , *SUBPPC );

unsigned char  *BORDCR  = 23624 ;
printf("%6u BORDCR =%6u\n",BORDCR, *BORDCR );

unsigned char  *EPPC1   = 23625 ;
unsigned char  *EPPC2   = 23626 ;
unsigned int EPPC= sysword(EPPC1 ,EPPC2 );
printf("%6u EPPC   =%6u\n",EPPC1 , EPPC );

unsigned char  *VARS1   = 23627 ;
unsigned char  *VARS2   = 23628 ;
unsigned int VARS= sysword(VARS1 ,VARS2 );
printf("%6u VARS   =%6u\n",VARS1 , VARS );

unsigned char  *DEST1   = 23629 ;
unsigned char  *DEST2   = 23630 ;
unsigned int DEST= sysword(DEST1 ,DEST2 );
printf("%6u DEST   =%6u\n",DEST1 , DEST );

unsigned char  *CHANS1  = 23631 ;
unsigned char  *CHANS2  = 23632 ;
unsigned int CHANS= sysword(CHANS1 ,CHANS2 );
printf("%6u CHANS  =%6u\n",CHANS1 , CHANS );

unsigned char  *CURCHL1 = 23633 ;
unsigned char  *CURCHL2 = 23634 ;
unsigned int CURCHL= sysword(CURCHL1 ,CURCHL2 );
printf("%6u CURCHL =%6u\n",CURCHL1 , CURCHL );

unsigned char  *PROG1   = 23635 ;
unsigned char  *PROG2   = 23636 ;
unsigned int PROG= sysword(PROG1 ,PROG2 );
printf("%6u PROG   =%6u\n",PROG1 , PROG );

preskey(1);

unsigned char  *NXTLIN1 = 23637 ;
unsigned char  *NXTLIN2 = 23638 ;
unsigned int NXTLIN= sysword(NXTLIN1 ,NXTLIN2 );
printf("%6u NXTLIN =%6u\n",NXTLIN1, NXTLIN );

unsigned char  *DATADD1 = 23639 ;
unsigned char  *DATADD2 = 23640 ;
unsigned int DATADD= sysword(DATADD1 ,DATADD2 );
printf("%6u DATADD =%6u\n",DATADD1, DATADD );

unsigned char  *ELINE1  = 23641 ;
unsigned char  *ELINE2  = 23642 ;
unsigned int ELINE= sysword(ELINE1 ,ELINE2 );
printf("%6u ELINE  =%6u\n",ELINE1, ELINE );

unsigned char  *KCUR1   = 23643 ;
unsigned char  *KCUR2   = 23644 ;
unsigned int KCUR= sysword(KCUR1 ,KCUR2 );
printf("%6u KCUR   =%6u\n", KCUR1,KCUR );

unsigned char  *CHADD1  = 23645 ;
unsigned char  *CHADD2  = 23646 ;
unsigned int CHADD= sysword(CHADD1 ,CHADD2 );
printf("%6u CHADD  =%6u\n", CHADD1, CHADD );

unsigned char  *XPTR1   = 23647 ;
unsigned char  *XPTR2   = 23648 ;
unsigned int XPTR= sysword(XPTR1 ,XPTR2 );
printf("%6u XPTR   =%6u\n",XPTR1 , XPTR );

unsigned char  *WORKSP1 = 23649 ;
unsigned char  *WORKSP2 = 23650 ;
unsigned int WORKSP= sysword(WORKSP1 ,WORKSP2 );
printf("%6u WORKSP =%6u\n",WORKSP1, WORKSP );

unsigned char  *STKBOT1 = 23651 ;
unsigned char  *STKBOT2 = 23652 ;
unsigned int STKBOT= sysword(STKBOT1 ,STKBOT2 );
printf("%6u STKBOT =%6u\n",STKBOT1, STKBOT );

unsigned char  *STKEND1 = 23653 ;
unsigned char  *STKEND2 = 23654 ;
unsigned int STKEND= sysword(STKEND1 ,STKEND2 );
printf("%6u STKEND =%6u\n",STKEND1, STKEND );

unsigned char  *BREG    = 23655 ;
printf("%6u BREG   =%6u\n",BREG, *BREG );

unsigned char  *MEM1    = 23656 ;
unsigned char  *MEM2    = 23657 ;
unsigned int MEM= sysword(MEM1 ,MEM2 );
printf("%6u MEM    =%6u\n",MEM1, MEM );

unsigned char  *FLAGS_2 = 23658 ; //
printf("%6u FLAGS_2=%6u   ",FLAGS_2, *FLAGS_2 );
byte2bitstr( *FLAGS_2 ) ;
printf("\n");

unsigned char  *DFSZ    = 23659 ;
printf("%6u DFSZ   =%6u\n",DFSZ , *DFSZ );

unsigned char  *S_TOP1  = 23660 ;
unsigned char  *S_TOP2  = 23661 ;
unsigned int S_TOP= sysword(S_TOP1 ,S_TOP2 );
printf("%6u S_TOP  =%6u\n",S_TOP1 , S_TOP );

unsigned char  *OLDPPC1 = 23662 ;
unsigned char  *OLDPPC2 = 23663 ;
unsigned int OLDPPC= sysword(OLDPPC1 ,OLDPPC2 );
printf("%6u OLDPPC =%6u\n",OLDPPC1 , OLDPPC );

unsigned char  *OSPPC   = 23664 ;
printf("%6u OSPPC  =%6u\n",OSPPC , *OSPPC );

unsigned char  *FLAGX   = 23665 ; //
printf("%6u FLAGX  =%6u   ",FLAGX , *FLAGX );
byte2bitstr( *FLAGX ) ;
printf("\n");

unsigned char  *STRLEN1 = 23666 ;
unsigned char  *STRLEN2 = 23667 ;
unsigned int STRLEN= sysword(STRLEN1 ,STRLEN2 );
printf("%6u STRLEN =%6u\n",STRLEN1, STRLEN );

unsigned char  *TADDR1  = 23668 ;
unsigned char  *TADDR2  = 23669 ;
unsigned int TADDR= sysword(TADDR1 ,TADDR2 );
printf("%6u TADDR  =%6u\n",TADDR1, TADDR );

preskey(1);

unsigned char  *SEED1   = 23670 ;
unsigned char  *SEED2   = 23671 ;
unsigned int SEED= sysword(SEED1 ,SEED2 );
printf("%6u SEED   =%6u\n",SEED1, SEED );

unsigned char  *FRAMES1 = 23672 ;
printf("%6u FRAMES1=%6u\n",FRAMES1 , *FRAMES1 );
unsigned char  *FRAMES2 = 23673 ;
printf("%6u FRAMES2=%6u\n",FRAMES2 , *FRAMES2 );
unsigned char  *FRAMES3 = 23674 ;
printf("%6u FRAMES3=%6u\n",FRAMES3 , *FRAMES3 );
unsigned long frame3 = *FRAMES3 * 65536 ;
unsigned int  frame2 = *FRAMES2 * 256 ;
unsigned int  frame1 = *FRAMES1 ;
unsigned long frame  = frame1 + frame2 + frame3 ;
int  framy = sysword( FRAMES1 , FRAMES2 );
printf("        frames:\n%10u\n%10u\n%10u\n%10u since last NMI\n%10u\n",(long)frame1 ,(long)frame2 ,(long)frame3,(long)frame, framy );
printf("        frames:\n%10u\n%10u\n%10u\n%10u since last NMI\n%10u\n",frame1 ,frame2 ,frame3, frame, framy );
preskey(1);

unsigned char  *UDG1    = 23675 ;
unsigned char  *UDG2    = 23676 ;
unsigned int UDG= sysword(UDG1 ,UDG2 );
printf("%6u UDG    =%6u\n",UDG1, UDG );

unsigned char  *COORDX  = 23677 ;
printf("%6u COORDX =%6u\n",COORDX , *COORDX );
unsigned char  *COORDY  = 23678 ;
printf("%6u COORDY =%6u\n",COORDY , *COORDY );

unsigned char  *PPOSN   = 23679 ;
printf("%6u PPOSN  =%6u\n",PPOSN, *PPOSN );

unsigned char  *PRCC1   = 23680 ;
unsigned char  *PRCC2   = 23681 ;
unsigned int PRCC= sysword(PRCC1 ,PRCC2 );
printf("%6u PRCC   =%6u\n",PRCC1, PRCC );

unsigned char  *ECHOE1  = 23682 ;
unsigned char  *ECHOE2  = 23683 ;
unsigned int ECHOE= sysword(ECHOE1 ,ECHOE2 );
printf("%6u ECHOE  =%6u\n",ECHOE1 , ECHOE );

unsigned char  *DFCC1   = 23684 ;
unsigned char  *DFCC2   = 23685 ;
unsigned int DFCC= sysword(DFCC1 ,DFCC2 );
printf("%6u DFCC   =%6u\n",DFCC1 , DFCC );

unsigned char  *DFCCL1  = 23686 ;
unsigned char  *DFCCL2  = 23687 ;
unsigned int DFCCL= sysword(DFCCL1 ,DFCCL2 );
printf("%6u DFCCL  =%6u\n",DFCCL1 , DFCCL );

unsigned char  *SPOSUC  = 23688 ;
printf("%6u SPOSUC =%6u\n",SPOSUC , *SPOSUC );
unsigned char  *SPOSUL  = 23689 ;
printf("%6u SPOSUL =%6u\n",SPOSUL , *SPOSUL );
unsigned char  *SPOSLC  = 23690 ;
printf("%6u SPOSLC =%6u\n",SPOSLC , *SPOSLC );
unsigned char  *SPOSLL  = 23691 ;
printf("%6u SPOSLL =%6u\n",SPOSLL , *SPOSLL );

unsigned char  *SCRCT   = 23692 ;
printf("%6u SCRCT  =%6u\n",SCRCT , *SCRCT );

preskey(1);

unsigned char  *ATTRP   = 23693 ;
printf("%6u ATTRP  =%6u   ",ATTRP, *ATTRP );
byte2bitstr( *ATTRP ) ;
printf("\n");

unsigned char  *MASKP   = 23694 ;
printf("%6u MASKP  =%6u   ",MASKP, *MASKP );
byte2bitstr( *MASKP ) ;
printf("\n");

unsigned char  *ATTRT   = 23695 ;
printf("%6u ATTRT  =%6u   ",ATTRT , *ATTRT );
byte2bitstr( *ATTRT ) ;
printf("\n");
unsigned char  *MASKT   = 23696 ;
printf("%6u MASKT  =%6u   ",MASKT , *MASKT );
byte2bitstr( *MASKT ) ;
printf("\n");

unsigned char  *PFLAG   = 23697 ;
printf("%6u PFLAG  =%6u   ",PFLAG , *PFLAG );
byte2bitstr( *PFLAG ) ;
printf("\n\n");

unsigned char  *MEMBOT00= 23698 ;
unsigned char  *MEMBOT01= 23699 ;
unsigned char  *MEMBOT02= 23700 ;
unsigned char  *MEMBOT03= 23701 ;
unsigned char  *MEMBOT04= 23702 ;
printf("%6u Membot 00-04 %3u , %3u , %3u , %3u , %3u\n",MEMBOT00 ,*MEMBOT00,*MEMBOT01,*MEMBOT02,*MEMBOT03,*MEMBOT04);

unsigned char  *MEMBOT05= 23703 ;
unsigned char  *MEMBOT06= 23704 ;
unsigned char  *MEMBOT07= 23705 ;
unsigned char  *MEMBOT08= 23706 ;
unsigned char  *MEMBOT09= 23707 ;
printf("%6u Membot 05-09 %3u , %3u , %3u , %3u , %3u\n",MEMBOT05,*MEMBOT05,*MEMBOT06,*MEMBOT07,*MEMBOT08,*MEMBOT09);

unsigned char  *MEMBOT10= 23708 ;
unsigned char  *MEMBOT11= 23709 ;
unsigned char  *MEMBOT12= 23710 ;
unsigned char  *MEMBOT13= 23711 ;
unsigned char  *MEMBOT14= 23712 ;
printf("%6u Membot 10-14 %3u , %3u , %3u , %3u , %3u\n",MEMBOT10,*MEMBOT10,*MEMBOT11,*MEMBOT12,*MEMBOT13,*MEMBOT14);

unsigned char  *MEMBOT15= 23713 ;
unsigned char  *MEMBOT16= 23714 ;
unsigned char  *MEMBOT17= 23715 ;
unsigned char  *MEMBOT18= 23716 ;
unsigned char  *MEMBOT19= 23717 ;
printf("%6u Membot 15-19 %3u , %3u , %3u , %3u , %3u\n",MEMBOT15,*MEMBOT15,*MEMBOT16,*MEMBOT17,*MEMBOT18,*MEMBOT19);

unsigned char  *MEMBOT20= 23718 ;
unsigned char  *MEMBOT21= 23719 ;
unsigned char  *MEMBOT22= 23720 ;
unsigned char  *MEMBOT23= 23721 ;
unsigned char  *MEMBOT24= 23722 ;
printf("%6u Membot 20-24 %3u , %3u , %3u , %3u , %3u\n",MEMBOT20,*MEMBOT20,*MEMBOT21,*MEMBOT22,*MEMBOT23,*MEMBOT24);

unsigned char  *MEMBOT25= 23723 ;
unsigned char  *MEMBOT26= 23724 ;
unsigned char  *MEMBOT27= 23725 ;
unsigned char  *MEMBOT28= 23726 ;
unsigned char  *MEMBOT29= 23727 ;
printf("%6u Membot 25-29 %3u , %3u , %3u , %3u , %3u\n",MEMBOT25,*MEMBOT25,*MEMBOT26,*MEMBOT27,*MEMBOT28,*MEMBOT29);

printf("\n\n");

unsigned char  *NONAME1 = 23728 ;
unsigned char  *NONAME2 = 23629 ;
unsigned int NONAME= sysword(NONAME1 ,NONAME2 );
printf("%6u NONAME =%6u\n",NONAME1, NONAME );

unsigned char  *RAMTOP1 = 23730 ;
unsigned char  *RAMTOP2 = 23731 ;
unsigned int RAMTOP= sysword(RAMTOP1 , RAMTOP2 );
printf("%6u RAMTOP =%6u\n",RAMTOP1, RAMTOP );

unsigned char  *PRAMT1  = 23632 ;
unsigned char  *PRAMT2  = 23633 ;
unsigned int PRAMT= sysword(PRAMT1 , PRAMT2 );
printf("%6u PRAMT  =%6u\n",PRAMT1, PRAMT  );

return 0;
}

//--------------------------------------

void main()
{
printf("\xC");  //cls
sysvar();
return 0;
}

// future sysvariable to include after ZX type-test
//; 128K System Variables
//23296		SWAP		;Paging subroutine (128K)/256-byte ZX Printer buffer (48K)
//23312		STOO		;Paging subroutine - Enter with ints disabled, AF, BC on stack
//23329		YOUNGER		;Paging subroutine
//23338		REGNUOY		;Paging subroutine
//23354		ONERR		;Paging subroutine
//23378,W		OLDHL		;Temp register store while paging
//23380,W		OLDBC		;Temp register store while paging
//23382,W		OLDAF		;Temp register store while paging
//23384,W		TARGET		;Subroutine addr. in ROM3
//23386,W		RETADDR		;Return addr. in ROM1
//23388,B		BANKM		;Last byte output to $7FFD
//23389,B		RAMRST		;RST 8 instruction
//23390,B		RAMERR		;Error number for RAMRST
//23391,W		BAUD		;RS232 bit period in Ts/26
//23393,B,2	SERFL		;RS232 flags/data
//23395,W		COL		;Current column from 1 to WIDTH
//23396,B		WIDTH		;Paper column width
//23397,B		TVPARS		;Number of inline params for RS232
//23398,B		FLAGS3		;Various flags
//23399,B		BANK678		;Last byte output to $1FFD
//23400,B		XLOC		;X location for COPY
//23401,B		YLOC		;Y location for COPY
//23402,W		OLDSP		;Old SP when TSTACK is in use
//23404,W		SYNRET		;Return addr. for ONERR
//23406,B,5	LASTV		;Last calculator value
//23411,W		RCLINE		;Line being renumbered
//23413,W		RCSTART		;Number of first line to renumber
//23415,W		RCSTEP		;Renumber step
//23417,B		LODDRV		;Load/Verify/Merge drive letter - "A", "B", "M" or "T"
//23418,B		SAVDRV		;Save drive letter - "A", "B", "M" or "T"
//23419,B		DUMPLF		;1/216ths user for LFs in COPY EXP
//23420,B,8	STRIP1		;Stripe1 bitmap
//23428,B,8	STRIP2		;Stripe2 bitmap
//23436,B,115	TSPACE		;Temporary stack space
//23551,B		TSTACK		;Temporary stack grows down from here
//

cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

Hello
i try to optimise the bit string code by moving a print statement to main , but it wont work
i get an printest.c:30:9: fatal error: Must be lvalue
probably there is very simple solution
i isolated the problem

Code: Select all

/* zcc +zx -v printest.c -o printest -lndos -create-app */
 #include <stdio.h>
 #include <string.h>

char byte2bitstr(char y )
{
char bitstr[9] ;
int x , z ;
for (x=0 ; x < 8 ; x++ )
  {
  z=7-x;
  bitstr[z] = 48 + ((y & (1<<x))>0) ;
  }
  printf("%s" , bitstr ) ;
  return bitstr ;
}

void main (){

unsigned char *FLAGS   = 23611 ;
unsigned char *bitstr[9] ;

printf("%6u FLAGS  =%6u   ", FLAGS, *FLAGS ) ;
 byte2bitstr( *FLAGS ) ; 
// bitstr =  byte2bitstr( *FLAGS ) ;      //fatal error: Must be lvalue
return ;
}
As soon as i want to fetch the bitstring in bitstr in main it fails.
i already tried a load off differrent situations with CHAR* and INT but i got stuck.
*bitstr[9] should be a pointer and able to fetch the value from byte2bitstr
but that is just my theory.
hope its realy as easy as i think it will be.
cheers
User avatar
dom
Well known member
Posts: 2072
Joined: Sun Jul 15, 2007 10:01 pm

Re: looking for sysvar list

Post by dom »

Not an lvalue means that it's not assignable to, clang explains the error better:

Code: Select all

y.c:27:9: error: array type 'unsigned char *[9]' is not assignable
 bitstr =  byte2bitstr( *FLAGS ) ;      //fatal error: Must be lvalue
I think what you meant to do was this:

Code: Select all

unsigned char *bitstr;
....
bitstr =  byte2bitstr( *FLAGS ) ;      //fatal error: Must be lvalue
But then looking at the code you have another problem:

Code: Select all

char byte2bitstr(char y )
{
char bitstr[9] ;
...
  return bitstr ;
}
Where you a returning a pointer to a buffer that's allocated on the stack. That memory for that buffer may well be overwritten by anything that happens after the function call.

So, you actually want:

Code: Select all


char byte2bitstr(char y )
{
static char bitstr[9];
int x , z ;
for (x=0 ; x < 8 ; x++ )
....
  return bitstr ;
}
Now it's static the memory won't be overwritten accidentally, only by a subsequent call to byte2bitstr()
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

static
ok, thats the next chapter like const and static.
i was fighting with making every thing a pointer, but it needs to be static.
thanks again, now i now were i am looking at.
chris
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

i made a resonable 'struct'.
Now i have to rewire everything since its only showing the 'struct' itself and NOT the adres aka PEEK value, yet.
some adresses are NOT YET correct,and from 3 'struct' there is only 1 used until now, its a version 0.1 or 0.01 if you like
http://www.cborn.nl/c/ZXsysvarV01.tap
http://www.cborn.nl/c/ZXsysvarV01.c
its about ZX so i dumped it here to:
https://worldofspectrum.org/forums/disc ... 0-1#latest
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

there was a big adres bug in the sys48, i hope i solved it.
its still "fresh and experimental" for me.
i hope its a kind of "systeem variable viewer"
http://www.cborn.nl/c/ZXsysvarV02.tap
http://www.cborn.nl/c/ZXsysvarV02.c
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

Hi still buzy learning,
Arjun provided a rewrite of my 'attempt' for a viewer function with separate files
arjun: https://worldofspectrum.org/forums/disc ... ent_975842
me : https://worldofspectrum.org/forums/disc ... ent_975810

It works and now i look for a way to make this file inside the ZX memory OR to make a tape.
i found

Code: Select all

unsigned char zx_tape_save_block(void *src, unsigned int len, unsigned char type)
Is there documentation about ZX saving to Tape or ramdrive??
any example is very welcome.
chris

ps:
http://www.cborn.nl/c/sysvr074d.tap
http://www.cborn.nl/c/sysvr074d.c
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

Hi, doing my homework getting 1 step closer:

www.cborn.nl/c/zxsv07b.c
www.cborn.nl/c/zxsv07b.tap

the 128 vars are still printed WRONG...
thats becouse the next chalenge is to separate the "struct" instructing from the other "struct"

this should be the common struct
struct sysvar { unsigned int *offset ; unsigned char *typebyte ; unsigned int nbyte ; unsigned char *sysvarname ; }
but how to convice the routine to use OR sysvar128 OR sysvar48 which i think like to call sv128 and sv48 , but maybe thats not clear enough.
if i get that done then maybe its a kind of 'finished' and usable as a subroutine.

Code: Select all


// OFFSET128 = 0X5B00 AKA 23296 //128K System Variables

struct sysvar { unsigned int *offset ; unsigned char *typebyte ; unsigned int nbyte ; unsigned char *sysvarname ; }

//struct sv128 { unsigned int *offset ; unsigned char *typebyte ; unsigned int nbyte ; unsigned char *sysvarname ; }

       sysvar128[36]= {
{ 23296, "O" , 36 , "SYS128" },
{    0 , "A" , 16 , "SWAP"   },  // 'A'ddress subroutine
{   16 , "A" , 17 , "STOO"   },
{   33 , "A" ,  9 , "YOUNGER"},
{   42 , "A" ,  9 , "REGNUOY"},
{   51 , "A" , 16 , "ONERR"  },
{   67 , "W" ,  2 , "OLDHL"  },  // 128k system variables
{   69 , "W" ,  2 , "OLDBC"  },  // 'W'ord
{   71 , "W" ,  2 , "OLDAF"  },
{   73 , "W" ,  2 , "TARGET" },
{   75 , "W" ,  2 , "RETADDR"},
{   77 , "B" ,  1 , "BANKM"  },  // 'B'yte (8bit)
{   78 , "B" ,  1 , "RAMRST" },
{   79 , "B" ,  1 , "RAMERR" },
{   81 , "W" ,  2 , "BAUD"   },
{   83 , "B" ,  2 , "SERFL"  },
{   85 , "B" ,  1 , "COL"    },
{   86 , "B" ,  1 , "WIDTH"  },
{   87 , "B" ,  1 , "TVPARS" },
{   88 , "F" ,  1 , "FLAGS3" }, // 'F'lag
{   89 , "B" ,  1 , "BANK678"},
{   90 , "B" ,  1 , "XLOC"   },
{   91 , "B" ,  1 , "YLOC"   },
{   92 , "W" ,  2 , "OLDSP"  },
{   94 , "W" ,  2 , "SYNRET" },
{   96 , "B" ,  5 , "LASTV"  },
{  101 , "W" ,  2 , "RCLINE" },
{  103 , "W" ,  2 , "RCSTART"},
{  105 , "W" ,  2 , "RCSTEP" },
{  107 , "C" ,  1 , "LODDRV" }, // 'C'haracter "A", "B", "M" or "T"
{  108 , "C" ,  1 , "SAVDRV" },
{  109 , "B" ,  1 , "DUMPLF" },
{  110 , "B" ,  8 , "STRIP1" },
{  118 , "B" ,  8 , "STRIP2" },
{  126 , "B" ,115 , "TSPACE" },
{  241 , "B" ,  1 , "TSTACK" }, // OFset 240 or 241 ??? top of stack !!
};
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

Hi
i got stuck in this routine since i tried to do it all in 1 piece, which is more blocking then helping me. Another thing is that the apraoch in ZX is different then in an eg emulator. The zx routine is way to big to be functional inside an zx, its 20KB !! and has an overload off data, correct ??

so i first have to make to structures as a separate file, which worked with out pointers and without errors.
i do this pragmatisch (in the human way) and wrote 3 files to create a binay structure

Code: Select all

// https://www.geeksforgeeks.org/readwrite-structure-file-c/

// gcc struct_sysvar48.c -o struct_sysvar48 -lm  2> struct_sysvar48.log  // '2>' redirect

// C program for writing
// struct to file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// a struct to read and write
struct sysvar
{
     unsigned short int offset;
     unsigned       char typebyte[1];
     unsigned short int nbyte;
     unsigned       char sysvarname[8];
};
 
int main ()
{
    FILE *outfile;
     
    // open file for writing
    outfile = fopen ("sysvar48.struct", "w");
    if (outfile == NULL)
    {
        fprintf(stderr, "\nError opened file\n");
        exit (1);
    }

    struct sysvar input1  = {23552, "O"  , 73 , "SYS48"   };
    struct sysvar input2  = {  0  , "B"  , 8  , "KSTATE"  };
    struct sysvar input3  = {  8  , "B"  , 1  , "LASTK"   };
    struct sysvar input4  = {  9  , "B"  , 1  , "REPDEL"  };
    struct sysvar input5  = { 10  , "B"  , 1  , "REPPER"  };
    struct sysvar input6  = { 11  , "W"  , 2  , "DEFADD"  };
    struct sysvar input7  = { 13  , "B"  , 1  , "K_DATA"  };
    struct sysvar input8  = { 14  , "B"  , 2  , "TVDATA"  };
    struct sysvar input9  = { 16  , "W"  , 38 , "STRMS"   };  // 0xff to 0x0f aka -3 to +15 stream adresses
    struct sysvar input10 = { 54  , "W"  , 2  , "CHARS"   };
    struct sysvar input11 = { 56  , "B"  , 1  , "RASP"    };
    struct sysvar input12 = { 57  , "B"  , 1  , "PIP"     };
    struct sysvar input13 = { 58  , "B"  , 1  , "ERRNR"   };
    struct sysvar input14 = { 59  , "F"  , 1  , "FLAGS"   };
    struct sysvar input15 = { 60  , "F"  , 1  , "TVFLAG"  };
    struct sysvar input16 = { 61  , "W"  , 2  , "ERRSP"   };
    struct sysvar input17 = { 63  , "W"  , 2  , "LISTSP"  };
    struct sysvar input18 = { 65  , "C"  , 1  , "MODE"    };  // "K", "L", "C", "E" or "G" cursor aka character value of input-mode
    struct sysvar input19 = { 66  , "W"  , 2  , "NEWPPC"  };
    struct sysvar input20 = { 68  , "B"  , 1  , "NSPPC"   };
    struct sysvar input21 = { 69  , "W"  , 2  , "PPC"     };
    struct sysvar input22 = { 71  , "B"  , 1  , "SUBPPC"  };
    struct sysvar input23 = { 72  , "B"  , 1  , "BORDCR"  };
    struct sysvar input24 = { 73  , "W"  , 2  , "E_PPC"   };
    struct sysvar input25 = { 75  , "W"  , 2  , "VARS"    };
    struct sysvar input26 = { 77  , "W"  , 2  , "DEST"    };
    struct sysvar input27 = { 79  , "W"  , 2  , "CHANS"   };
    struct sysvar input28 = { 81  , "W"  , 2  , "CURCHL"  };
    struct sysvar input29 = { 83  , "W"  , 2  , "PROG"    };
    struct sysvar input30 = { 85  , "W"  , 2  , "NXTLIN"  };
    struct sysvar input31 = { 87  , "W"  , 2  , "DATADD"  };
    struct sysvar input32 = { 89  , "W"  , 2  , "E_LINE"  };
    struct sysvar input33 = { 91  , "W"  , 2  , "KCUR"    };
    struct sysvar input34 = { 93  , "W"  , 2  , "CH_ADD"  };
    struct sysvar input35 = { 95  , "W"  , 2  , "XPTR"    };
    struct sysvar input36 = { 97  , "W"  , 2  , "WORKSP"  };
    struct sysvar input37 = { 99  , "W"  , 2  , "STKBOT"  };
    struct sysvar input38 = { 101 , "W"  , 2  , "STKEND"  };
    struct sysvar input39 = { 103 , "B"  , 1  , "BREG"    };
    struct sysvar input40 = { 104 , "W"  , 2  , "MEM"     };
    struct sysvar input41 = { 106 , "F"  , 1  , "FLAGS2"  };
    struct sysvar input42 = { 107 , "B"  , 1  , "DF_SZ"   };
    struct sysvar input43 = { 108 , "W"  , 2  , "S_TOP"   };
    struct sysvar input44 = { 110 , "W"  , 2  , "OLDPPC"  };
    struct sysvar input45 = { 112 , "B"  , 1  , "OSPPC"   };
    struct sysvar input46 = { 113 , "F"  , 1  , "FLAGX"   };
    struct sysvar input47 = { 114 , "W"  , 2  , "STRLEN"  };
    struct sysvar input48 = { 116 , "W"  , 2  , "TADDR"   };
    struct sysvar input49 = { 118 , "W"  , 2  , "SEED"    };
    struct sysvar input50 = { 120 , "T"  , 3  , "FRAMES"  };  // UNSIGNED LONG CLOCK ;
    struct sysvar input51 = { 123 , "W"  , 2  , "UDG"     };
    struct sysvar input52 = { 125 , "B"  , 1  , "COORDS"  };  // COORDX
    struct sysvar input53 = { 126 , "B"  , 1  , "COORDSY" };  // COORDY
    struct sysvar input54 = { 127 , "B"  , 1  , "P_POSN"  };
    struct sysvar input55 = { 128 , "W"  , 2  , "PRCC"    };
    struct sysvar input56 = { 130 , "B"  , 1  , "ECHO_E"  };
    struct sysvar input57 = { 131 , "B"  , 1  , "ECHO_EY" };
    struct sysvar input58 = { 132 , "W"  , 2  , "DF_CC"   };
    struct sysvar input59 = { 134 , "W"  , 2  , "DF_CCL"  };
    struct sysvar input60 = { 136 , "B"  , 1  , "S_POSN"  };
    struct sysvar input61 = { 137 , "B"  , 1  , "S_POSNY" };
    struct sysvar input62 = { 138 , "B"  , 1  , "S_POSNL" };
    struct sysvar input63 = { 139 , "B"  , 1  , "S_POSNLY"};
    struct sysvar input64 = { 140 , "B"  , 1  , "SCR_CT"  };
    struct sysvar input65 = { 141 , "F"  , 1  , "ATTR_P"  };  // FBPPPIII
    struct sysvar input66 = { 142 , "F"  , 1  , "MASK_P"  };  // FBPPPIII
    struct sysvar input67 = { 143 , "F"  , 1  , "ATTR_T"  };  // FBPPPIII
    struct sysvar input68 = { 144 , "F"  , 1  , "MASK_T"  };  // FBPPPIII
    struct sysvar input69 = { 145 , "F"  , 1  , "P_FLAG"  };
    struct sysvar input70 = { 146 , "B"  , 30 , "MEMBOT"  };  // 05 X 06 = 30 ADRESSES
    struct sysvar input71 = { 176 , "W"  , 2  , "NMIADD"  };
    struct sysvar input72 = { 178 , "W"  , 2  , "RAMTOP"  };
    struct sysvar input73 = { 180 , "W"  , 2  , "P_RAMT"  };

    // write struct to file
    fwrite (&input1 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input2 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input3 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input4 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input5 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input6 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input7 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input8 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input9 , sizeof(struct sysvar), 1, outfile);
    fwrite (&input10, sizeof(struct sysvar), 1, outfile);
    fwrite (&input11, sizeof(struct sysvar), 1, outfile);
    fwrite (&input12, sizeof(struct sysvar), 1, outfile);
    fwrite (&input13, sizeof(struct sysvar), 1, outfile);
    fwrite (&input14, sizeof(struct sysvar), 1, outfile);
    fwrite (&input15, sizeof(struct sysvar), 1, outfile);
    fwrite (&input16, sizeof(struct sysvar), 1, outfile);
    fwrite (&input17, sizeof(struct sysvar), 1, outfile);
    fwrite (&input18, sizeof(struct sysvar), 1, outfile);
    fwrite (&input19, sizeof(struct sysvar), 1, outfile);
    fwrite (&input20, sizeof(struct sysvar), 1, outfile);
    fwrite (&input21, sizeof(struct sysvar), 1, outfile);
    fwrite (&input22, sizeof(struct sysvar), 1, outfile);
    fwrite (&input23, sizeof(struct sysvar), 1, outfile);
    fwrite (&input24, sizeof(struct sysvar), 1, outfile);
    fwrite (&input25, sizeof(struct sysvar), 1, outfile);
    fwrite (&input26, sizeof(struct sysvar), 1, outfile);
    fwrite (&input27, sizeof(struct sysvar), 1, outfile);
    fwrite (&input28, sizeof(struct sysvar), 1, outfile);
    fwrite (&input29, sizeof(struct sysvar), 1, outfile);
    fwrite (&input30, sizeof(struct sysvar), 1, outfile);
    fwrite (&input31, sizeof(struct sysvar), 1, outfile);
    fwrite (&input32, sizeof(struct sysvar), 1, outfile);
    fwrite (&input33, sizeof(struct sysvar), 1, outfile);
    fwrite (&input34, sizeof(struct sysvar), 1, outfile);
    fwrite (&input35, sizeof(struct sysvar), 1, outfile);
    fwrite (&input36, sizeof(struct sysvar), 1, outfile);
    fwrite (&input37, sizeof(struct sysvar), 1, outfile);
    fwrite (&input38, sizeof(struct sysvar), 1, outfile);
    fwrite (&input39, sizeof(struct sysvar), 1, outfile);
    fwrite (&input40, sizeof(struct sysvar), 1, outfile);
    fwrite (&input41, sizeof(struct sysvar), 1, outfile);
    fwrite (&input42, sizeof(struct sysvar), 1, outfile);
    fwrite (&input43, sizeof(struct sysvar), 1, outfile);
    fwrite (&input44, sizeof(struct sysvar), 1, outfile);
    fwrite (&input45, sizeof(struct sysvar), 1, outfile);
    fwrite (&input46, sizeof(struct sysvar), 1, outfile);
    fwrite (&input47, sizeof(struct sysvar), 1, outfile);
    fwrite (&input48, sizeof(struct sysvar), 1, outfile);
    fwrite (&input49, sizeof(struct sysvar), 1, outfile);
    fwrite (&input50, sizeof(struct sysvar), 1, outfile);
    fwrite (&input51, sizeof(struct sysvar), 1, outfile);
    fwrite (&input52, sizeof(struct sysvar), 1, outfile);
    fwrite (&input53, sizeof(struct sysvar), 1, outfile);
    fwrite (&input54, sizeof(struct sysvar), 1, outfile);
    fwrite (&input55, sizeof(struct sysvar), 1, outfile);
    fwrite (&input56, sizeof(struct sysvar), 1, outfile);
    fwrite (&input57, sizeof(struct sysvar), 1, outfile);
    fwrite (&input58, sizeof(struct sysvar), 1, outfile);
    fwrite (&input59, sizeof(struct sysvar), 1, outfile);
    fwrite (&input60, sizeof(struct sysvar), 1, outfile);
    fwrite (&input61, sizeof(struct sysvar), 1, outfile);
    fwrite (&input62, sizeof(struct sysvar), 1, outfile);
    fwrite (&input63, sizeof(struct sysvar), 1, outfile);
    fwrite (&input64, sizeof(struct sysvar), 1, outfile);
    fwrite (&input65, sizeof(struct sysvar), 1, outfile);
    fwrite (&input66, sizeof(struct sysvar), 1, outfile);
    fwrite (&input67, sizeof(struct sysvar), 1, outfile);
    fwrite (&input68, sizeof(struct sysvar), 1, outfile);
    fwrite (&input69, sizeof(struct sysvar), 1, outfile);
    fwrite (&input70, sizeof(struct sysvar), 1, outfile);
    fwrite (&input71, sizeof(struct sysvar), 1, outfile);
    fwrite (&input72, sizeof(struct sysvar), 1, outfile);
    fwrite (&input73, sizeof(struct sysvar), 1, outfile);

    if(fwrite != 0)
        printf("contents to file written successfully !\n");
    else
        printf("error writing file !\n");
 
    // close file
    fclose (outfile);
 
    return 0;
}

if i check the struct in GHEX i see 1 colomn i done NOT understand
it looks like an extra colomn right after the type character, eg 'O' , its the colom with the blue mark
Image
maybe i am to fast, i still have to (re)write that viewer!
and maybe a "structwritter" that can use a separate file as input., put 1 step at a time, i will try so.
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

the links to my momentary 'sysvar struct builders' (edit time is to short, realy)

http://www.cborn.nl/c/struct_sysvar128.c
http://www.cborn.nl/c/struct_sysvar48.c
http://www.cborn.nl/c/struct_sysvarIF1.c
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

i changed the picture
its the 4th byte 0x56 which has nothing to do there according to me.
char typebyte[1] gives the correct character plus someting else
while typing this i think to my self "why unsigned char" and i removed it , but does not change
cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

another attempt to write a more common "sysvar struct writer"
its still a single write but its closer to that common writer i want
next step is to fetch an external file, but the amount of entries must be given aswell!!!
now
int amount=73;

so still WIP but a bit better, although not very special =D

Code: Select all

// https://www.geeksforgeeks.org/readwrite-structure-file-c/

// gcc struct_sysvar48.c -o struct_sysvar48 -lm  2> struct_sysvar48.log  // '2>' redirect

// C program for writing (zx spectrum) system variable structures from TXT to a binairy STRUCT
// struct to file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main ()
{
    FILE *outfile;
    int x ;

    printf("makes:\nstruct sysvar\n {\n   unsigned short int offset;\n /*unsigned*/     char typechar[2];\n   unsigned short int nbyte;\n /*unsigned*/     char sysvarname[11];\n }\n  //{     , ""   ,    , ""        }\n");


    // open file for writing
    outfile = fopen ("sysvar48.struct", "w");
    if (outfile == NULL)
    {
        fprintf(stderr, "\nError opened file\n");
        exit (1);
    }

// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+
// can i change this into a external readable file ??
// a struct to read and write
   int amount=73 ;
   struct sysvar
   {
     unsigned short int offset;
   /*unsigned*/     char typechar[2];
     unsigned short int nbyte;
   /*unsigned*/     char sysvarname[11];
   }
   sysvar[]= {                           //[amount] is not accepted
   {23552, "O",amount, "SYS48"   },
   {  0  , "B"  , 8  , "KSTATE"  },
   {  8  , "B"  , 1  , "LASTK"   },
   {  9  , "B"  , 1  , "REPDEL"  },
   { 10  , "B"  , 1  , "REPPER"  },
   { 11  , "W"  , 2  , "DEFADD"  },
   { 13  , "B"  , 1  , "K_DATA"  },
   { 14  , "B"  , 2  , "TVDATA"  },
   { 16  , "W"  , 38 , "STRMS"   },  // 0xff to 0x0f aka -3 to +15 stream addresses
   { 54  , "W"  , 2  , "CHARS"   },
   { 56  , "B"  , 1  , "RASP"    },
   { 57  , "B"  , 1  , "PIP"     },
   { 58  , "B"  , 1  , "ERRNR"   },
   { 59  , "F"  , 1  , "FLAGS"   },
   { 60  , "F"  , 1  , "TVFLAG"  },
   { 61  , "W"  , 2  , "ERRSP"   },
   { 63  , "W"  , 2  , "LISTSP"  },
   { 65  , "C"  , 1  , "MODE"    },  // "K", "L", "C", "E" or "G" cursor aka character value of input-mode
   { 66  , "W"  , 2  , "NEWPPC"  },
   { 68  , "B"  , 1  , "NSPPC"   },
   { 69  , "W"  , 2  , "PPC"     },
   { 71  , "B"  , 1  , "SUBPPC"  },
   { 72  , "B"  , 1  , "BORDCR"  },
   { 73  , "W"  , 2  , "E_PPC"   },
   { 75  , "W"  , 2  , "VARS"    },
   { 77  , "W"  , 2  , "DEST"    },
   { 79  , "W"  , 2  , "CHANS"   },
   { 81  , "W"  , 2  , "CURCHL"  },
   { 83  , "W"  , 2  , "PROG"    },
   { 85  , "W"  , 2  , "NXTLIN"  },
   { 87  , "W"  , 2  , "DATADD"  },
   { 89  , "W"  , 2  , "E_LINE"  },
   { 91  , "W"  , 2  , "KCUR"    },
   { 93  , "W"  , 2  , "CH_ADD"  },
   { 95  , "W"  , 2  , "XPTR"    },
   { 97  , "W"  , 2  , "WORKSP"  },
   { 99  , "W"  , 2  , "STKBOT"  },
   { 101 , "W"  , 2  , "STKEND"  },
   { 103 , "B"  , 1  , "BREG"    },
   { 104 , "W"  , 2  , "MEM"     },
   { 106 , "F"  , 1  , "FLAGS2"  },
   { 107 , "B"  , 1  , "DF_SZ"   },
   { 108 , "W"  , 2  , "S_TOP"   },
   { 110 , "W"  , 2  , "OLDPPC"  },
   { 112 , "B"  , 1  , "OSPPC"   },
   { 113 , "F"  , 1  , "FLAGX"   },
   { 114 , "W"  , 2  , "STRLEN"  },
   { 116 , "W"  , 2  , "TADDR"   },
   { 118 , "W"  , 2  , "SEED"    },
   { 120 , "T"  , 3  , "FRAMES"  },  // 'T' 24bit UNSIGNED LONG CLOCK ;
   { 123 , "W"  , 2  , "UDG"     },
   { 125 , "B"  , 1  , "COORDS"  },  // COORDX
   { 126 , "B"  , 1  , "COORDSY" },  // COORDY
   { 127 , "B"  , 1  , "P_POSN"  },
   { 128 , "W"  , 2  , "PRCC"    },
   { 130 , "B"  , 1  , "ECHO_E"  },
   { 131 , "B"  , 1  , "ECHO_EY" },
   { 132 , "W"  , 2  , "DF_CC"   },
   { 134 , "W"  , 2  , "DF_CCL"  },
   { 136 , "B"  , 1  , "S_POSN"  },
   { 137 , "B"  , 1  , "S_POSNY" },
   { 138 , "B"  , 1  , "S_POSNL" },
   { 139 , "B"  , 1  , "S_POSNLY"},
   { 140 , "B"  , 1  , "SCR_CT"  },
   { 141 , "F"  , 1  , "ATTR_P"  },  // FBPPPIII
   { 142 , "F"  , 1  , "MASK_P"  },  // FBPPPIII
   { 143 , "F"  , 1  , "ATTR_T"  },  // FBPPPIII
   { 144 , "F"  , 1  , "MASK_T"  },  // FBPPPIII
   { 145 , "F"  , 1  , "P_FLAG"  },
   { 146 , "B"  , 30 , "MEMBOT"  },  // 05 X 06 = 30 ADDRESSES
   { 176 , "W"  , 2  , "NMIADD"  },
   { 178 , "W"  , 2  , "RAMTOP"  },
   { 180 , "W"  , 2  , "P_RAMT"  },
   };
// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+


    while( x<amount )
           { fwrite (&sysvar[x] , sizeof(struct sysvar), 1, outfile ) ;
            x++;
           }

   if(x = amount)
        printf("%d contents to file written successfully !\n", amount);
    else
        printf("error writing file !\n");
 
    // close file
    fclose (outfile);
 
    return 0;
}

cborn
Well known member
Posts: 267
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

i DID manage to use the result in an external struct reader
and i did make a 2byte string from the charactr and the varname is 10+1 length

Code: Select all

// https://www.geeksforgeeks.org/readwrite-structure-file-c/

// gcc read_struct_sysvar.c -o read_struct_sysvar -lm  2> read_struct_sysvar.log  // '2>' redirect

// C program for reading
// struct from a file
#include <stdio.h>
#include <stdlib.h>
 
// struct sysvar with 4 fields
struct sysvar
{
     unsigned short int offset;
   /*unsigned*/     char typechar[2];  //whats up duck? why 2bytes and why [1]
     unsigned short int nbyte;
   /*unsigned*/     char sysvarname[11];
};
 
// Driver program
int main (int argc, char *argv[])
{
    FILE *infile ;
    unsigned short int offset, nbyte ;
    int start, sysvarlength ;
    char  typechar,  sysvarname[8] ;
    if (argc < 2 ) {
        fprintf(stdout,"Usage: %s [struct file] [struct file] .. \n",argv[0]);
        exit(1);
    }

//make a for next or while for multiple files

    if ( (infile=fopen(argv[1],"rb") ) == NULL ) {
        printf("Can't open input file\n");
        exit(1);
    }

    struct sysvar input;

    // Open sysvar.struct for reading
    infile = fopen (argv[1], "r");
    if (infile == NULL)
    {
        fprintf(stderr, "\nError opening file\n");
        exit (1);
    }

//    fseek(infile, 0, SEEK_SET);
    
    printf ("found:\n");      // read file contents till end of file
    while(fread(&input, sizeof(struct sysvar), 1, infile))
          printf ("%d '%s' %d %s\n", input.offset, input.typechar, input.nbyte, input.sysvarname);
 
    // close file
    fclose (infile);
 
    return 0;
}
result:

Code: Select all

 ./read_struct_sysvar sysvar48.struct
found:
23552 'O' 73 SYS48
0 'B' 8 KSTATE
8 'B' 1 LASTK
9 'B' 1 REPDEL
10 'B' 1 REPPER
11 'W' 2 DEFADD
13 'B' 1 K_DATA
14 'B' 2 TVDATA
16 'W' 38 STRMS
54 'W' 2 CHARS
56 'B' 1 RASP
57 'B' 1 PIP
58 'B' 1 ERRNR
59 'F' 1 FLAGS
60 'F' 1 TVFLAG
61 'W' 2 ERRSP
63 'W' 2 LISTSP
65 'C' 1 MODE
66 'W' 2 NEWPPC
68 'B' 1 NSPPC
69 'W' 2 PPC
71 'B' 1 SUBPPC
72 'B' 1 BORDCR
73 'W' 2 E_PPC
75 'W' 2 VARS
77 'W' 2 DEST
79 'W' 2 CHANS
81 'W' 2 CURCHL
83 'W' 2 PROG
85 'W' 2 NXTLIN
87 'W' 2 DATADD
89 'W' 2 E_LINE
91 'W' 2 KCUR
93 'W' 2 CH_ADD
95 'W' 2 XPTR
97 'W' 2 WORKSP
99 'W' 2 STKBOT
101 'W' 2 STKEND
103 'B' 1 BREG
104 'W' 2 MEM
106 'F' 1 FLAGS2
107 'B' 1 DF_SZ
108 'W' 2 S_TOP
110 'W' 2 OLDPPC
112 'B' 1 OSPPC
113 'F' 1 FLAGX
114 'W' 2 STRLEN
116 'W' 2 TADDR
118 'W' 2 SEED
120 'T' 3 FRAMES
123 'W' 2 UDG
125 'B' 1 COORDS
126 'B' 1 COORDSY
127 'B' 1 P_POSN
128 'W' 2 PRCC
130 'B' 1 ECHO_E
131 'B' 1 ECHO_EY
132 'W' 2 DF_CC
134 'W' 2 DF_CCL
136 'B' 1 S_POSN
137 'B' 1 S_POSNY
138 'B' 1 S_POSNL
139 'B' 1 S_POSNLY
140 'B' 1 SCR_CT
141 'F' 1 ATTR_P
142 'F' 1 MASK_P
143 'F' 1 ATTR_T
144 'F' 1 MASK_T
145 'F' 1 P_FLAG
146 'B' 30 MEMBOT
176 'W' 2 NMIADD
178 'W' 2 RAMTOP
180 'W' 2 P_RAMT

so its a structure fixed to

Code: Select all

   struct sysvar
   {
     unsigned short int offset;
   /*unsigned*/     char typechar[2];
     unsigned short int nbyte;
   /*unsigned*/     char sysvarname[11];
   }
Post Reply