[comp.sys.apple2] Help with FWEntry and Orca C 1.1

araftis@polyslo.CalPoly.EDU (Alex Raftis) (11/04/90)

I've been haveing some problems with trying to get FWEntry to work with Orca
C 1.1. Included at the end of this article are some fragments of code that I
use to call FWEntry. Basically, it's trying to access the serial port firm-
ware to increase throughput over GSOS. I've written similar code that works
well under TML Pascal (but I prefer to work in C). I've also tried running 
this when linked with the standard and "bugfix" (recently posted) libraries.
Basically what happens is, depite the fact that the printf shows I should be
sending all the correct data, the program calls FWEntry and then crashes to
GSBug. If I go to the monitor, I can miniassembler a code fragment that
basically make the same call in ML, and it works fine, so I doubt it's the
firmware. Any input would be appreciated.

#pragma keep "modem"

#include <stdio.h>
#include <stdlib.h>
#include <types.h>
#include <misctool.h>
#include "modem.h"

MODEM *StartUpModem(int portnum)
{
   long     baseaddr;
   MODEM    *m;

   if ((portnum < 0) || (portnum > 7)) return(0);
   m = (MODEM *)malloc(sizeof(MODEM));
   if (!m) return(0);

   baseaddr = 0x00E1C000 | portnum << 8;
   printf("%06lX\n", baseaddr);
   m->port = portnum;
   m->init    = baseaddr + *(byte *)(baseaddr + 0x0D);
   printf("   init = %06lX\n", m->init);
   m->read    = baseaddr + *(byte *)(baseaddr + 0x0E);
   printf("   read = %06lX\n", m->read);
   m->write   = baseaddr + *(byte *)(baseaddr + 0x0F);
   printf("  write = %06lX\n", m->write);
   m->status  = baseaddr + *(byte *)(baseaddr + 0x10);
   printf(" status = %06lX\n", m->status);
   m->control = baseaddr + *(byte *)(baseaddr + 0x12);
   printf("control = %06lX\n", m->control);
   m->baud = BAUD_2400;
   m->data = DATA8_STOP1;
   m->parity = PARITY_NONE;
   m->linelen = 0;
   m->format = FALSE;
   m->xonxoff = FALSE;
   m->lfcr = FALSE;
   m->echo = FALSE;
   m->masklf = TRUE;
   m->buffer = TRUE;
   return(m);
}

void InitModem(MODEM *m)
{
   FWRec    r;

   printf("%d\n", m->port);
   printf("%04X %04X %04X %04X\n", (int)0, (int)(0xC0 | m->port), (int)(m->port << 4), (int)(m->init));
   r = FWEntry((int)0, (int)(0xC0 | m->port), (int)(m->port << 4), (int)(m->init));
   printf("%04X %04X %04X %04X\n", r.yRegExit, r.xRegExit, r.aRegExit, r.status);
}

(addional code deleted)



-- 
               -------------------------------------------------- 
                     Internet: araftis@polyslo.CalPoly.EDU
               America Online: xela      (Real Life: Alex Raftis)