Files
Shawn Quick dfcaae62dd Add qlink, the disk tools, and a bootable ProDOS 8 image.
Move the assembler to src/qasm. qlink links OMF 1.0 and 2.0 from a script. makeBin flattens a load file, qomf dumps OMF, and qpro builds ProDOS volumes. APW and MPW assemble through the ORCA front end. Relocatable modules emit OMF objects. Listings stay off unless -l is set.

make boot assembles the GS/OS 6.0.1 ProDOS 8 kernel and BASIC.SYSTEM into an 800K volume. BASIC.SYSTEM accepts ls and pfx, and its splash reports PRODOS BASIC 2.0, copyright 1983-2026. IIGS.601.SRC is the source and the BASIC.SYSTEM oracle that image is built from.
2026-10-16 14:41:55 -07:00

1 line
7.7 KiB
NASM

title 'Queue Stuff'
**********************************************************************
*
* Queue Stuff
* Copyright (C) 1988
* Apple Computer, Inc.
* All Rights Reserved
*
* This file contains the routines
*
* AddToQueue
* DeleteFromQueue
*
*
**********************************************************************
include 'all.macros'
include 'mt.equates.asm'
include '::sys.equs.asm'
title 'AddToQueue'
****************************************************************
*
AddToQueue PROC EXPORT
*
* This routine adds the indicated record to the link list
* that starts at PtrToFirstPtr.
*
* If FirstPtr is zero, then the new pointer will be
* stored at PtrToFirstPtr.
*
* The link in the header field of the new record is zeroed.
*
* Before the items are linked, the signature word of the
* header record is checked. If the signature is not valid,
* and error is returned and no linkage is made.
*
*
* Inputs:
* Pointer To Record to Add
* Pointer To Pointer to First Record
*
* Outputs:
* none
*
* External Refs:
import oErrOut8
import FindMatch
*
* Entry Points:
* none
*
longa on ; mode
longi on
*
* Change History
*
* 12 Jan 88 Steven Glass
*
* Added code to check and see if the specified entry was
* already in the queue. When it is an error is returned.
*
****************************************************************
DefineStack
OrigD WORD
CurPtr LONG
RTL1 block 3
rtl2 block 3
PtrToFirstPtr LONG
RoutinePtr LONG
PriorPtr equ PtrToFirstPtr ; better name for this location when in
; loop.
pha ; put space for CurPtr on stack
pha
phd ; save d-reg
tsc ; turn stack to d-page
tcd
;-----------------------------------------------------------
;
; Make sure that the signature is correct.
;
ldy #HeaderSignature
lda [RoutinePtr],y
cmp #QueueSignature
bne SigError
pha ; space for result
pha
pei RoutinePtr+2
pei RoutinePtr
pei PtrToFirstPtr+2 ; save the pointer to the first pointer
pei PtrToFirstPtr
jsr FindMatch ; no match should be found
bcs Continue
pla
pla
ldx #AlreadyInQueue
bra AllDone
Continue
;
; Restore the pointer to the first pointer.
;
PullLong PriorPtr
;-----------------------------------------------------------
;
; Signature is ok, find the end and link it in.
;
ldy #2 ; set y to 2 and leave this way until end
php ; save state of system
sei ; turn off interrupts
;-----------------------------------------------------------
;
; We got the last one. Link the new record into the last
; one and zero the link in the new one.
;
FoundEnd lda RoutinePtr ; Put the pointer to the new routine in the
sta [PriorPtr] ; space provided in last
lda RoutinePtr+2
sta [PriorPtr],y
lda #0 ; zero the link field of the new routine
sta [RoutinePtr]
sta [RoutinePtr],y
;-----------------------------------------------------------
;
; Restore interrupts, clear error code and fall into
; exit routine.
;
plp
tax ; put zero in x
AllDone pld
pla
pla
jml oErrOut8
SigError
ldx #BadSignature
bra AllDone
ENDP
title 'DeleteFromQueue'
****************************************************************
*
DeleteFromQueue PROC EXPORT
*
* Removes the indicated record from the linked list. First it
* checks the record for the required signature word. If the
* signature is not there, an error is returned.
*
* If the signature is ok, then we searc the list from the
* beginning for the indicated record. When the record is found,
* its next field is put in the the next field of the prior record.
*
* If the record is not found, an error is returned.
*
*
* Inputs:
* Pointer to Record To Remove
* Pointer to First Record Pointer
*
* Outputs:
* none
*
* External Refs:
import oErrOut8
import FindMatch
*
* Entry Points:
*
longa on ; mode
longi on
*
*
* Change History
*
* 12 Jan 88 Steven Glass
*
* Made code that searches for the specified pointer a
* subroutine so that it can be called by AddToQueue.
*
* Changed this call to use subroutine.
*
****************************************************************
DefineStack
OrigD WORD
CurPtr LONG
RTL1 block 3
rtl2 block 3
PtrToFirstPtr LONG
RoutinePtr LONG
PriorPtr equ PtrToFirstPtr ; better name for this location when in
; loop.
pha ; put space on stack for CurPtr
pha
phd ; save d-page
tsc ; turn stack to dpage
tcd
;-----------------------------------------------------------
;
; Check the signature. If it is not correct, we're
; done now.
;
ldy #HeaderSignature
lda [RoutinePtr],y
cmp #QueueSignature
bne SigError
;-----------------------------------------------------------
;
; Routine signature is ok, lets find the indicated record.
;
SigOK
pha ; space for result
pha
pei RoutinePtr+2
pei RoutinePtr
pei PtrToFirstPtr+2 ; save the pointer to the first pointer
pei PtrToFirstPtr
jsr FindMatch
PullLong PriorPtr
bcc FoundIt
;-----------------------------------------------------------
;
; We go to the end without finding the record. Restore
; interrupt state, put error code in x and join
; common exit routine.
;
ldx #RecordNotFound
bra AllDone
FoundIt
ldy #2 ; we set y to 2 here and not touch it again
; in this routine
;-----------------------------------------------------------
;
; Manipulate the Queue with interrupts off.
;
php ; save state of system
sei ; turn off interrupts
;-----------------------------------------------------------
;
; We found it. Take the value in the link field and put
; it in the link field of the previous record.
;
lda [RoutinePtr]
sta [PriorPtr]
lda [RoutinePtr],y
sta [PriorPtr],y
;-----------------------------------------------------------
;
; Restore interrupts, set error code and join common
; exit code.
;
plp
ldx #0
;-----------------------------------------------------------
;
; Exit now
;
AllDone pld ; restore d-page
pla ; clear off CurPtr
pla
jml oErrOut8 ; clean up stack.
;-----------------------------------------------------------
;
; There was a signature error. Set the error code and get
; out.
;
SigError
ldx #BadSignature ; error returned in x-reg
bra AllDone
ENDP
****************************************************************
*
FindMatch PROC
*
* Searches for the specified entry in the indicated queue.
*
* If the entry is found, the carry returns clear.
* If the entry is not found, the carry returns set.
*
* The output is the pointer to the entry that points to
* the specified entry, or the last entry in the list if no
* match is found.
*
*
* Inputs:
* Space For Result
* Routine Ptr
* PtrToFirstPtr
*
* Outputs:
* Entry That Points to Matching Entry
* Carry Clear indicates match
* Carry set indicates no match.
*
* External Refs:
* none
*
* Entry Points:
* none
*
longa on ; mode
longi on
*
****************************************************************
DefineStack
OrigD word
RTS word
PtrToFirstPtr LONG
RoutinePtr LONG
CurPtr LONG
phd
tsc
tcd
;-----------------------------------------------------------
;
; Put the first pointer in CurPtr
;
lda PtrToFirstPtr
sta CurPtr
lda PtrToFirstPtr+2
sta CurPtr+2
;
; Set y to 2 once and only once.
;
ldy #2
;-----------------------------------------------------------
;
; Loop through, looking to see when CurPtr is equal to
; the Pointer that was passed. If CurPtr is zero, we
; reached the end of the list and didn't find it.
;
Loop
lda [CurPtr]
ora [CurPtr],y
beq NoMatch
lda [CurPtr] ; is it this one?
cmp RoutinePtr
bne NotThisOne ; no
lda [CurPtr],y ; maybe, look at high word
cmp RoutinePtr+2
bne NotThisOne
Match
clc
bra Strip
NoMatch
sec
Strip
pld
plx
pla
pla
pla
pla
phx
rts
;-----------------------------------------------------------
;
; This was not the right one, so walk down the list by
; moving CurPtr to PriorPtr and putting the link
; into CurPtr. Go back to beginning of the loop.
;
NotThisOne
lda [CurPtr] ; move next to curPtr
tax
lda [CurPtr],y
sta CurPtr+2
stx CurPtr
bra Loop ; and loop
ENDP
END