home *** CD-ROM | disk | FTP | other *** search
-
- incdir "includes:"
-
- IFND EXEC_EXECBASE_I
- INCLUDE exec/execbase.I
- ENDC
-
- IFND EXEC_TYPES_I
- INCLUDE exec/types.i
- ENDC
-
- IFND EXEC_LIBRARIES_I
- INCLUDE exec/libraries.i
- ENDC
-
- IFND EXEC_NODES_I
- include "exec/nodes.i"
- ENDC
-
- IFND EXEC_MEMORY_I
- include "exec/memory.i"
- ENDC
-
- IFND EXEC_EXEC_LIB_I
- include "exec/exec_lib.i"
- ENDC
-
- IFND MISC_SURVEYMEM_I
- include "Misc/surveymem.i"
- ENDC
-
- CALLBASE: MACRO
- jsr _LVO\1(a6)
- ENDM
-
-
- ;3 handy macros to do all the desired operations.
- ;Feel free to change the names ;-)
-
- SMON: MACRO ;ON=>counters begin to calc deltas.
- moveq #SMMF_On,d0
- bsr Sendmsg
- ENDM
-
- SMFRZ: MACRO ;FREEZE=>STOPS THE COUNTERS.
- moveq #SMMF_freeze,d0 ;then check the difference! yep!
- bsr Sendmsg
- ENDM
-
- SMOFF: MACRO ;OFF=>clears counters
- moveq #SMMF_Off,d0 ;not very useful here,though...
- bsr Sendmsg
- ENDM
-
-
-
- ;Sorry for all C users ! ...this time YOU will be obliged to look at
- ;an 'unfriendly language'
- ;Two reasons for this: * I only "Read C" enough to put things back to ASM!
- ; * Let's reverse the roles once ;-)
- ; (personal revenge from the RKRMs)
-
- ;This source works Ok with Asmone,should be no problem with Devpac.
- ;case insensitive of course!
-
-
- ; how you should do it:simple,no?
- ;
- ;
- ; bsr InitSMport
- ; .....
- ; SMON
- ; < routine that allocates & deallocates memory >
- ; SMOFF
- ; .....
- ; bsr CloseSMport
-
-
-
- ;*************************** Sample program ******************************
- section "dummy",code
-
- BEGIN: bsr InitSMport ;once for all
-
-
- ;example:program loses 212 bytes (Hmmm I just wonder why ;-)
- ;in fact,SM will show '216' but it's only bcoz of Exec's roundup routines
-
- SMON ;counters....go!
-
- move.l #212,d0
- move.l #MEMF_ANY+MEMF_CLEAR,d1
- CALLEXEC ALLOCMEM
-
- ;hmmmm...forgotten something?
- SMFRZ
-
- bsr CloseSMport
- moveq #0,d0
- rts
-
- ;****************************************************************************
-
-
-
-
-
- ;----------------------------------------------------------------------------
- ; The subroutines
- ;They test everything,so you don't have to worry if Surveymem is present/not.
- ;
- ;----------------------------------------------------------------------------
-
-
- ;Tries to create a replyport (so when we send a message,we can wait for it
- ;to be received)
- ;*****************
- InitSMport:
- CALLEXEC Createmsgport
- tst.l d0
- move.l d0,SMreplyPort
- rts
-
-
- CloseSMport:
- tst.l SMreplyport
- bne.s .close
- rts
- .close: move.l SMreplyport,a0
- CALLEXEC Deletemsgport
- rts
-
- ;
- ;The sendroutine. INPUT:D0.l=SMMF_flag
- ;--------------------------------------------------------------------------
- SendMsg:tst.l SMreplyport
- bne.s .ok
- rts
- .ok: movem.l a0-a6/d1-d7,-(sp)
- bsr .do
- movem.l (sp)+,a0-a6/d1-d7
- rts
- .do: lea Themsg,a5
- move.w #SMm_SIZEOF,MN_LENGTH(a5)
- move.l SMReplyport,MN_REPLYPORT(a5)
- move.l #SM_Mark,SMm_code(a5)
- move.l d0,SMm_data(a5)
- clr.b FLG_port
- CALLEXEC FORBID
- lea mainportname,a1
- CALLBASE FINDPORT
- tst.l d0
- beq.b .noport
- move.b #1,FLG_port
- move.l d0,a0 ;if port=ok,send!
- move.l a5,a1
- CALLBASE PUTMSG
- .noport:
- CALLBASE PERMIT
-
- tst.b FLG_port
- bne .mainportok
- rts
- .mainportok:
- move.l SMReplyport,a0
- CALLBASE WAITPORT ;then wait at our replyport (til SM has read our msg)
- rts ;of course we get back 'Themsg' in d0.
-
- SMreplyport: dc.l 0
- Themsg: ds.b SMm_SIZEOF
- FLG_port: dc.b 0 ;internal flag:if non zero,means port was found
- mainportname: dc.b "Surveymem Main Port",0
- even
-
-