A2osX/.Docs/KERNEL.md

1292 lines
21 KiB
Markdown
Raw Normal View History

2016-10-22 20:52:00 +00:00
*** Auto generated by docgen.cmd ***
2018-06-18 08:44:02 +00:00
2018-10-16 15:48:03 +00:00
# Args2ArgV
2018-10-25 15:31:41 +00:00
Expand String and convert to ArgV List
## C
short int args2argv(char* args, char* argv[])
2018-10-16 15:48:03 +00:00
## ASM
`>PUSHW argv`
`>LDYA args`
`>SYSCALL Args2ArgV
2018-10-25 15:31:41 +00:00
## RETURN VALUE
A = Arg count
2018-10-16 15:48:03 +00:00
# ArgV
2018-06-18 08:44:02 +00:00
## ASM
**In:**
A = argument index.
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC : success
Y,A = PTR To Arg[A]
CS : Out Of Bound
2018-06-28 15:26:34 +00:00
# LoadDrv
2018-06-18 08:44:02 +00:00
2018-07-20 05:43:11 +00:00
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-06-28 15:26:34 +00:00
Y,A = PTR to "NAME.DRV [PARAM]" C-String
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-28 15:26:34 +00:00
none
2018-06-18 08:44:02 +00:00
2018-07-20 05:43:11 +00:00
# InsDrv
2018-07-17 15:45:59 +00:00
2018-07-20 05:43:11 +00:00
## C
2018-07-17 15:45:59 +00:00
`void * insdrv (void * src, void * crvcsstart, void * drvcsend, void * drvend);`
2018-06-28 15:26:34 +00:00
2018-07-20 05:43:11 +00:00
## ASM
2018-06-28 15:26:34 +00:00
**In:**
2018-07-19 15:33:55 +00:00
`>PUSHW DRV.END`
`>PUSHW DRV.CS.END`
`>PUSHW DRV.CS.START`
`>LDYA L.SRC`
`SYSCALL insdrv`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-07-17 15:45:59 +00:00
Y,A = Ptr to installed driver
2018-06-28 15:26:34 +00:00
# GetDevByID
2018-06-18 08:44:02 +00:00
A = DevID
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC = OK, CS = ERROR
2018-07-19 15:33:55 +00:00
Y,A = FD
2018-08-08 15:13:37 +00:00
X = hFD
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# GetDevByName
2018-06-18 08:44:02 +00:00
Y,A = Ptr to device name (C-String)
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-08-08 15:13:37 +00:00
CC = OK, CS = ERROR
Y,A = FD
X = DevID
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# GetDevStatus
2018-07-19 15:33:55 +00:00
## C
2018-09-06 15:36:44 +00:00
`int getdevstatus(short int hFD, S.DIB* dstat);`
2018-07-19 15:33:55 +00:00
## ASM
2018-09-06 15:36:44 +00:00
`>PUSHWI S.DIB`
`lda DevID`
`>SYSCALL GetDevStatus`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
2018-07-17 15:45:59 +00:00
# MKDev
2018-10-05 14:58:38 +00:00
Create a hDEV
## C
`hDEV mkdev (S.FD * fd)`
## ASM
`>LDYA FD.DEV`
`>SYSCALL mkdev
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-10-05 14:58:38 +00:00
A = hDEV
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# OpenDir
2018-07-20 11:51:08 +00:00
## C
`int hDIR opendir (const char * dirpath);`
## ASM
`>LDYA dirpath`
`>SYSCALL opendir`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC : success
A = hDIR
CS : error
A = EC
2018-06-28 15:26:34 +00:00
# ReadDir
2018-07-20 11:51:08 +00:00
## C
`int readdir (int hDIR, S.DIRENT * dirent);`
## ASM
`>PUSHW dirent`
`lda hDIR`
`>SYSCALL readdir`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC : success
X = hDIRENT
Y,A = PTR to S.DIRENT
CS : error
A = EC
note : A = 0 means no more entry
2018-06-28 15:26:34 +00:00
# CloseDir
2018-07-20 11:51:08 +00:00
## C
`void closedir(hDIR);`
## ASM
`lda hDIR`
`>SYSCALL closedir`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
none, always succeed.
# ExpandStr
**In:**
Y,A = PTR to String to Expand (C-String)
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
X = hMem to Expanded String (C-String)
Y,A = PTR to Expanded String
2018-06-28 15:26:34 +00:00
# FileSearch
Search a file in the provided PATH list
And return, if found, the full path to it.
## C
`int filesearch ( char * filename, char * searchpath, char * fullpath, stat * filestat);`
## ASM
**In:**
`>PUSHWI filestat`
`>PUSHWI fullpath`
`>PUSHWI searchpath`
`>LDYAI filename`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-28 15:26:34 +00:00
CC : success
DstBuf = FilePath
DstStat = S.STAT
CS : not found
# PutEnv
2018-09-06 15:36:44 +00:00
Change or add an environment variable, string is 'NAME=VALUE'
## C
`int putenv(char *string);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-06 15:36:44 +00:00
`>LDYA string`
`>SYSCALL putenv`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
# SetEnv
2018-09-06 15:36:44 +00:00
Change or add an environment variable
## C
`int setenv(const char *name, const char *value);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-06 15:36:44 +00:00
`>PUSHW value`
`>LDYA name`
`>SYSCALL setenv`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# GetEnv
2018-09-06 15:36:44 +00:00
searches the environment list to find the environment variable name,
and returns a pointer to the corresponding value string.
## C
`char *getenv(const char *name);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-06 15:36:44 +00:00
`>LDYA name`
2018-10-11 15:23:06 +00:00
`>SYSCALL getenv`
## RETURN VALUE
2018-09-06 15:36:44 +00:00
CC : Y,A = PTR to VALUE (C-String)
2018-06-18 08:44:02 +00:00
CS : not found
2018-06-28 15:26:34 +00:00
# UnsetEnv
2018-09-06 15:36:44 +00:00
Remove an environment variable
## C
`int unsetenv(const char *name);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-06 15:36:44 +00:00
`>LDYA name`
`>SYSCALL unsetenv`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# LoadTxtFile
2018-06-18 08:44:02 +00:00
Load TXT a file in memory (with ending 0)
**In:**
Y,A = File Path
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = File Length (without ending 0)
X = hMem of Loaded File
# LoadFile
Load a file in memory
**In:**
PUSHW = AUXTYPE (Handled by....
PUSHB = TYPE ...
PUSHB = MODE ...
2018-07-27 13:34:34 +00:00
LDYA = PATH ...FOpen)
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = File Length
X = hMem of Loaded File
# ChTyp
2018-09-05 15:22:46 +00:00
Change The type of a ProDOS File
## C
`int chtyp(const char *filepath, const char filetype);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-05 15:22:46 +00:00
`>PUSHBI filetype`
`>LDYA filepath`
`>SYSCALL chtyp`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
# ChMod
**In:**
PUSHW = UID
PUSHW = PATH
# ChOwn
**In:**
2018-09-05 15:22:46 +00:00
PUSHW = mod
2018-06-18 08:44:02 +00:00
PUSHW = PATH
# ChGrp
**In:**
PUSHW = GID
PUSHW = PATH
2018-07-17 15:45:59 +00:00
# open
## C
2018-10-04 15:30:14 +00:00
`hFD open(const char *pathname, short int flags);`
2018-07-17 15:45:59 +00:00
## ASM
**In:**
`>PUSHB flags`
`>LDYA pathname`
`>SYSCALL open`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-07-17 15:45:59 +00:00
A = hFD
2018-10-04 15:30:14 +00:00
REG File created on ProDOS : T=TXT,X=$0000
2018-07-17 15:45:59 +00:00
2018-08-27 15:26:01 +00:00
# close
## C
`int close(hFD fd);`
## ASM
**In:**
`lda fd`
`>SYSCALL close`
2018-07-19 15:33:55 +00:00
# read
## C
2018-08-27 15:26:01 +00:00
`int read(hFD fd, void *buf, int count);`
## ASM
**In:**
`>PUSHWI count`
`>PUSHW buf`
`lda fd`
`>SYSCALL read`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-08-27 15:26:01 +00:00
CC: Y,A = bytes read
CS: A = EC
# write
## C
`int write(hFD fd, const void *buf, int count);`
## ASM
**In:**
`>PUSHWI count`
`>PUSHW buf`
`lda fd`
`>SYSCALL write`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-08-27 15:26:01 +00:00
CC: Y,A = bytes written
CS: A = EC
2018-07-19 15:33:55 +00:00
2018-07-17 15:45:59 +00:00
# IOCTL
## C
2018-08-08 15:13:37 +00:00
`int ioctl(short int hFD, int request, void * param );`
2018-07-17 15:45:59 +00:00
## ASM
`PUSHWI param`
2018-07-19 15:33:55 +00:00
`PUSHBI request`
2018-08-08 15:13:37 +00:00
`lda hFD`
2018-07-17 15:45:59 +00:00
`>SYSCALL IOCTL`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-07-17 15:45:59 +00:00
Y,A = ...
# pipe
## C
`int pipe(int pipefd[2]);`
## ASM
2018-06-18 08:44:02 +00:00
# FAdd,FSub,FMult,FDiv,FPwr
Return X+Y, X-Y, X*Y, X/Y, X^Y
2018-06-18 11:42:48 +00:00
2018-06-18 15:48:00 +00:00
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-06-18 11:42:48 +00:00
`>PUSHF X (float)`
`>PUSHF Y (float)`
2018-06-18 15:48:00 +00:00
`>SYSCALL fadd`
`>SYSCALL fsub`
`>SYSCALL fmult`
`>SYSCALL fdiv`
`>SYSCALL fpwr`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 11:42:48 +00:00
On stack (float)
2018-06-18 08:44:02 +00:00
# Log,Sqr,Exp,Cos,Sin,Tan,ATan
Return Log(x), Sqr(x), E^X, Cos(x), Sin(X), Tan(x), ATan(x)
2018-06-18 11:42:48 +00:00
2018-06-18 15:48:00 +00:00
## C
2018-06-18 11:42:48 +00:00
`float log ( float x);`
`float sqr ( float x);`
`float exp ( float x);`
`float cos ( float x);`
`float sin ( float x);`
`float tan ( float x);`
`float atan ( float x);`
2018-06-18 15:48:00 +00:00
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-06-18 11:42:48 +00:00
`>PUSHF x (Float)`
`>SYSCALL log`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
On stack (Float)
2018-06-18 15:48:00 +00:00
# float
2018-06-18 08:44:02 +00:00
Return 'floated' long
2018-06-18 15:48:00 +00:00
## C
`float f = (float)12345678;
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-06-18 15:48:00 +00:00
`>PUSHL X` (long)
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 15:48:00 +00:00
On stack (float)
# lrintf
Return float rounded into a long
2018-06-18 08:44:02 +00:00
2018-06-18 15:48:00 +00:00
## C
`long int lrintf (float x);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-06-18 15:48:00 +00:00
`>PUSHF x`
`>SYSCALL lrintf`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
On stack (long)
# GetMem0
Y,A = Size Requested
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC : success
YA = PTR to Mem (ZERO Initialised)
* X = hMem
CS :
A = EC
# GetMem
Y,A = Size Requested
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC : success
YA = PTR to Mem (Uninitialised)
* X = hMem
CS :
A = EC
# FreeMem
A = hMem To Free
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
none.
2018-08-21 13:12:47 +00:00
(X unmodified)
2018-06-18 08:44:02 +00:00
# GetMemPtr
2018-08-21 13:12:47 +00:00
A = hMem
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-08-21 13:12:47 +00:00
Y,A = PTR to MemBlock
(X unmodified)
2018-06-18 08:44:02 +00:00
# GetMemByID
2018-08-21 13:12:47 +00:00
A = hMem
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-08-21 13:12:47 +00:00
Y,A = ZPMemMgrSPtr = PTR to S.MEM
(X unmodified)
2018-06-18 08:44:02 +00:00
2018-10-29 08:41:10 +00:00
# GetMemStat
**In:**
Y,A = Ptr to 24 bytes buffer
## RETURN VALUE
Buffer filled with memory stats
2018-06-18 08:44:02 +00:00
# NewStr
Create a new copy of this C-String
2018-08-21 13:12:47 +00:00
Y,A = Ptr to source C-String
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-08-21 13:12:47 +00:00
CC : success
Y,A = PTR to String
X = hMem (PSTR)
CS : error
A = SYS error code
2018-06-18 08:44:02 +00:00
# SListGetByID
PUSHB = hSList
PUSHW = KeyID
PUSHW = Data Ptr
PUSHW = Key Ptr
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
X,Y = Next KeyID
# SListUpdateByID
PUSHB = hSList
PUSHW = KeyID
PUSHW = Data Ptr
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
A = Key Length
X,Y = KeyID
# SListAdd
PUSHB = hSList
PUSHW = Key Ptr
PUSHW = Data Ptr
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
A = Key Length
X,Y = KeyID
# SListLookup
PUSHB = hSList
PUSHW = Key Ptr
PUSHW = Data Ptr
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
A = Key Length
X,Y = KeyID
# SListNew
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
A=hSList
# SListFree
A=hSList
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
# GetStkObjProp
A = hObject (AUX Memory)
Y = Property Index
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = Property Value
# NewStkObj
Y,A = Size Requested
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC : success
YA = PTR to Mem (Uninitialised)
* X = hMem
CS :
A = EC
# FreeStkObj
A = hMem To Free (AUX Memory)
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
none.
(X,Y unmodified)
# LoadStkObj
Load a file in AUX memory (Stock Objects)
PUSHW = AUXTYPE (Handled by....
PUSHB = TYPE ...
PUSHB = MODE ...
PUSHW = PATH ...FOpen)
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = File Length
X = hMem of Loaded Object in AUX mem
2018-11-26 16:36:55 +00:00
# GetPSStat
**In:**
Y,A = Ptr to K.PS.MAX*2+1 bytes buffer
## RETURN VALUE
Buffer filled with PS stats
2018-10-25 15:31:41 +00:00
# ExecL
## C
`int execl(const char* cmdline, short int flags);`
## ASM
`>PUSHB flags`
`>LDYA cmdline`
`>SYSCALL execl`
## RETURN VALUE
A = Child PSID
# ExecV
2018-10-15 15:39:21 +00:00
## C
2018-10-16 15:48:03 +00:00
`int exec(const char* argv[], short int flags);`
2018-10-11 15:23:06 +00:00
## ASM
`>PUSHB flags`
2018-10-15 06:25:40 +00:00
`>LDYA argv`
2018-10-15 15:39:21 +00:00
`>SYSCALL execv`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
A = Child PSID
2018-06-28 15:26:34 +00:00
# GetPSStatus
2018-06-18 08:44:02 +00:00
**In:**
A = PID
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
A = Status Byte
# Stat
Return information about a file
2018-07-20 11:51:08 +00:00
## C
`int stat(const char *pathname, struct stat *statbuf);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-07-20 11:51:08 +00:00
`>PUSHW statbuf`
`>LDYA pathname`
`>SYSCALL stat`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# MKDir
2018-09-20 15:33:05 +00:00
create a directory
## C
`int mkdir(const char *pathname, int mode);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-20 15:33:05 +00:00
`>PUSHW mode`
`>LDYA pathname`
`>SYSCALL mkdir`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-09-20 15:33:05 +00:00
CC : success
CS : error
A = EC
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# MkNod
2018-10-04 06:13:44 +00:00
Create a special or ordinary file.
2018-09-20 15:33:05 +00:00
(CDEV, BDEV, DSOCKS, SSOCK, PIPE)
## C
`hFILE mknod(const char *pathname, int mode, hFD fd);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-20 15:33:05 +00:00
`>PUSHB fd`
`>PUSHW mode`
`>LDYA pathname`
`>SYSCALL mknod`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-09-20 15:33:05 +00:00
CC = OK, CS = ERROR
A = hFILE
2018-06-18 08:44:02 +00:00
# MKFIFO
return a hFILE to a new FIFO
2018-09-20 15:33:05 +00:00
## C
`hFILE mkfifo(const char *pathname, int mode);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-20 15:33:05 +00:00
`>PUSHW mode`
`>LDYA pathname`
`>SYSCALL mkfifo`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-09-20 15:33:05 +00:00
CC = OK, CS = ERROR
A = hFILE
2018-06-18 08:44:02 +00:00
2018-11-26 16:36:55 +00:00
# PutChar
Print A (char) to StdOut
2018-06-18 08:44:02 +00:00
## C
2018-11-26 16:36:55 +00:00
`int putchar ( int character );`
2018-06-18 08:44:02 +00:00
## ASM
**In:**
2018-11-26 16:36:55 +00:00
`lda caracter`
`>SYSCALL putchar`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC = success
2018-11-26 16:36:55 +00:00
# FPutC
Print A (char) to hFILE
2018-06-18 08:44:02 +00:00
## C
2018-11-26 16:36:55 +00:00
`int fputc ( hFILE stream , int character );`
2018-06-18 08:44:02 +00:00
## ASM
**In:**
2018-11-26 16:36:55 +00:00
`>PUSHB character`
`lda stream`
`>SYSCALL fputc`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC = success
# PutS
Write Str to StdOut, appends '\r\n'
## C
`int puts ( const char * str );`
**In:**
2018-07-27 13:34:34 +00:00
## ASM
`>LDYAI str`
`>SYSCALL puts`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC = success
# FPutS
Write Str to FILE
## C
2018-07-27 13:34:34 +00:00
`int fputs (hFILE stream, const char * str );`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-07-27 13:34:34 +00:00
`>PUSHW str`
`lda stream`
`>SYSCALL fputs`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC = success
# PrintF/SPrintF/FPrintF
Prints C-Style String
## C
`int printf ( const char * format, ... );`
`int fprintf ( hFILE stream, const char * format, ... );`
2018-11-26 16:36:55 +00:00
`int sprintf ( char * str, const char * format, ... );`
2018-06-18 08:44:02 +00:00
## ASM
**In:**
2018-10-05 14:58:38 +00:00
PrintF : (example is for printing Y,A as integer : format="%I", 2 bytes)
2018-06-18 08:44:02 +00:00
`>PUSHYA`
2018-07-24 06:24:23 +00:00
`...`
`>PUSHBI bytecount`
2018-06-18 08:44:02 +00:00
`>LDYAI format`
`>SYSCALL printf`
SPrintF :
`>PUSHYA`
2018-07-24 06:24:23 +00:00
`...`
`>PUSHBI bytecount`
2018-06-18 08:44:02 +00:00
`>PUSHWI format`
`>LDYAI str`
`>SYSCALL sprintf`
FPrintF :
`>PUSHYA`
2018-07-24 06:24:23 +00:00
`...`
`>PUSHBI bytecount`
2018-06-18 08:44:02 +00:00
`>PUSHWI format`
`lda hFILE`
`>SYSCALL fprintf`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC : success, Y,A = bytes sent
CS : error, A = code from Output
Specifiers :
+ %b : pull 1 byte to Print BIN
+ %B : pull 2 bytes to Print BIN
+ %d : pull 1 byte unsigned DEC 0..255
+ %D : pull 2 bytes unsigned DEC 0..65535
+ %u : pull 4 bytes long unsigned DEC 0..4294967295
+ %e : pull 5 Bytes float (-)1.23456789e+12
+ %f : pull 5 Bytes float (-)3.1415
+ %h : pull 1 byte to Print HEX
+ %H : pull 2 bytes to Print HEX
+ %i : pull 1 byte to Print signed DEC -128..127
+ %I : pull 2 bytes to Print signed DEC -32768..32767
+ %L : pull 4 bytes signed DEC -2147483648..2147483647
+ %n : pull 1 byte to Print low Nibble HEX
+ %N : pull 1 byte to Print high Nibble HEX
+ %s : pull 2 bytes ptr to C-Style String
+ %S : pull 2 bytes ptr to P-Style String
+ \b : Print 'BS' (08)
+ \e : Print 'ESC' ($1B,27)
+ \f : Print 'FF' ($0C,12)
+ \n : Print 'LF' ($0A,10)
+ \r : Print 'CR' ($0D,13)
+ \\\\ : Print \
+ \\% : Print %
Modifiers for len and padding :
+ %d : '9' '12'
+ %2d : ' 9' '12'
+ %02d : '09' '12'
+ %11s : 'ABCDEFGH '
+ %011s : 'ABCDEFGH000'
+ %2f : '3.14'
2018-07-27 13:34:34 +00:00
# FGetS
read bytes from stream into the array
pointed to by s, until n-1 bytes are read, or a <newline> is read and
transferred to s, or an end-of-file condition is encountered. The
string is then terminated with a null byte.
## C
`char *fgets(hFILE stream, char * s, int n);`
## ASM
**In:**
`>PUSHW n`
`>PUSHW s`
`lda hFILE`
`>SYSCALL fgets`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-07-27 13:34:34 +00:00
Y,A: s
CC = success
2018-06-18 08:44:02 +00:00
# GetChar
Get char from StdIn
2018-10-04 06:13:44 +00:00
## C
`int getchar ();`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-10-04 06:13:44 +00:00
`>SYSCALL getchar`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC = success
A = char
# GetC
Get char from Node
## C
2018-10-04 06:13:44 +00:00
`int getc ( hFILE stream );`
2018-06-18 08:44:02 +00:00
## ASM
**In:**
2018-10-04 06:13:44 +00:00
`lda stream`
`>SYSCALL getc`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC = success
A = char
# SScanF
Read formatted data from string
## C
2018-07-24 06:24:23 +00:00
`int sscanf ( const char * s, const char * format, ... );`
2018-06-18 08:44:02 +00:00
## ASM
**In:**
2018-08-08 15:13:37 +00:00
`>PUSHW ptr`
`...`
`>PUSHBI bytecount`
`>PUSHWI format`
2018-06-18 08:44:02 +00:00
+ %i : short int
+ %d : byte
+ %I : int
+ %D : word
+ %L : long int
+ %U : dword
+ %h : HEX byte
+ %H : HEX word
2018-07-27 13:34:34 +00:00
+ %s : string
2018-06-18 08:44:02 +00:00
2018-08-08 15:13:37 +00:00
TODO : %10s
2018-06-18 08:44:02 +00:00
`>LDYA s`
2018-08-25 11:23:59 +00:00
`>SYSCALL sscanf`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-08-08 15:13:37 +00:00
A = Number of arguments filled.
2018-06-18 08:44:02 +00:00
# FOpen
Open a file
2018-06-18 11:42:48 +00:00
## C
2018-10-04 15:30:14 +00:00
`hFILE fopen ( const char * filename, short int flags, short int ftype, int auxtype );`
2018-06-18 08:44:02 +00:00
**In:**
2018-06-18 11:42:48 +00:00
## ASM
`>PUSHWI auxtype`
`>PUSHBI ftype`
2018-10-04 15:30:14 +00:00
`>PUSHBI flags`
2018-10-04 06:13:44 +00:00
+ O.RDONLY : if R and exists -> ERROR
+ O.WRONLY : if W and exists -> CREATE
+ O.TRUNC : Reset Size To 0
+ O.APPEND : Append
+ O.TEXT : Open/Append in Text mode
+ O.CREATE : Create if not exists
2018-10-04 15:30:14 +00:00
TODO: replace flags/ftype/auxtype with mode="w+,t=TYP,x=AUXTYPE"
2018-10-04 06:13:44 +00:00
+ r = O_RDONLY
+ r+ = O_RDWR
+ w = O_WRONLY | O_CREAT | O_TRUNC
+ w+ = O_RDWR | O_CREAT | O_TRUNC
+ a = O_WRONLY | O_CREAT | O_APPEND
+ a+ = O_RDWR | O_CREAT | O_APPEND
+ ,t=123 or t=$ff or t=TXT
+ ,x=12345 or x=$ffff
2018-06-18 11:42:48 +00:00
`>LDYAI filename`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC : A = hFILE
CS : A = EC
2018-06-28 15:26:34 +00:00
# FClose
2018-06-18 08:44:02 +00:00
Close a file
2018-07-17 15:45:59 +00:00
## C
2018-09-05 15:22:46 +00:00
int fclose ( hFILE stream );
2018-07-17 15:45:59 +00:00
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-10-04 06:13:44 +00:00
`lda stream`
`>SYSCALL fclose`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
# FRead
Read bytes from file
2018-10-04 15:30:14 +00:00
## C
int fread (hFILE stream, void * ptr, int count );
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-07-24 16:00:24 +00:00
`>PUSHWI count`
`>PUSHW ptr`
2018-10-04 06:13:44 +00:00
`lda stream`
2018-07-24 16:00:24 +00:00
`>SYSCALL fread`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = Bytes Read
# FWrite
Write bytes to file
2018-06-19 15:08:22 +00:00
## C
2018-07-24 16:00:24 +00:00
`int fwrite (hFILE stream, const void * ptr, int count );`
2018-06-19 15:08:22 +00:00
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-07-24 16:00:24 +00:00
`>PUSHWI count`
`>PUSHW ptr`
2018-10-04 06:13:44 +00:00
`lda stream`
2018-07-24 16:00:24 +00:00
`>SYSCALL fwrite`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = Bytes Written
2018-06-28 15:26:34 +00:00
# FFlush
2018-07-27 13:34:34 +00:00
## C
int fflush(hFILE stream);
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-10-04 06:13:44 +00:00
`lda stream`
`>SYSCALL fflush`
2018-06-18 08:44:02 +00:00
# FSeek
Set the file-position indicator for hFILE
2018-07-27 13:34:34 +00:00
## C
2018-08-08 15:13:37 +00:00
`int fseek(hFILE stream, long offset, short int whence);`
2018-07-27 13:34:34 +00:00
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-08-08 15:13:37 +00:00
`>PUSHBI whence`
`>PUSHL offset`
`lda stream`
`>SYSCALL fseek`
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# FEOF
2018-06-18 08:44:02 +00:00
Test the end-of-file indicator for hFILE
2018-10-04 06:13:44 +00:00
## C
`int feof(hFILE stream);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-10-04 06:13:44 +00:00
`lda stream`
`>SYSCALL feof`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
CC :
2018-10-04 06:13:44 +00:00
A=0 EOF
A =0 NOT EOF
2018-06-18 08:44:02 +00:00
CS :
# FTell
Return the current value of the file-position indicator
2018-07-27 13:34:34 +00:00
## C
`long ftell(hFILE stream);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-08-08 15:13:37 +00:00
`lda stream`
`>SYSCALL ftell`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-08-08 15:13:37 +00:00
On stack (long)
2018-06-18 08:44:02 +00:00
2018-06-28 15:26:34 +00:00
# Remove
2018-10-04 06:13:44 +00:00
Remove a file or directory
## C
int remove(const char *pathname);
## ASM
**In:**
`>LDYA pathname`
`>SYSCALL remove`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
# Rename
Rename a file
2018-08-08 15:13:37 +00:00
## C
`int rename(const char *oldpath, const char *newpath);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-08-08 15:13:37 +00:00
`>PUSHW newpath`
`>LDYA oldpath`
`>SYSCALL rename`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
2018-06-18 15:48:00 +00:00
# strtof
2018-06-18 08:44:02 +00:00
Convert String to 40 bits Float
2018-10-04 15:30:14 +00:00
## C
2018-06-18 08:44:02 +00:00
`float strtof (const char* str, char** endptr);`
2018-10-04 15:30:14 +00:00
## ASM
2018-06-18 08:44:02 +00:00
**In:**
`>PUSHWI EndPtr`
`>LDYA str`
2018-06-18 11:42:48 +00:00
`>SYSCALL strtof`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
On stack (float)
# AToF
Convert String to 40 bits Float
## C
`float atof (const char* str);`
## ASM
**In:**
`>LDYA str`
2018-06-18 15:48:00 +00:00
`>SYSCALL atof`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
On stack (float)
# StrToL/StrToUL
Convert String to 32 bits (unsigned) int
## C
`long strtol (const char* str, char** endptr, int base);`
`unsigned long strtoul (const char* str, char** endptr, int base);`
## ASM
**In:**
`>PUSHB Base`
`>PUSHWI EndPtr`
2018-06-18 15:48:00 +00:00
`>LDYAI str`
`>SYSCALL strtol`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
On stack (long)
2018-06-18 15:48:00 +00:00
# atol
Convert String to 32 bits long
2018-06-18 08:44:02 +00:00
## C
`long atol ( const char * str );`
## ASM
**In:**
`>LDYA str`
2018-06-18 15:48:00 +00:00
`>SYSCALL atol`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
On stack (long)
2018-06-18 15:48:00 +00:00
# atoi
Convert String to 16 bits int
2018-06-18 08:44:02 +00:00
## C
`int atoi ( const char * str );`
## ASM
**In:**
2018-06-18 15:48:00 +00:00
`>LDYAI str`
`>SYSCALL atoi`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 15:48:00 +00:00
Y,A = int
2018-06-18 08:44:02 +00:00
2018-08-21 13:12:47 +00:00
# RealPath
2018-06-18 08:44:02 +00:00
Return the canonicalized absolute pathname
2018-06-18 15:48:00 +00:00
## C
`unsigned short int realpath (const char* str);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-06-18 15:48:00 +00:00
`>LDYA str`
`>SYSCALL realpath`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 15:48:00 +00:00
CC : success
Y,A = Ptr to Full Path (C-String)
X = hMem of Full Path
CS : A = Error Code
2018-06-18 08:44:02 +00:00
2018-11-26 16:36:55 +00:00
# StrMatch
Compare a String against pattern (e.g. '*test?.txt')
## C
`int * strmatch ( char * s, const char * pattern );`
## ASM
**In:**
`>PUSHWI pattern`
`>LDYAI s`
`>SYSCALL strmatch`
## RETURN VALUE
CC : match
CS : no match
2018-06-18 08:44:02 +00:00
# StrLen
Returns Length of C-String
## C
2018-06-19 15:08:22 +00:00
`int strlen ( char * str);`
2018-06-18 08:44:02 +00:00
## ASM
2018-06-19 15:08:22 +00:00
`>LDYAI str`
`>SYSCALL strlen`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = String length
# StrCat
Concatenate strings
## C
`char * strcat ( char * destination, const char * source );`
## ASM
**In:**
`>PUSHWI source`
`>LDYAI destination`
`>SYSCALL strcat`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = destination
# StrCpy
Copy string
## C
`char * strcpy ( char * destination, const char * source );`
## ASM
**In:**
`>PUSHWI source`
`>LDYAI destination`
`>SYSCALL strcpy`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Y,A = destination
# StrUpr/StrLwr
Convert string to UPPERCASE/lowercase
2018-09-06 12:27:37 +00:00
## C
`int strupr ( char * str);`
`int strlwr ( char * str);`
## ASM
**In:**
`>LDYAI str`
`>SYSCALL strupr`
`>SYSCALL strlwr`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
Uppercased/lowercased String in Buffer
2018-09-06 12:27:37 +00:00
Y,A = str
2018-06-18 08:44:02 +00:00
# StrCmp
Compare 2 strings
2018-09-06 12:27:37 +00:00
## C
`int strcmp(const char *s1, const char *s2);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-06 12:27:37 +00:00
`>PUSHWI s2`
`>LDYAI s1`
`>SYSCALL strcmp`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-09-06 12:27:37 +00:00
CC : match
CS : no match
CC, Y,A=0
CS, Y,A > 0 or < 0
2018-06-18 08:44:02 +00:00
2018-09-06 12:27:37 +00:00
# StrCaseCmp
Compare 2 strings, ignoring case
## C
`int strcasecmp(const char *s1, const char *s2);`
## ASM
2018-06-18 08:44:02 +00:00
**In:**
2018-09-06 12:27:37 +00:00
`>PUSHWI s2`
`>LDYAI s1`
`>SYSCALL strcasecmp`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-09-06 12:27:37 +00:00
CC : match
CS : no match
2018-06-18 08:44:02 +00:00
CC, Y,A=0
CS, Y,A > 0 or < 0
# Time
Get System Time in Buffer
## C
2018-09-05 15:22:46 +00:00
`time_t time (S.TIME* timer);`
2018-06-18 08:44:02 +00:00
2018-10-04 15:30:14 +00:00
## ASM
2018-10-11 15:23:06 +00:00
`>LDYA timer`
`>SYSCALL time`
## RETURN VALUE
2018-06-18 08:44:02 +00:00
S.TIME filled with System date/time
# PTime2Time
Convert ProDOS Time To S.TIME
## C
2018-09-05 15:22:46 +00:00
`int PTime2Time (long* ptime, S.TIME* timer);`
2018-06-18 08:44:02 +00:00
2018-10-04 15:30:14 +00:00
## ASM
2018-09-05 15:22:46 +00:00
`>PUSHW timer`
`>LDYA ptime`
`>SYSCALL PTime2Time`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
# CTime2Time
2018-09-05 15:22:46 +00:00
Convert CTime Time To S.TIME
## C
`int CTime2Time (long* ctime, S.TIME* timer);`
2018-10-04 15:30:14 +00:00
## ASM
2018-09-05 15:22:46 +00:00
`>PUSHW timer`
`>LDYA ctime`
`>SYSCALL CTime2Time`
2018-10-11 15:23:06 +00:00
## RETURN VALUE
2018-06-18 08:44:02 +00:00
# StrFTime
## C
Convert S.TIME struct to CSTR
2018-10-11 15:23:06 +00:00
`size_t strftime (char* ptr, const char* format, const struct S.TIME* timeptr );`
2018-06-18 08:44:02 +00:00
## ASM
2018-10-11 15:23:06 +00:00
`PUSHW timeptr`
`PUSHW format`
2018-06-18 08:44:02 +00:00
+ %a : Abbreviated weekday name : Thu
+ %A : Full weekday name : Thursday
+ %b : Abbreviated month name : Aug
+ %B : Full month name : August
+ %d : Day of the month, zero-padded (01-31)
+ %H : Hour in 24h format (00-23) 14
+ %I : Hour in 12h format (01-12) 02
+ %m : Month as a decimal number (01-12) 08
+ %M : Minute (00-59) 55
+ %p : AM or PM designation PM
+ %S : Second (00-61) 02
+ %w : Weekday as a decimal number with Sunday as 0 (0-6)
+ %y : Year, last two digits (00-99)
+ %Y : Year four digits 2001
2018-10-11 15:23:06 +00:00
`>LDYA ptr`
`>SYSCALL strftime`
## RETURN VALUE
2018-06-18 08:44:02 +00:00
none. always succeed.