gno/sys/fileport/fileport/port.macros

1 line
12 KiB
Plaintext
Raw Normal View History

; ; Copyright (C) Kopriha Software, 1990 - 1991 ; All rights reserved. ; Licensed material -- property of Kopriha Software ; ; This software is made available solely pursuant to the terms ; of a Kopriha Software license agreement which governs its use. ; ; ; The following macros (port_routine/port_return) are support ; routines for IIGS port drivers. ; ; ; Macros: port_routine (<length>:<parm name>[,...])[,<work size>] ; - Enter a port driver routine ; ; port_return <length>:<return name>[,<completion routine>] ; - Exit a port driver routine ; - This macro must be followed by an RTL. By coding the ; macro this way you can customize the return (some, but ; not all port driver routines must return after a CMP #1. ; See the source to port.asm for the details). ; ; ; Note: These macros are derived from the csubroutine/creturn ; macros supplied with Orca/C (on the demos disk). ; MACRO &lab port_subroutine &parms,&work &lab anop Places the label from macro invocation aif c:&work,.a If there is a work parm goto .a lclc &work Local define work a string &work setc 0 Set work to zero .a .a gbla &totallen Global define totallen gbla &worklen Global define worklen gbla &PClen Global define length of PC &worklen seta &work Set worklen = work (type conversion) &totallen seta 0 Set totallen to zero &PClen seta 8 Set PC length to 8 (6(rtnPC*2)+1(direct page)+1(data bank)) aif c:&parms=0,.e If there are no parms to routine then goto .e lclc &len Local define char len lclc &p Local define char p lcla &i Local define int i &i seta 1 i = 1 .b .b &p setc &parms(&i) p = parms[i] &len amid &p,2,1 len = substr(p,2,1) aif "&len"=":",.c if len == ':' goto .c &len amid &p,1,2 len = substr(p,1,2) {First 2 chars} &p amid &p,4,l:&p-3 p = substr(p,4,strlen(p)-3) {get name} ago .d goto .d .c .c &len amid &p,1,1 len = substr(p,1,1) {only first char} &p amid &p,3,l:&p-2 p = substr(p,3,strlen(p)-2) {get name} .d .d We have a name and its length &p equ &totallen+&PClen+&work {name} equ totallen+PClen+work &totallen seta &totallen+&len totallen = totallen+len (length of parm) &i seta &i+1 i = i + 1 aif &i<=c:&parms,^b if i<#parms goto b (backwards goto) .e .e All parms setup (equ'd) tsc get stack pointer aif &work=0,.f If you need work space... sec add it onto the stack pointer sbc #&work tcs .f Stack is setup by here... phd Save the direct page tcd Set direct page == stack ptr mend Thus lda parm is a direct page reference... MACRO &lab port_return &returnparm,&comproutine ; ; Parse the return parameter (if defined). ; &lab anop Place any label from macro invocation lclc &len Local create len aif c:&returnparm,.a If there is a parameter goto .a lclc &returnparm Local create r (for parm length) &returnparm setc 0