mirror of
https://github.com/marketideas/qasm.git
synced 2026-10-24 22:02:28 +00:00
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.
1 line
9.3 KiB
Plaintext
1 line
9.3 KiB
Plaintext
**********************************************************************
|
|
*
|
|
* GSTextEdit Version 1.0
|
|
* File: memory.aii
|
|
*
|
|
* Copyright Apple Computer, Inc. 1988-89
|
|
* All rights reserved
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* Notes
|
|
*
|
|
* All the routines in GSTextEdit must be called in full native mode and
|
|
* return that way.
|
|
*
|
|
* All the files in GSTextEdit must be assembled with the "-unsafe"
|
|
* option to pass unresolved references to the linker.
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* Change History
|
|
*
|
|
* 30 May 89 Dave Good
|
|
*
|
|
* Cleaned up comments for final release.
|
|
*
|
|
**********************************************************************
|
|
|
|
|
|
INCLUDE 'GlobalIncludes'
|
|
|
|
|
|
****************************************************************
|
|
; A,X contain the size of the new handle
|
|
; Y contains the atrributes
|
|
; on exit A,X contain the new handle
|
|
;---------------------------------------------------------------
|
|
Memory1Proc PROC
|
|
|
|
;---------------------------------------------------------------
|
|
EXPORT GetSmallHandle
|
|
EXPORT GetLargeHandle
|
|
EXPORT GetSpecialHandle
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
GetSmallHandle ldx #0 ;the high word of the size is zero
|
|
;---------------------------------------------------------------
|
|
GetLargeHandle ldy #0 ;the attributes are also zero
|
|
;---------------------------------------------------------------
|
|
GetSpecialHandle PushLongSpace ;space for result
|
|
PushAX ;the size of the handle to create
|
|
PushZWord UserID ;get this from the Global Variables
|
|
phy ;free floating, everywhere
|
|
PushLongSpace ;space for ignored pointer
|
|
_NewHandle
|
|
bcs error
|
|
PullAX ;get the returned handle in A,X
|
|
rts ;return carry clr
|
|
;---------------------------------------------------------------
|
|
error tax
|
|
pla ; discard the bad handle..
|
|
pla
|
|
rts
|
|
;---------------------------------------------------------------
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
Memory2Proc PROC
|
|
|
|
;---------------------------------------------------------------
|
|
EXPORT GetTerminatedHandle
|
|
EXPORT GetClearHandle
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
DefineStack
|
|
origD word
|
|
thePtr long
|
|
theHandle long
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
GetTerminatedHandle lda #4 ;get the new handle
|
|
jsr GetSmallHandle
|
|
bcs error
|
|
PushAX
|
|
PushAX
|
|
|
|
phd
|
|
tsc
|
|
tcd
|
|
|
|
Deref theHandle,thePtr ;this leaves Y-Reg equal to two
|
|
lda #$FFFF
|
|
sta [thePtr]
|
|
sta [thePtr],y
|
|
|
|
done pld ;restore the original direct page
|
|
PullAX ;pull off garbage
|
|
PullAX ;get the returned handle in A,X
|
|
clc
|
|
error rts
|
|
;---------------------------------------------------------------
|
|
GetClearHandle pha ;save the size
|
|
jsr GetSmallHandle
|
|
ply ;recover the saved size
|
|
bcs error
|
|
PushAX
|
|
PushAX
|
|
|
|
phd
|
|
tsc
|
|
tcd
|
|
|
|
tyx ;save the saved size
|
|
Deref theHandle,thePtr ;this leaves Y-Reg equal to two
|
|
txa ;get back the size
|
|
tay
|
|
lsr a
|
|
lda #0 ;reload the zero (doesn't clear carry)
|
|
bcc loop
|
|
dey
|
|
shortm
|
|
sta [thePtr],y
|
|
longm
|
|
loop dey
|
|
dey
|
|
sta [thePtr],y
|
|
bne loop
|
|
clc ;indicate no error
|
|
bra done
|
|
;---------------------------------------------------------------
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
Memory3Proc PROC
|
|
|
|
;---------------------------------------------------------------
|
|
EXPORT LockHandle
|
|
EXPORT DerefHandle
|
|
EXPORT UnlockHandle
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
DSECT 1
|
|
origD word
|
|
returnAddr word
|
|
theHandle long
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
LockHandle phd
|
|
tsc
|
|
tcd
|
|
ldy #4
|
|
lda [theHandle],y
|
|
ora #$8000
|
|
sta [theHandle],y
|
|
bra derefIt
|
|
;---------------------------------------------------------------
|
|
DerefHandle phd
|
|
tsc
|
|
tcd
|
|
derefIt ldy #2
|
|
lda [theHandle],y
|
|
tax
|
|
lda [theHandle]
|
|
sta theHandle+2
|
|
exit pld
|
|
ply
|
|
pla
|
|
pla
|
|
phy
|
|
rts
|
|
;---------------------------------------------------------------
|
|
UnlockHandle phd
|
|
tsc
|
|
tcd
|
|
ldy #4
|
|
lda [theHandle],y
|
|
and #$7FFF
|
|
sta [theHandle],y
|
|
bra exit
|
|
;---------------------------------------------------------------
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
Memory4Proc PROC
|
|
|
|
;---------------------------------------------------------------
|
|
EXPORT LockRecordHandle
|
|
EXPORT DerefRecordHandle
|
|
EXPORT UnlockRecordHandle
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
LockRecordHandle ldy #4
|
|
lda [RecordHandle],y
|
|
ora #$8000
|
|
sta [RecordHandle],y
|
|
movl RecordHandle,RecordInUse ;mark this record as in use
|
|
;---------------------------------------------------------------
|
|
DerefRecordHandle Deref RecordHandle,RecordPtr
|
|
rts
|
|
;---------------------------------------------------------------
|
|
UnlockRecordHandle ldy #4
|
|
lda [RecordHandle],y
|
|
and #$7FFF
|
|
sta [RecordHandle],y
|
|
stzl RecordInUse ;clear the record in use variable
|
|
rts
|
|
;---------------------------------------------------------------
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
DerefAX PROCNAME Export
|
|
|
|
DSECT 1
|
|
theHandle long
|
|
|
|
phd
|
|
phx
|
|
pha
|
|
tsc
|
|
tcd
|
|
ldy #2
|
|
lda [theHandle],y
|
|
tax
|
|
lda [theHandle]
|
|
sta theHandle+2
|
|
pla
|
|
pla
|
|
pld
|
|
rts
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
Memory5Proc PROC
|
|
|
|
;---------------------------------------------------------------
|
|
EXPORT KillRgn
|
|
EXPORT KillHandle
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
KillRgn ply ;get the return address into Y-Reg
|
|
PullAX ;get the region handle into A-Reg and X-Reg
|
|
phy ;push the return address back on the stack
|
|
;---------------------------------------------------------------
|
|
KillHandle PushAX ;push passed handle on the stack
|
|
_DisposeHandle
|
|
tax ;save the error code in X-Reg
|
|
rts ;the carry will be set/clr by _DisposeH.
|
|
;---------------------------------------------------------------
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
Memory6Proc PROC
|
|
|
|
;---------------------------------------------------------------
|
|
EXPORT QuickMove
|
|
EXPORT BlockMove
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
QuickMove lda MoveLength+2
|
|
bne entry1
|
|
ldy MoveLength
|
|
beq @quickExit
|
|
cpy #10
|
|
bge entry2
|
|
dey
|
|
|
|
lda SourcePtr+2
|
|
cmp DestPtr+2
|
|
bne @doQuick
|
|
lda DestPtr
|
|
cmp SourcePtr
|
|
bge @doQuick
|
|
adc #10
|
|
cmp SourcePtr
|
|
bge entry3
|
|
|
|
@doQuick shortm
|
|
@loop lda [SourcePtr],y
|
|
sta [DestPtr],y
|
|
dey
|
|
bpl @loop
|
|
longm
|
|
@quickExit rts
|
|
;---------------------------------------------------------------
|
|
BlockMove lda MoveLength+2
|
|
entry1 ora MoveLength
|
|
beq done
|
|
|
|
entry2 lda SourcePtr+2
|
|
cmp DestPtr+2
|
|
blt backwards
|
|
bne forewards
|
|
entry3 lda SourcePtr
|
|
cmp DestPtr
|
|
blt backwards
|
|
;---------------------------------------------------------------
|
|
forewards PushZLong SourcePtr
|
|
PushZLong DestPtr
|
|
ldy #%0000100000000101
|
|
;---------------------------------------------------------------
|
|
doIt PushZLong MoveLength
|
|
phy
|
|
jsl $E10200 ;memory mover entry point
|
|
done rts
|
|
;---------------------------------------------------------------
|
|
backwards decl MoveLength
|
|
lda SourcePtr
|
|
clc
|
|
adc MoveLength
|
|
tax
|
|
lda SourcePtr+2
|
|
adc MoveLength+2
|
|
pha
|
|
phx
|
|
lda DestPtr
|
|
clc
|
|
adc MoveLength
|
|
tax
|
|
lda DestPtr+2
|
|
adc MoveLength+2
|
|
pha
|
|
phx
|
|
incl MoveLength
|
|
ldy #%0000100000001010
|
|
bra doIt
|
|
;---------------------------------------------------------------
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
GetHandleSize PROCNAME Export
|
|
|
|
;---------------------------------------------------------------
|
|
DefineStack
|
|
origD word
|
|
returnAddr word
|
|
theHandle long
|
|
;---------------------------------------------------------------
|
|
|
|
;---------------------------------------------------------------
|
|
phd ;save the old direct page
|
|
tsc ;setup our new direct page
|
|
tcd
|
|
|
|
ldy #HandleRecord.length+2
|
|
lda [theHandle],y
|
|
tax
|
|
dey
|
|
dey
|
|
lda [theHandle],y
|
|
|
|
ldy returnAddr
|
|
sty theHandle+2
|
|
pld ;restore the original direct page
|
|
ply ;pull off the garbage
|
|
ply
|
|
rts
|
|
;---------------------------------------------------------------
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
SetHandleSize PROCNAME Export
|
|
|
|
;---------------------------------------------------------------
|
|
PushAX ;push the size to set to
|
|
|
|
lda 9,s ;copy the handle
|
|
pha
|
|
lda 9,s
|
|
pha
|
|
_SetHandleSize
|
|
tax ;save the error code in X-Reg
|
|
|
|
ply ;save return address
|
|
pla ;pull off the passed handle
|
|
pla
|
|
phy ;restore return address
|
|
rts ;carry will be set/clr by SetHandleSize.
|
|
;---------------------------------------------------------------
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
DerefTempPtr PROCNAME Export
|
|
|
|
Deref TempPtr,TempPtr ;WARNING: this code must NOT change the
|
|
rts ;..carry flag
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
TerminateTempPtr PROCNAME Export
|
|
|
|
lda #$FFFF
|
|
sta [TempPtr],y
|
|
iny
|
|
iny
|
|
sta [TempPtr],y
|
|
rts
|
|
|
|
ENDP
|
|
|
|
****************************************************************
|
|
|
|
END
|