* Vertb.s - Assembler source of interrupt server * * Copyright (c) 1990 Commodore-Amiga, Inc. * * This example is provided "as-is" and is subject to change; no warranties * are made. All use is at your own risk. No liability or responsibility * is assumed. _LVOAllocMem = -198 _LVOFreeMem = -210 _LVOOpenLibrary = -552 _LVOCloseLibrary = -414 _LVORawDoFmt = -522 _LVOWrite = -48 _LVOOutput = -60 * Start of Programme Start: * Open dos.library and setup _stdout move.l $4,a6 move.l #DOSName,a1 ;Library to open moveq #33,d0 ;Kickstart 1.2 jsr _LVOOpenLibrary(a6) move.l d0,a6 beq Exit move.l a6,DOSBase jsr _LVOOutput(a6) ;Get CLI Output move.l d0,_stdout beq Exit_CloseDOS * Allocate an Interrupt node structure moveq #22,d0 ;Interrupt_Sizeof move.l #$10001,d1 ;MEMF_PUBLIC|MEMF_CLEAR move.l $4,a6 jsr _LVOAllocMem(a6) move.l d0,VBInterrupt bne .SetupInterrupt ;We managed to open Okay. move.l #StringError,a3 ;Could not allocate memory jsr WriteDosMessage bra Exit_CloseDOS .SetupInterrupt * Initialize the Interrupt node: move.l VBInterrupt,a1 move.b #2,8(a1) ;is_Node.ln_Type = NT_INTERRUPT move.b #-60,9(a1) ;is_Node.ln_Pri = -60 lea VBInterruptName,a0 ;is_Node.ln_Name = "VertB-example" move.l a0,10(a1) lea Counter,a0 ;is_Data = &Counter move.l a0,14(a1) lea VertBServer,a0 ;is_Code = VertBServer move.l a0,18(a1) * put the new interrupt server into action: moveq #5,d0 ;intNumber move.l $4,a6 jsr -168(a6) ;AddIntServer move.l #String01,a3 jsr WriteDosMessage move.l $4,a6 move.l #$1000,d0 ;SIGBREAKF_CTRL_C jsr -318(a6) ;Wait() jsr WriteResult move.l $4,a6 moveq #5,d0 ;intNumber move.l VBInterrupt,a1 ;interrupt jsr -174(a6) ;RemIntServer() Exit_FreeMemory: move.l $4,a6 move.l VBInterrupt,a1 moveq #22,d0 ;Interrupt_SizeOf jsr _LVOFreeMem(a6) Exit_CloseDOS: move.l $4,a6 move.l DOSBase,a1 jsr _LVOCloseLibrary(a6) Exit: moveq #0,d0 rts putchproc: move.b d0,(a3)+ rts WriteResult: lea StringArgs,a0 ;Text String lea Counter,a1 ;Argument(s) lea putchproc,a2 ;Routine to copy byte lea Buffer,a3 ;Buffer string to output to move.l $4,a6 jsr _LVORawDoFmt(a6) WriteDosMessage: move.l a3,d2 moveq #0,d3 .GetSize tst.b (a3)+ beq WriteDos add.b #1,d3 bra .GetSize WriteDos: move.l DOSBase,a6 move.l _stdout,d1 jsr _LVOWrite(a6) rts VertBServer: jmp VertBIntAsm_Code VertBIntAsm_Code: add.l #1,Counter moveq #0,d0 rts DOSBase: dc.l 0 Counter: dc.l 0 VBInterrupt: dc.l 0 _stdout: dc.l 0 DOSName: dc.b 'dos.library',0 VBInterruptName: dc.b 'VertB-example',0 StringError: dc.b 'Can not allocate interrupt structure',10,0 String01: dc.b 'VBlank server will increment a counter every frame',10 dc.b 'Counter now zero - wait a few seconds then press CTRL-C',10,0 StringArgs: dc.b '%ld vertical blanks occured.',10,0 Buffer: ds.b 60 END