stein@rocksanne.UUCP (Adam Stein) (12/03/87)
The TRSDOS command MEMORY won't allow you to set the high memory pointer
higher than the current setting, so I wrote this. It was written with
Aztec C but the comments should provide enough information about the
Aztec specifics for someone to change it to another compiler. The
comments also describe the use.
Adam Stein
rutgers!rochester!rocksanne!stein
-----cut here----------cut here----------cut here----------cut here-----
/*Program to set the high memory pointer or display it's current setting.
Sethigh without arguments shows the high memory pointer's current
setting (i.e. sethigh). An optional high memory pointer can be given
in decimal (i.e. sethigh 54000) or in hex (i.e. sethigh -x ff00) using
the '-x' option. Any errors in the arguments produces the usage
message.
Written to get around the problem of the restriction in the dos call
MEMORY that specifies that the new value for high must be lower than
the current setting.
Written using Aztec C v1.06A.
Specific aztec functions:
svc [svc(code,bc,de,hl)] - used to call a TRSDOS SVC. The first
argument is the SVC number, the last
3 arguments fill the BC, DE, and HL
registers, respectively. If the SVC
returns with the Z flag set, svc()
returns 0, otherwise it returns the
value in the A register.
svchl [svchl(code,bc,de,hl)] - Same as svc() except that if the Z flag
is set on return from the SVC, svchl()
returns the value in the HL register,
otherwise, it returns 0.
Specific aztec constants:
S_ERROR - the SVC number for the error SVC (26).
S_HIGH - the SVC number the the high SVC (100).
Written by Adam Stein (12/02/87).
*/
#include "stdio/h"
#include "ctype/h"
#include "trs4/h"
unsigned int high_memory;
main(argc,argv)
register int argc;
register char *argv[];
{
register int error;
getargs(argc,argv);
if(!high_memory) { /*No high value given, show current setting*/
high_memory = svchl(S_HIGH,0,0,0);
printf("High memory is set to 0x%x (%u)\n",high_memory,high_memory);
} else
if((error = svc(S_HIGH,0,0,high_memory)))
svc(S_ERROR,error | 192,0,0);
}
getargs(argc,argv)
register int argc;
register char *argv[];
{
high_memory = 0;
if(argc > 1)
if(argc > 3) {
fputs("usage: sethigh [[-x] high]\n",stderr);
exit(-1);
} else switch(argc) {
case 2:
if(!isdigit(argv[1][0]) ||
!sscanf(argv[1],"%d",&high_memory)) {
fputs("usage: sethigh [[-x] high]\n",stderr);
exit(-1);
}
break;
case 3:
if(strcmp("-x",argv[1])) {
fputs("usage: sethigh [[-x] high]\n",stderr);
exit(-1);
} else if(!sscanf(argv[2],"%x",&high_memory)) {
fputs("usage: sethigh [[-x] hex_high]\n",stderr);
exit(-1);
}
break;
}
}
-----cut here----------cut here----------cut here----------cut here-----