mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 03:30:05 +00:00
Merge pull request #2526 from picocomputer/master
Add to rp6502 target: clock(), xregn(), and RIA stack increase
This commit is contained in:
commit
bb7f0c17b8
@ -37,6 +37,7 @@ RIA_OP_PHI2 := $02
|
|||||||
RIA_OP_CODEPAGE := $03
|
RIA_OP_CODEPAGE := $03
|
||||||
RIA_OP_LRAND := $04
|
RIA_OP_LRAND := $04
|
||||||
RIA_OP_STDIN_OPT := $05
|
RIA_OP_STDIN_OPT := $05
|
||||||
|
RIA_OP_CLOCK := $0F
|
||||||
RIA_OP_CLOCK_GETRES := $10
|
RIA_OP_CLOCK_GETRES := $10
|
||||||
RIA_OP_CLOCK_GETTIME := $11
|
RIA_OP_CLOCK_GETTIME := $11
|
||||||
RIA_OP_CLOCK_SETTIME := $12
|
RIA_OP_CLOCK_SETTIME := $12
|
||||||
|
@ -47,8 +47,7 @@ struct __RP6502
|
|||||||
unsigned char step1;
|
unsigned char step1;
|
||||||
unsigned int addr1;
|
unsigned int addr1;
|
||||||
unsigned char xstack;
|
unsigned char xstack;
|
||||||
unsigned char errno_lo;
|
unsigned int errno;
|
||||||
unsigned char errno_hi;
|
|
||||||
unsigned char op;
|
unsigned char op;
|
||||||
unsigned char irq;
|
unsigned char irq;
|
||||||
const unsigned char spin;
|
const unsigned char spin;
|
||||||
@ -101,6 +100,7 @@ long __fastcall__ ria_call_long_errno (unsigned char op);
|
|||||||
#define RIA_OP_CODEPAGE 0x03
|
#define RIA_OP_CODEPAGE 0x03
|
||||||
#define RIA_OP_LRAND 0x04
|
#define RIA_OP_LRAND 0x04
|
||||||
#define RIA_OP_STDIN_OPT 0x05
|
#define RIA_OP_STDIN_OPT 0x05
|
||||||
|
#define RIA_OP_CLOCK 0x0F
|
||||||
#define RIA_OP_CLOCK_GETRES 0x10
|
#define RIA_OP_CLOCK_GETRES 0x10
|
||||||
#define RIA_OP_CLOCK_GETTIME 0x11
|
#define RIA_OP_CLOCK_GETTIME 0x11
|
||||||
#define RIA_OP_CLOCK_SETTIME 0x12
|
#define RIA_OP_CLOCK_SETTIME 0x12
|
||||||
@ -117,6 +117,8 @@ long __fastcall__ ria_call_long_errno (unsigned char op);
|
|||||||
|
|
||||||
/* C API for the operating system. */
|
/* C API for the operating system. */
|
||||||
|
|
||||||
|
int __cdecl__ xregn (char device, char channel, unsigned char address, unsigned count,
|
||||||
|
...);
|
||||||
int __cdecl__ xreg (char device, char channel, unsigned char address, ...);
|
int __cdecl__ xreg (char device, char channel, unsigned char address, ...);
|
||||||
int phi2 (void);
|
int phi2 (void);
|
||||||
int codepage (void);
|
int codepage (void);
|
||||||
|
@ -86,6 +86,8 @@ struct tm {
|
|||||||
# define CLOCKS_PER_SEC 135 /* FIXME */
|
# define CLOCKS_PER_SEC 135 /* FIXME */
|
||||||
#elif defined(__GEOS__)
|
#elif defined(__GEOS__)
|
||||||
# define CLOCKS_PER_SEC 1
|
# define CLOCKS_PER_SEC 1
|
||||||
|
#elif defined (__RP6502__)
|
||||||
|
# define CLOCKS_PER_SEC 100
|
||||||
#elif defined(__TELESTRAT__)
|
#elif defined(__TELESTRAT__)
|
||||||
# define CLOCKS_PER_SEC 10
|
# define CLOCKS_PER_SEC 10
|
||||||
#elif defined(__ATARI__) || defined (__LYNX__)
|
#elif defined(__ATARI__) || defined (__LYNX__)
|
||||||
|
7
libsrc/rp6502/clock.c
Normal file
7
libsrc/rp6502/clock.c
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include <rp6502.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
clock_t __fastcall__ clock (void)
|
||||||
|
{
|
||||||
|
return ria_call_long (RIA_OP_CLOCK);
|
||||||
|
}
|
@ -5,7 +5,7 @@ int __fastcall__ read (int fildes, void* buf, unsigned count)
|
|||||||
{
|
{
|
||||||
int total = 0;
|
int total = 0;
|
||||||
while (count) {
|
while (count) {
|
||||||
unsigned blockcount = (count > 256) ? 256 : count;
|
unsigned blockcount = (count > 512) ? 512 : count;
|
||||||
int bytes_read = read_xstack (&((char*)buf)[total], blockcount, fildes);
|
int bytes_read = read_xstack (&((char*)buf)[total], blockcount, fildes);
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0) {
|
||||||
return bytes_read;
|
return bytes_read;
|
||||||
|
@ -7,7 +7,7 @@ unsigned char __fastcall__ _sysrename (const char* oldpath, const char* newpath)
|
|||||||
size_t oldpathlen, newpathlen;
|
size_t oldpathlen, newpathlen;
|
||||||
oldpathlen = strlen (oldpath);
|
oldpathlen = strlen (oldpath);
|
||||||
newpathlen = strlen (newpath);
|
newpathlen = strlen (newpath);
|
||||||
if (oldpathlen + newpathlen > 254) {
|
if (oldpathlen + newpathlen > 510) {
|
||||||
return _mappederrno (EINVAL);
|
return _mappederrno (EINVAL);
|
||||||
}
|
}
|
||||||
while (oldpathlen) {
|
while (oldpathlen) {
|
||||||
|
@ -5,7 +5,7 @@ int __fastcall__ write (int fildes, const void* buf, unsigned count)
|
|||||||
{
|
{
|
||||||
int ax, total = 0;
|
int ax, total = 0;
|
||||||
while (count) {
|
while (count) {
|
||||||
int blockcount = (count > 256) ? 256 : count;
|
int blockcount = (count > 512) ? 512 : count;
|
||||||
ax = write_xstack (&((char*)buf)[total], blockcount, fildes);
|
ax = write_xstack (&((char*)buf)[total], blockcount, fildes);
|
||||||
if (ax < 0) {
|
if (ax < 0) {
|
||||||
return ax;
|
return ax;
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
#include <rp6502.h>
|
#include <rp6502.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
int __fastcall__ write_xstack (const void* buf, unsigned count, int fildes)
|
int __fastcall__ write_xstack (const void* buf, unsigned count, int fildes)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
if (count > 512) {
|
||||||
|
return _mappederrno (EINVAL);
|
||||||
|
}
|
||||||
for (i = count; i;) {
|
for (i = count; i;) {
|
||||||
ria_push_char (((char*)buf)[--i]);
|
ria_push_char (((char*)buf)[--i]);
|
||||||
}
|
}
|
||||||
|
19
libsrc/rp6502/xregn.c
Normal file
19
libsrc/rp6502/xregn.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include <rp6502.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
int __cdecl__ xregn (char device, char channel, unsigned char address, unsigned count,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start (args, count);
|
||||||
|
RIA.xstack = device;
|
||||||
|
RIA.xstack = channel;
|
||||||
|
RIA.xstack = address;
|
||||||
|
while (count--) {
|
||||||
|
unsigned v = va_arg (args, unsigned);
|
||||||
|
RIA.xstack = v >> 8;
|
||||||
|
RIA.xstack = v;
|
||||||
|
}
|
||||||
|
va_end (args);
|
||||||
|
return ria_call_int_errno (RIA_OP_XREG);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user