Re: [cc65] Latest Snapshot - Apple II

From: Bill Buckels <bbuckels1mymts.net>
Date: 2014-05-19 20:43:50
Groepaz wrote:
>whatever you are trying to say, it seems to line up with your previous 
>ramblings :)

Apparently... but your comment on seek was hilarious. Anyone could write it 
on the Apple II but haven't. Anyone can't on the Commodore so focus instead 
on optimizing an already optimal compiler. But on a computer like the Atari 
which I think is less capable in many ways I am surprised and shocked to see 
it done for so many models.

Here's the Aztec C65 lseek from 1983 for the C64:

/* Copyright (C) 1983 by Manx Software Systems, Inc. */

#include "io.h"
#include "errno.h"

long
lseek(fd, pos, mode)
int fd, mode;
long pos;
{
 register struct fil_tab *fp;
 long curpos;

 errno = 0;
 fp = _fil_tab + fd;
 if (fd < 0 || fd > MAXFILES || fp->mode == 0xff) {
  errno = E_BADFD;
  return(-1);
 }
 if (fp->type != 'L') {
  errno = E_BADTYPE;
  return(-1);
 }
 if (mode == 2) {
  errno = E_BADMODE;
  return(-1);
 }
 if (mode == 1) {
  curpos = ((fp->rechi<<8) | fp->reclo) - 1;
  curpos *= RECSIZE;
  curpos += fp->byte - 2;
  pos += curpos;
 }
 curpos = pos;
 fp->byte = pos % RECSIZE + 2;
 pos /= RECSIZE;
 fp->reclo = ++pos;
 fp->rechi = pos >> 8;
 return(curpos);
} 

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon May 19 20:44:12 2014

This archive was generated by hypermail 2.1.8 : 2014-05-19 20:44:14 CEST