QDOS Internals

Anything you never knew you wanted to know about the Sinclair QL.

User Tools

Site Tools


Table of Contents


This trap links in a new Thing.

Call ParametersReturn Parameters
D0.B$26D0.LError code.
A1.LAddress of Thing linkage A0.LPreserved.


ERR_EXName already exists.


  • None of the "Thing" Traps work with Qdos or SMSQE. However, if the HOTKEY system v 2.03 and beyond is available vectors are provided to enable the thing system to be used. SMSQE contains an appropriate HOTKEY system. See below.
  • All registers not shown above are not used on entry and are preserved on exit.
  • The linkage block, shown below, should have TH_THING, TH_FREE, TH_FFREE, TH_REMOV, TH_VERID, TH_NSHAR and TH_NAME filled in.
  • The space for the linkage block should be in the common heap and should be the first, or only, item in that allocated space.

Thing Linkage Block

TH_NXTTH$00longpointer to next linkage block
TH_USAGE$04longusage list
TH_FRFRE$08longcode to force remove a Thing
TH_FRZAP$0Clongcode when Thing owner is removed
TH_THING$10longpointer to Thing itself
TH_USE$14longcode to use the Thing or 0
TH_FREE$18longcode to free the Thing or 0
TH_FFREE$1Clongcode to force free the Thing or 0
TH_REMOV$20longcode to tidy up before removing a Thing or 0
TH_NSHAR$24byteset if Thing not shareable
TH_CHECK$25bytecheck byte of name - set by LTHG
TH_VERID$26longversion ID eg "1.03"
TH_NAME$2Astringname of Thing


The Thing called THING allows, via HOTKEY (v 2.03 +), use of things. The THING thing is:

THH_ENTR$08longaddress of TH_ENTRY routine
THH_EXEC$0Clongaddress of TH_EXEC routine


This vector gives the same result as the Trap #1 thing routines with codes $26 to $2C. The parameters to be used are exactly as for the Traps. The routines, apart from this one, are:


The vector TH_EXEC allows an executable thing to be called. At entry D0 holds the owner ID, 0 or -1. The MSW of D2 contains the priority of the job to be executed and the LSW the timeout. A0 points to the thing name and A1 to the parameter string.


The first example shows how to get one of the vectors.

* Routine to get Thing Vector to A4

; On entry D0.W = 8 for THH_ENTR and $0C for THH_EXEC.
; On a successful exit A4 contains the vector.

vecr	reg	d1-3/d7/a0
	movem.l	vecr,-(sp)		; Save registers
	move.w	d0,d3			; Keep parameter in D3
	moveq	#mt_inf,d0		; Get address . .
	trap	#1			; . . of SYS_VARS
	move	sr,d7			; Keep condition codes
	trap	#0			; To supervisor mode
	move.l	sv_thingl(a0),d1	; address of Thing list . .
	beq	not_there ---->
	movea.l	d1,a0			; . . to A0
	move.l	(a0),d1			; Last linkage block? . .
	beq	found			; . . yes
	movea.l	d1,a0			; try the . .
	bra	thvec_lp		; . . next one
 	moveq	#-7,d0			; ERROR Not found
	bra	th_rt
found	movea.l	$10(a0),a0		; Pointer to THING Thing
	cmpi.l	#-1,4(a0)		; THING? . .
	bne	not_there ---->		; . . NO!
	movea.l	(a0,d3.w),a4		; Get the vector to A4
th_rt	move	d7,sr			; Back to user mode
	movem.l	(sp)+,vecr		; Replace registers
	tst.l	d0			; Set condition codes

The second example shows an executable program being linked in. Note that the routine SMS_LTHG assumes that the linkage block is the first item in a block of allocated space and places the address of the linkage block 12 bytes earlier than its start assuming it to be the header of allocated space. To allow that to happen sixteen zero bytes are placed at PSEUDO just before that linkage block.

	LEA	TLINK,A1	; address of linkage block
	LEA	N_THING,A0	; address of Thing itself
	MOVE.L	A0,$10(A1)	; set address of Thing in linkage
	BSR	GU_THVEC	; Get the vector
	BNE	OOPS_1	---->
	MOVEQ	#$SMS_LTHG,D0	; $26	
	JSR	(A4)		; Link in the Thing
; This is the NET_PEEK Thing

N_THING	DC.L	"THG%",1	; Type is 1 = executable code
	DC.L	HEADZ-N_THING	; -> Start of header
	DC.L	PRS-HEADZ	; Size of header
	DC.L	D_SPACE		; Data space
	DC.L	STARTA-N_THING	; -> Start of program

; This is the linkage block

PSEUDO  DC.L    0,0,0,0         ; pseudo allocated space header

TLINK	DCB.W	19,0		; All zero until . .
	DC.L	"1.00"		; . . Version
	DC.W    8		; Length of name
	DC.B    "NET_PEEK"	; name
	DS.W	0		; To even boundary
qdosmsq/traps/trap_1/lthg.txt · Last modified: 2010/11/06 11:20 by george.gwilt