static void PVArgs (CPURegs* Regs) { unsigned ArgC = ArgCount - ArgStart; unsigned ArgV = GetAX (Regs); unsigned SP = MemReadZPWord (0x00); unsigned Args = SP - (ArgC + 1) * 2; Print (stderr, 2, "PVArgs ($%04X)\n", ArgV); MemWriteWord (ArgV, Args); SP = Args; while (ArgStart < ArgCount) { unsigned I = 0; const char* Arg = ArgVec[ArgStart++]; SP -= strlen (Arg) + 1; do { MemWriteByte (SP + I, Arg[I]); } while (Arg[I++]); MemWriteWord (Args, SP); Args += 2; } MemWriteWord (Args, 0x0000); MemWriteWord (0x0000, SP); SetAX (Regs, ArgC); }
static void PVClose (CPURegs* Regs) { unsigned RetVal; unsigned FD = GetAX (Regs); Print (stderr, 2, "PVClose ($%04X)\n", FD); RetVal = close (FD); SetAX (Regs, RetVal); }
static void PVWrite (CPURegs* Regs) { unsigned char* Data; unsigned RetVal, I = 0; unsigned Count = GetAX (Regs); unsigned Buf = PopParam (2); unsigned FD = PopParam (2); Print (stderr, 2, "PVWrite ($%04X, $%04X, $%04X)\n", FD, Buf, Count); Data = xmalloc (Count); while (I < Count) { Data[I++] = MemReadByte (Buf++); } RetVal = write (FD, Data, Count); xfree (Data); SetAX (Regs, RetVal); }
static void PVRead (CPURegs* Regs) { unsigned char* Data; unsigned RetVal, I = 0; unsigned Count = GetAX (Regs); unsigned Buf = PopParam (2); unsigned FD = PopParam (2); Print (stderr, 2, "PVRead ($%04X, $%04X, $%04X)\n", FD, Buf, Count); Data = xmalloc (Count); RetVal = read (FD, Data, Count); if (RetVal != (unsigned) -1) { while (I < RetVal) { MemWriteByte (Buf++, Data[I++]); } } xfree (Data); SetAX (Regs, RetVal); }
void __attribute__((interrupt,auto_psv)) _T5Interrupt(void) { _T5IF = 0; GetAX(num_ax, data); }