ASCII to Binary and Binary to ASCII Translator

Emu48 can't import programs transferred via ASCII mode.  This System 
RPL program will take the string that Emu48 puts on the stack when the 
program was originally transferred in ASCII mode and will convert it 
to a binary.  If the header exists the settings will set accordingly, 
and if any comments exist it will remove them.  If you are loading a 
text file rather than a program, this will simply remove the carriage 
returns so there is nothing but line feeds.  If you give it a binary 
program rather than a text file, it will convert it to a text file, 
making it suitable for exporting from Emu48.  Remember that Emu48 adds 
a 13-byte HPHP48-W header to the beginning that must be removed when 
exporting ASCII files.

Simple directions:
1. Load emu48asc.bin into Emu48 with the Edit-Load Object... command
2. STO it in a variable
3. Load the file you want to translate
4. Run this program with the VAR menu softkey
5. STO the translated program in a variable (if wanted) or export it 
   with the Edit-Save Object... command

This can also be used on a real HP48 if you prefer to transfer ASCII 
files via Xmodem, which doesn't do translation.  However, it will be 
very slow.

In order for this program to work properly, flag -55 (LASTARG) must 
be enabled.  If it is disabled, simply type -55 CF to re-enable it.

Because I combined both importing and exporting into a single program, 
this only works maybe 90% of the time.  If you would prefer two 
separate programs which, when combined, work 95% of the time, load 
emu48asc.dir instead.  This would be best, for example, when exporting 
a string, such as System RPL or assembly language source code.

Unfortunately, this program sometimes fails on directories.  I'm not 
entirely sure why it doesn't work (since it properly imports some 
directories) and don't have a solution at present.  For these pesky 
directories, you'll have to use your real HP48.

The commented System RPL source code is in emu48asc.src.  This uses 
two unsupported entry points, PTR 30477 and PTR 303AC, but they appear 
stable and have been tested to work in revisions D, M, P, and R.

Program created by Eric Rechlin <eric@hpcalc.org> based on posts to 
comp.sys.hp48 by John H Meyers <jhmeyers@mum.edu>.  I would also like 
to thank Christoph Gisselink for optimizing my program, saving about 
20 bytes.

Revision 1.3, see http://www.hpcalc.org for updates.