Dilwyn Jones wrote: > clr.w d0 ;position in linkage to set Should be clr.w d1 of course. Though I think it doesn't really matter.
> clr.w d2 ;no bytes to be set (read only) > moveq.w #-1,d3 ;infinite timeout > ;find channel ID for window number passed and put in a0 > clr.l a1 ;pointer to data to set, in this case none as it's read only > move.w #$6f,d0 ;iop.slnk ($6f=dec.111) I suggest to *always* use symbolic names instead of direct numbers. Especially with things like the PTR2 offset and flag later on. In this case one would include the following files for example: include 'dev8_keys_qdos_io' include 'dev8_keys_con' The command can then be written as moveq #iop.slnk,d0 > trap #3 > tst.w d0 ;any error such as channel not open Error returns are long. Though it doesn't make much difference in practice, it'd be cleaner to use "tst.l d0". > move.w #$128,d7 ;offset $128 in PE linkage block > move.l 0(a1,d7.w),d6 Those two lines are equivalent to move.l pt_ident(a1),d6 ; Flag that identifies GD2 Again, by using symbolic names the code gets much clearer. And regarding the comment, the code already shows that something at position $128 is taken out of the PE block. A comment should not repeat what the code does, it should be one level higher and say /why/ the code does what it does. Sorry for being so teacher like, but years of formal computer science training do leave their traces ;-) > This is completely off the top of my head with no testing, no real > knowledge of what i'm doing, but filled with hope someone will read > this and either complete it into something workable or at least tell > me what i'm doing wrong! You asked for it, you got my comments ;-) It might be a good programing example to see how a clean, SMSQ/E programing style conform implementation of all this could look like: example_asm: <---> ; Example basic extension V1.00 © 2003 me section example include 'dev8_keys_qdos_io' include 'dev8_keys_con' include 'dev8_keys_qlv' include 'dev8_keys_err' include 'dev8_mac_proc' xref ut_chan1 xref ut_rtint ;+++ ; Initialise SBASIC procedures ;--- ex_initp lea ex_procs,a1 ; example procedures move.w sb.inipr,a2 jmp (a2) ex_procs proc_stt proc_end ; empty, no procedures, only functions proc_stt proc_ref PTR_ENV proc_ref GD2 proc_end ;+++ ; x = PTR_ENV (#ch) ; ; Returns 1 if the pointer environment is installed. Parameter Ch is ; optional. ;--- ptr_env jsr ut_chan1 ; get a channel id bne.s ex_rts cmpa.l a3,a5 ; any more parameters? bne.s ex_ipar ; yes, that's bad moveq #-1,d3 moveq #iop.pinf,d0 ; test for PE trap #3 moveq #1,d1 ; default to "PE installed" tst.l d0 ; 0 = PE installed beq.s ptr_ret moveq #0,d1 ; no PE, return 0 ptr_ret jmp ut_rtint ; return integer in D1 ;+++ ; x = GD2 (#ch) ; ; Returns 1 if the GD2 environment is available. Parameter Ch is ; optional. ;--- gd2 jsr ut_chan1 ; get a channel id bne.s ex_rts cmpa.l a3,a5 ; any more parameters? bne.s ex_ipar ; yes, that's bad clr.w d1 ; don't set anything, only get clr.w d2 ; address of PE linkage block moveq #-1,d3 moveq #iop.slnk,d0 trap #3 tst.l d0 bne.s ex_rts moveq #1,d1 ; default to "GD2 available" move.l pt_ident(a1),d0 cmp.l #pt.ident,d0 ; flag for GD2 beq.s gd2_ret moveq #0,d1 ; no GD2 available gd2_ret jmp ut_rtint ex_ipar moveq #err.ipar,d0 ex_rts rts end <---> example_link: <---> program win2_example_cde section example section utils input win2_example_rel library dev8_sbsext_utq_lib <---> Please note that the current sbsext_ut_lib of the SMSQ/E sources are *NOT* QDOS compatible anymore. Gave me some big headache when building Qpac2. That's why I created sbsext_utq_lib, which replaces only the problematic functions with ones that again run on all systems. Will send the sources to Wolfgang to have it delivered with the official distribution. Marcel