home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PCACHSRC.ZIP / MEMBER.ASM < prev    next >
Assembly Source File  |  1991-09-11  |  2KB  |  59 lines

  1. ;MEMBER.ASM
  2. ;links with OOP.CPP.  Was created by firstly compiling to .ASM o/p
  3. ;with a stub in place, to obtain this skeleton.....
  4. ;  BCC -c -S OOP.CPP
  5. ;-c suppresses linking, -S generates .ASM output.
  6. ;Note that i have heavily optimised this and it looks nothing like the
  7. ;original skeleton.  By use of EXTRN's i have used the labels from the
  8. ;C++ module... note also the mangled names for the external functions.
  9.  
  10.     PUBLIC  @circle@place$qii
  11.     EXTRN   @box@place$qii:NEAR
  12.     EXTRN   @circle@draw$qv:WORD   ;NEAR
  13.     EXTRN   _box1:NEAR
  14.     ;note that I can't reference C++ member-data by name (eg;_col).
  15.  
  16. _TEXT SEGMENT BYTE PUBLIC 'CODE'
  17.     ASSUME cs:_TEXT
  18.  
  19. @circle@place$qii PROC NEAR
  20.     push bp
  21.     mov  bp,sp
  22.     push si
  23.     mov  si,[bp+4]        ;addr of current object (this).
  24.  
  25.     mov  ax,[bp+6]        ;parameter r, passed on stack.
  26.     mov  [si]+0,ax        ;accessing data of current object.
  27.     mov  ax,[bp+8]        ;parameter c
  28.     mov  [si]+2,ax        ;ditto. (copying c to col).
  29.  
  30.     ;to access another function, belonging to another object....
  31.     ;box1.place(1,2)....
  32.     mov  ax,2        ;put params on stack.
  33.     push ax
  34.     mov  ax,1
  35.     push ax
  36.     mov  ax,OFFSET _box1
  37.     push ax            ;pass addr of box1 to C++ function.
  38.     call @box@place$qii
  39.     add  sp,6        ;remove params from stack.
  40.  
  41.     ;to access another function, current object....
  42.     ;this->draw()....
  43.     push si            ;addr this object (no other params to pass).
  44.     mov bx,@circle@draw$qv
  45.     call [si+bx]
  46.     add  sp,2        ;remove param from stack.
  47.  
  48.     pop  si
  49.     pop  bp
  50.     ret
  51. @circle@place$qii ENDP
  52. _TEXT     ENDS
  53.     END
  54.  
  55. ;note that in theory we could access the data-members of any object,
  56. ;regardless of whether they're private or public.  You can see above
  57. ;how we got the address of _box1 into SI.... a simple indexed move
  58. ;can access any of _box1's fields.
  59.