home *** CD-ROM | disk | FTP | other *** search
- COMMENT %
- ==============================================================================
- Defines an object.
-
- Passed: Obj - Object name
- Objs - Ancestor list
- Instances - Instance variable list
- Messages - Message list
-
- =============================================================================%
- defObj MACRO Obj,Objs,Instances,Messages
- LOCAL ObjTbl,MsgTbl,InstTbl
-
- ObjTbl LABEL WORD
- objsDef Obj,<Objs>
-
- MsgTbl LABEL WORD
- msgsDef Obj,<Messages>
-
- InstTbl LABEL WORD
- instDef <Instances>
-
- ALIGN 2
- PUBLIC Obj
- Obj _Object <ObjTbl,MsgTbl,InstTbl>
-
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Defines objects.
-
- Passed: Obj - Object name
- Objs - Ancestor list
-
- =============================================================================%
- objsDef MACRO Obj,Objs
- DW Obj
- IRP Obj,<Objs>
- DW Obj
- ENDM
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Defines messages.
-
- Passed: Obj - Object name
- Messages - Message list
-
- =============================================================================%
- msgsDef MACRO Obj,Messages
- IRP Msg,<Messages>
- DB Msg ;Msg# identifies msg
- IFNDEF Obj&&Msg
- DW Nil ;Obj has no local methods
- ELSE
- DW Obj&&Msg ;Obj has local methods
- ENDIF
- ENDM
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Defines instances variables.
-
- Passed: Instances - Instance variable list
-
- =============================================================================%
- instDef MACRO Instances
- X = 0
- Y = 0
- IRP Inst,<Instances>
- defInst Inst,%X,%Y
- ENDM
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Defines an instance variable.
-
- Passed: Inst - Instance variable name
- Cnt - Instance variable field number
- Size - Size of instance variable
-
- =============================================================================%
- defInst MACRO Inst,Cnt,Size
- IFIDN <Cnt>,<0>
- X = X+1
- ELSE
- IFIDN <Cnt>,<1>
- X = X+1
- Y = Inst
- ELSE
- X = 0
- defVar Size,Inst
- ENDIF
- ENDIF
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Defines a data item.
-
- Passed: Size - Size of data in bytes
- Value - Value of data item
-
- =============================================================================%
- defVar MACRO Size,Value
- IFIDN <Size>,<1>
- DB Value
- ELSE
- IFIDN <Size>,<2>
- DW Value
- ELSE
- IFIDN <Size>,<4>
- DD Value
- ELSE
- IFIDN <Size>,<8>
- DQ Value
- ELSE
- IFIDN <Size>,<10>
- DT Value
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDM
-
-
-
-
- COMMENT %
- ==============================================================================
- Defines a message.
-
- Passed: Obj - Object name
- Msg - Message name
- Methods - Method list
-
- =============================================================================%
- defMsg MACRO Obj,Msg,Methods
- ALIGN 2
- Obj&Msg _Message <Methods>
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Sets us SI to point to object, and calls initObject procedure.
-
- =============================================================================%
- initObj MACRO Obj
- lea si,Obj ;Pass object ptr
- call initObject ;Find all ancestors
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Gets an object's instance variable.
-
- Passed: Dest- Destination register
- Var - Instance variable name
- Obj - Source object
-
- =============================================================================%
- getInst MACRO Dest,Var,Obj
- IFNB <Obj>
- IFIDN <Obj>,<Self>
- mov si,WORD PTR[Self]
- mov si,WORD PTR[si].Instances
- ELSE
- IFIDN <si>,<Obj>
- mov si,WORD PTR[si].Instances
- ELSE
- mov si,Obj&.Instances
- ENDIF
- ENDIF
- ENDIF
- mov Dest,[si+Var]
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Gets an object's instance variable, but object is pointed to by one of
- Self's instance variables.
-
- Passed: Dest- Destination register
- Var - Instance variable name
- Obj - Source object instance variable
-
- =============================================================================%
- getInst$ MACRO Dest,Var,Obj
- mov si,WORD PTR[Self]
- mov si,WORD PTR[si].Instances
- mov si,[si+Obj]
- mov si,WORD PTR[si].Instances
- mov Dest,[si+Var]
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Sets an object's instance variable.
-
- Passed: Var - Instance variable name
- Source - Source register
- Obj - Source object
- Size - Size of data
-
- =============================================================================%
- setInst MACRO Var,Source,Obj,Size
- IFNB <Obj>
- IFIDN <Obj>,<Self>
- mov si,WORD PTR[Self]
- mov si,WORD PTR[si].Instances
- ELSE
- mov si,Obj&.Instances
- ENDIF
- ENDIF
- setInst_ Var,Source,Size
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Sets an object's instance variable, but object is pointed to by one of
- Self's instance variables.
-
- Passed: Var - Instance variable name
- Source - Source register
- Obj - Source object instance variable
- Size - Size of data
-
-
- =============================================================================%
- setInst$ MACRO Var,Source,Obj,Size
- mov si,WORD PTR[Self]
- mov si,WORD PTR[si].Instances
- mov si,[si+Obj]
- mov si,WORD PTR[si].Instances
- setInst_ Var,Source,Size
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Assembles move instruction based on source register.
-
- =============================================================================%
- setInst_ MACRO Var,Source,Size
- IFIDN <Source>,<al>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<ah>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<bl>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<bh>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<cl>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<ch>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<dl>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<dh>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<ax>
- mov WORD PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<bx>
- mov WORD PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<cx>
- mov WORD PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<dx>
- mov WORD PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<di>
- mov WORD PTR[si+Var],Source
- ELSE
- IFIDN <Source>,<si>
- mov WORD PTR[si+Var],Source
- ELSE
- IFIDN <Size>,<1>
- mov BYTE PTR[si+Var],Source
- ELSE
- IFIDN <Size>,<2>
- mov WORD PTR[si+Var],Source
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDIF
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Sends the specified message to the specified table of enslaved objects.
-
- =============================================================================%
- sendSlaves MACRO Tbl,Msg,Args
- LOCAL sds1
-
- mov cx,Wptr[Tbl] ;Get object count
- sds1: add Tbl,2 ;Point to next object obj
- mov si,Wptr[Tbl] ;Get object obj ptr
- pushData <Self,Tbl,cx>
- send si,Msg,Args ;Send object the message
- popData <cx,Tbl,Self>
- loop sds1
- ENDM
-
-
-
- COMMENT %
- ==============================================================================
- Executes the specified object/message pair sends.
-
- =============================================================================%
- sendLoop MACRO Reg,CountOff,TblOff
- LOCAL sdlp1,sdlp2
-
- push Self
- xor ch,ch ;Zero hi-order of count reg
- mov cl,Bptr[Reg+CountOff] ;Get count byte
- mov di,Wptr[Reg+TblOff] ;Get beginning of tbl
- sdlp1: pushData <cx,di>
- mov si,Wptr[di] ;Get obj ptr
- neq si,<OFFSET Self>,sdlp2 ;Jump if not sending to Self
- mov si,Wptr[si] ;Else get obj ptr
- sdlp2: mov dx,Wptr[di+2] ;Get msg number
- call sendMsg ;Send message
- popData <di,cx>
- add di,4 ;Point to next msg
- loop sdlp1 ;Do it again
- pop Self
- ENDM
-
-
-
- COMMENT %
- ==========================================================================
- Sets up stack, SI with object pointer, DX with message number, and calls
- sendMsg procedure.
-
- Passed: Obj - Name of receiving object
- Msg - Message number
-
- =========================================================================%
- send MACRO Obj,Msg,ArgList
- pushArgs ArgList ;Push arguments onto stack
-
- IFIDN <Obj>,<Self> ;If object is Self
- mov si,Wptr[Self] ;Get object ptr from it
- ELSE
- IFDIF <Obj>,<si> ;If object ptr not in SI
- lea si,Obj ;Load SI with ptr to object
- ENDIF
- ENDIF
-
- IFDIF <Msg>,<dx> ;If msg number not in DX
- mov dx,Msg ;Put it in DX
- ENDIF
-
- call sendMsg ;Send message
-
- IFNB <ArgList> ;If arguments
- X = 0 ;Init stack depth counter
- IRP Arg,<ArgList> ;For every arg on stack
- X = X+2 ;Increment depth counter
- ENDM
- add sp,X ;Reset stack pointer
- ENDIF
- ENDM
-
-
-
- COMMENT %
- ==========================================================================
- Pushes up to ten arguments onto the stack.
-
- =========================================================================%
- pushArgs MACRO A0,A1,A2,A3,A4,A5,A6,A7,A8,A9
- IFB <A0> ;If no more arguments
- EXITM ;Exit macro
- ENDIF
-
- IFIDN <A0>,<ax> ;If arg in AX
- push ax ;Push AX
- ELSE
- IFIDN <A0>,<bx> ;If arg in BX
- push bx ;Push BX
- ELSE
- IFIDN <A0>,<cx> ;If arg in CX
- push cx ;Push CX
- ELSE
- IFIDN <A0>,<dx> ;If arg in DX
- push dx ;Push DX
- ELSE
- mov bx,A0 ;Else move into BX
- push bx ;Push BX
- ENDIF
- ENDIF
- ENDIF
- ENDIF
-
- pushArgs A1,A2,A3,A4,A5,A6,A7,A8,A9
- ENDM
-
-
-
- COMMENT %
- ==========================================================================
- Finds the specified message for specified object.
-
- Passed: Msg - Message number
- Obj - Addr ptr to object structure
-
- Passes: si - Pointer to combined method pointer
-
- =========================================================================%
- findMsg MACRO Obj,Msg,Lbl
- LOCAL fdmg1,fdmg2
-
- IFDIF <Obj>,<si> ;If object ptr is not in SI
- mov si,Obj ;Put it there
- ENDIF
-
- mov di,Wptr[si].Instances
- ;Addr of msg tbl end
- mov si,Wptr[si].Messages
- ;Addr of msg tbl beginning
-
- fdmg1: lodsb ;Fetch msg number
- eq al,Msg,fdmg2 ;Exit if message is found
- add si,2 ;Else point to next message
- cmp si,di ;More messages?
- jb fdmg1 ;If so continue search
-
- IFNB <Lbl> ;If label provided
- jmp Lbl ;Jump to it upon failure
- ENDIF
- fdmg2:
- ENDM
-
-
-
-