home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 13.ddi / QUEUE.ZIP / OOP.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-06-10  |  2.6 KB  |  130 lines

  1. ;This sample demonstrates the use of objects by using objects to create
  2. ;a simple linked-list mailing list.
  3.  
  4. MODEL SMALL
  5. LOCALS
  6.  
  7.  
  8. ;** Declare Mailing-List node object **
  9.  
  10. INCLUDE node.aso                ;Pull in node object
  11.  
  12. mlabel STRUC GLOBAL node METHOD {
  13.   init:dword = InitLabel            ;initialize address
  14.   deinit:dword = DeinitLabel            ;deinitialize address
  15.   print:word = PrintLabel            ;print mailling label
  16.   }
  17.   label_name    db 80 dup (?)            ;name
  18.   label_addr1    db 80 dup (?)            ;address line 1
  19.   label_addr2    db 80 dup (?)            ;address line 2
  20.   label_city    db 80 dup (?)            ;city
  21.   label_state    db 2 dup (?)            ;state
  22.   label_zip    db 9 dup (?)            ;zip code
  23.   label_phone    db 10 dup (?)            ;phone number
  24. ENDS
  25.  
  26. ;** Create instance of Mailing-List node virtual method table **
  27.  
  28. DATASEG
  29.  
  30. TBLINST
  31.  
  32. ;** Declare Mailing-List object **
  33.  
  34. INCLUDE list.aso                ;Pull in list object
  35.  
  36. mail STRUC GLOBAL list METHOD {
  37.   print:word = PrintList            ;print mailling list
  38.   }
  39. ENDS
  40.  
  41. ;** Create instance of Mailing-List virtual method table **
  42.  
  43. DATASEG
  44.  
  45. TBLINST
  46.  
  47. ;** Create instance of Mailing-List
  48.  
  49. mlist mail {}
  50.  
  51. CODESEG
  52.  
  53.     startupcode
  54.     ;;...
  55.     mov ax,@data
  56.     mov ds,ax
  57.     mov si,offset mlist
  58.     call ds:si method mail:init uses ds:bx pascal,ds si
  59.     ;;...
  60.     mov si,offset mlist
  61.     call ds:si method mail:print uses ds:bx pascal,ds si
  62.     ;;...
  63.  
  64.  
  65.  
  66. ;** Mailing-List methods **
  67.  
  68. ;Print out the mailling list.
  69.  
  70. ;** Mailing-List methods **
  71.  
  72. ;Print the mailling list
  73. PrintList PROC PASCAL NEAR
  74. ARG @@list:dword
  75. USES dx,bx,es,di
  76.     les di,@@list
  77.     call es:di method mail:first pascal,es di
  78. @@lp:    mov ds,dx
  79.     mov bx,ax
  80.     or ax,dx
  81.     jz @@dn
  82.     call ds:bx method mlabel:print uses cs:si pascal,ds bx
  83.         ; call es:di method mail:next pascal,ds bx
  84.         call ds:bx method mlabel:next pascal,ds bx
  85.         mov ds,dx
  86.         mov bx,ax
  87.     jmp short @@lp
  88. @@dn:    ret
  89. ENDP
  90.  
  91. ;** Mailing-List Node methods **
  92.  
  93. ;Initialize the Node object.
  94. ;This is the method "node|init"
  95. InitLabel PROC PASCAL FAR
  96. ARG @@node:dword
  97. USES es,di
  98.     les di,@@node
  99.     call es:di method node:init pascal,es di
  100.     sub ax,ax
  101.     mov es:[di.label_name],al
  102.     mov es:[di.label_addr1],al
  103.     mov es:[di.label_addr2],al
  104.     mov es:[di.label_city],al
  105.     mov es:[di.label_state],al
  106.     mov es:[di.label_phone],al
  107.     ret
  108. ENDP
  109.  
  110. ;Deinitialize the Node object.
  111. ;This is the method "node|deinit"
  112. DeinitLabel PROC PASCAL FAR
  113. ARG @@node:dword
  114. USES es,di
  115.     les di,@@node
  116.     call es:di method node:init pascal,es di
  117.     ret
  118. ENDP
  119.  
  120.  
  121. ;Print a mailing list label
  122. PrintLabel PROC PASCAL NEAR
  123. ARG @@node:dword
  124. USES es,di
  125.     ;;<<print the label here>>
  126.     ret
  127. ENDP
  128.  
  129. END
  130.