looking for sysvar list

ZX80, ZX 81, ZX Spectrum, TS2068 and other clones
Post Reply
cborn
Member
Posts: 81
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
Member
Posts: 81
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
Member
Posts: 81
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
Member
Posts: 81
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: 1477
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
Member
Posts: 81
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
Member
Posts: 81
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
Member
Posts: 81
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: 1477
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
Member
Posts: 81
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
Member
Posts: 81
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
Member
Posts: 81
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
Member
Posts: 81
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
Member
Posts: 81
Joined: Tue Oct 06, 2020 7:45 pm

Re: looking for sysvar list

Post by cborn »

cborn
Member
Posts: 81
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 !!
};
Post Reply