Hi Norman,
Yes, you can get HPGCC to generate programs for a 48gii! If you do, then you and I will probably be the only people on the planet to have done it successfully. Here is how you do it:
First, you need HPGCC version 1.1. You can get it from the
sourceforge page here
Install HPGCC 1.1 on your computer. In the rest of this message, I've assumed that you installed it into c:\arm-hp.
I had to add c:\arm-hp\libexec\gcc\arm-elf\3.4.6 to my path so the
compiler could find cc1.exe. I'm not sure if that was a problem with my installation. To make this easy, I created the following file called env.bat in the directory where I installed hpgcc (c:\arm-hp):
set HPGCC=C:\HPGCC1-1
PATH %HPGCC%\bin;%HPGCC%\libexec\gcc\arm-elf\3.4.6;%HPGCC%\arm-elf\bin;%PATH%
The sat_createtemp() function that comes with HPGCC 1.1 doesn't work properly so you need to replace it with the one from HPGCC2.0 and rebuild the libraries. Here is the replacement file:
// These functions replace sat_create_tempob() in HPGCC 1.1. They are taken
// from HPGCC 2.0. The ones in 1.1 don't work with the 48gii.
// Copy this file over c:\hp-arm\sources\hplib\saturn\sat_createtemp.c
// and then rebuild the library.
#include <hpgcc49.h>
unsigned int
sat_map_a2s(unsigned int arm_addr)
{
int f;
unsigned int a=arm_addr&0xfffff800;
for(f=0;f<256;++f) {
if(_saturn_cpu->Read[f]==a) return (f<<12)+((arm_addr&0x7ff)<<1);
}
return 0xffffffff;
}
// AUXILIARY FUNCTION
// FINDS PAGE CLOSEST TO RSKTOP USED BY HPGCC
// RETURN 0xffffffff IF NONE.
unsigned __find_main_ram_start(int rsktop)
{
int f;
extern unsigned _mmu_table_addr,_mmu_table_entries;
int *ptr=(int *)_mmu_table_addr;
int minaddr=sat_map_s2a(rsktop);
unsigned int page=0xffffffff,a;
for(f=0;f<_mmu_table_entries;++f) {
a=ptr[f]&0xfffff000;
if(a>minaddr && a<page) page=a;
}
return page;
}
// AUXILIARY FUNCTION, RETURNS THE AMOUNT OF USEABLE TEMPOB IN NIBBLES
int sat_getfreetempob()
{
int rstk=sat_peek(SAT_RSKTOP,5);
int freeend;
freeend=__find_main_ram_start(rstk);
if(freeend==0xffffffff) {
// C PROGRAM IS NOT USING MAIN RAM
return sat_peek(SAT_DSKTOP,5)-rstk-11;
}
freeend=sat_map_a2s(freeend);
return freeend-rstk-11;
}
int
sat_createtemp(int objsize)
{
// CREATETEMP IMPLEMENTATION
// objsize=size of object including prolog
// in nibbles
int ttop=sat_peek(SAT_TEMPTOP,5);
int rstk=sat_peek(SAT_RSKTOP,5);
int size=rstk-ttop;
int freemem;
int ptr;
// check for enough room here
if(objsize>sat_getfreetempob()) {
// insufficient memory to create object
return 0;
}
// make room in memory
sat_moveup(ttop,ttop+objsize+6,size);
// adjust tempob chain
ptr=ttop+1+objsize;
sat_poke(ptr,objsize+6,5);
// adjust pointers
// RSKTOP
sat_poke(SAT_RSKTOP,sat_peek(SAT_RSKTOP,5)+objsize+6,5);
// TEMPTOP
sat_poke(SAT_TEMPTOP,sat_peek(SAT_TEMPTOP,5)+objsize+6,5);
// adjust free memory
freemem=sat_peek(SAT_DSKTOP,5)-sat_peek(SAT_RSKTOP,5);
freemem/=5;
sat_poke(SAT_AVMEM,freemem,5);
// return addr to prolog of new object
return ttop+1;
}
Copy the above text into c:\arm-hp\sources\hplib\Saturn\sat_createtemp.c, replacing the existing file.
Edit c:\arm-hp\sources\hplib\hpmath.h and replace this line:
#define _fabs(x) ( (x) < 0.0 ? (-x) : (x) )
with this:
#define _fabs(x) ( (x) < 0.0 ? -(x) : (x) )
also replace this:
#define abs(a) ((a) < 0 ? (-a) : (a))
with this:
#define abs(a) ((a) < 0 ? -(a) : (a))
Now rebuild the libraries as follows:
- Start a command window.
- Cd c:\arm-hp\
- Run env.bat to set up environment variables to use hpgcc
- Cd c:\arm-hp\sources\hplib
- Type “make clean”
- Type “make”. This will rebuild the libraries, including the new copy of sat_createtemp.c
- Type “make install” to copy the new version of libhplib.a to the right place.
There are separate versions of the ARMToolbox for the HP48 and HP 49.
You need to install c:\arm-hp\ARMToolbox\LIB275-48.lib on your calculator. Note that
you'll want to rename this library first because LIB275-48.LIB is an
invalid variable name on the calculator.
It looks like the ArmToolbox's "S->exe" command isn't supported on the 48gii. You can only run programs via the PrRUN command. This means you can't create stand-alone programs on the HP48 - they require the ARMToolbox to be installed.