Wiki

Clone wiki

Super-Mon / NakedOS_API

NakedOS Assembly API

THE GENERAL FORM OF A NAKEDOS CALL IS:

 JSR $340
 ADC $DCXX    ; XX IS THE OPERATION #
 ...PARAMS... ; SEE BELOW
 ADC $DCXX    ; CAN CHAIN MULTIPLE CMDS
 ...PARAMS...
 CLD          ; TERMINATES THE CHAIN

PARAMETERS ARE ALWAYS 8 BITS AND SPECI-
FIED BY A SUBSET OF 6502 OPCODES THAT
NAKEDOS INTERPRETS SPECIALLY:

 LDA #11      ; IMMEDIATE VALUE
 LDA $22      ; LOAD VALUE FROM ZERO PG
 LDA $3333    ; LOAD VALUE FROM ABS ADDR
 BIT $4400    ; TAKE HIGH BYTE (EG $44)
 BIT $0055    ; TAKE LOW BYTE (EG $55)

THE LATTER TWO FORMS ARE NICE FOR MAKING
SYMBOLIC REFERENCES TO MEMORY PAGES AND
FILE NUMBERS (RESPECTIVELY.)

        == SUPPORTED COMMANDS ==

 ADC $DC01  READ FILE (ENTIRE FILE)
 <FILE#>      NUMBER (01.FD) OF FILE
 <MEMPAGE>    STARTING MEMORY PAGE

 ADC $DC02  WRITE FILE
 <FILE#>      NUMBER (01.DF) OF FILE
 <MEMPAGE>    STARTING MEMORY PAGE
 <NPAGES>     NUMBER OF PAGES TO WRITE

 ADC $DC03  DELETE FILE
 <FILE#>      NUMBER (01.DF) OF FILE

 ADC $DC08  GET FILE INFO
 <FILE#>      NUMBER (01.DF) OF FILE.
              AFTER CALL, X-REG HAS FILE
              LENGTH, OR 0 FOR NONE.

 ADC $DC0F  INITIALIZE CATALOG (DELETE
              ALL FILES)

 ADC $DC41  RAW DISK READ
 <TRACK#>     STARTING TRACK (00.22)
 <SECTOR#>    STARTING SECTOR (00.0F)
 <MEMPAGE>    STARTING MEMORY PAGE
 <NPAGES>     NUMBER OF PAGES TO READ

 ADC $DC42  RAW DISK WRITE
 <TRACK#>     STARTING TRACK (00.22)
 <SECTOR#>    STARTING SECTOR (00.0F)
 <MEMPAGE>    STARTING MEMORY PAGE
 <NPAGES>     NUMBER OF PAGES TO WRITE

 CLD        DONE WITH DISK COMMANDS
             (TURNS OFF DRIVE, CLEARS
              NAKEDOS BUFFERS, RETURNS)

 SED        PAUSE (LEAVES DRIVE ON,
              NAKEDOS STAYS IN MEM &
              RETURNS. QUICK TO RESUME)
               
 CLV        STAY RESIDENT
             (LIKE SED BUT TURNS OFF
              THE DRIVE. GOOD PREP FOR
              RAW-READING UNKNOWN DISK)

             == EXAMPLE ==

THIS EXAMPLE COPIES FILE 5 TO FILE 6.
IT FIRST GETS THE FILE LENGTH, THEN
READS TO A BUFFER AT $4000, AND WRITES
FROM THAT SAME BUFFER.

 JSR $340    ; CALL NAKEDOS
 ADC $DC08   ; FILE INFO
 BIT $DF05   ; FILE NUMBER 5
 SED         ; LEAVE ON, RESUME 6502 ASM
 STX $6      ; STORE FILE LENGTH
 JSR $340    ; BACK TO NAKEDOS
 ADC $DC01   ; READ FILE
 BIT $DF05   ; FILE NUMBER 5
 LDA #40     ; PAGE $40 (E.G. ADDR 4000)
 ADC $DC02   ; WRITE FILE
 LDA #5      ; FILE NUMBER 6
 BIT $4000   ; PAGE $40 SAID ANOTHER WAY
 LDA $6      ; RETRIEVE FILE LENGTH
 CLD         ; ALL DONE

This page is from Super-mon's built-in help system.

Updated