home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l010 / 5.ddi / C5.ARC / DISKSAMP.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-12-20  |  3.0 KB  |  111 lines

  1. ; ------------------------------------------------------------------
  2. ;
  3. ; The following is the source code for a sample disk-based blackbox.
  4. ; It takes the following parameters:
  5. ;
  6. ;     FILE_NAME: a pointer to a text variable (text is always by ref.)
  7. ;     PASSED_INTEGER: an integer, passed by value
  8. ;     RETURNED_INTEGER: an integer, passed by reference
  9. ;     RETURNED_CHECK: a check box, passed by reference.
  10. ;
  11. ; For the sake of simplicity, the BlackBox does not perform any
  12. ; elaborate function, but merely adds 2 to the passed integer and
  13. ; returns the sum in the returned integer, and returns a 1 in
  14. ; returned check if file_name is not an empty string, and a 2 if
  15. ; file_name is an empty string.
  16. ;
  17. ; The pointer to the parameter block that is returned by the int 0F3H
  18. ; call points to the language_type integer value.  The parameter after
  19. ; that will be the last parameter requested by the BlackBox.  The
  20. ; first parameter requested by the blackbox will be at the highest
  21. ; address.
  22. ;
  23. ; Again, the form and style of a disk-based BlackBox is largely up to the
  24. ; preference of the developer.    Notice that a stack segment is declared
  25. ; since a disk-based blackbox should be written as a stand-alone .EXE.
  26. ;
  27. ; ------------------------------------------------------------------
  28.  
  29.  
  30.  
  31.  
  32.  
  33. data     segment byte public 'DATA'
  34.  
  35.  
  36. parameter_structure    STRUC
  37.  
  38. language_value       dw    ?           ; passed by value
  39. returned_check       dd    ?           ; passed by reference
  40. returned_integer   dd    ?           ; passed by reference
  41. passed_integer       dw    ?           ; passed by value
  42. file_name       dd    ?           ; passed by reference
  43.  
  44. parameter_structure    ENDS
  45.  
  46.  
  47. parameter_block    dd    ?           ; address of parameter block
  48.  
  49.  
  50. data     ends
  51.  
  52.  
  53. stack     segment para stack 'STACK'
  54.  
  55.      db   1024 dup (0)
  56.  
  57. stack     ends
  58.  
  59.  
  60. cseg     segment byte public 'CODE'
  61.      assume cs:cseg, ds:data, ss:stack
  62.  
  63.  
  64. public sample_disk_blackbox
  65. sample_disk_blackbox    proc
  66.  
  67.      mov       ax,data
  68.      mov       ds,ax           ; initialize the ds register
  69.  
  70.      mov       ax,214*256 + 7
  71.      int       0F3H            ; get the pointer to the parameters
  72.  
  73.      mov       word ptr parameter_block,bx
  74.      mov       word ptr parameter_block[2],dx
  75.  
  76.      les       di,parameter_block
  77.      mov       ax,es:[di].passed_integer     ; move into ax the integer
  78.      inc       ax
  79.      inc       ax                 ; add two to passed integer
  80.  
  81.      les       di,es:[di].returned_integer     ; make es:[di] point to
  82.                          ; returned integer
  83.      mov       word ptr es:[di],ax
  84.  
  85.      les       di,parameter_block
  86.      les       di,es:[di].file_name      ; make es:[di] point to
  87.                          ; file name
  88.  
  89.      mov       al,1              ; initialize al for not empty
  90.  
  91.      cmp       byte ptr es:[di],0         ; compare first byte to 0
  92.      jne       sample_disk_blackbox_exit
  93.  
  94.      mov       al,2              ; set al to empty check value
  95.  
  96. public sample_disk_blackbox_exit
  97. sample_disk_blackbox_exit:
  98.      les       di,parameter_block
  99.      les       di,es:[di].returned_check     ; es:[di] points to check
  100.  
  101.      mov       byte ptr es:[di],al
  102.  
  103.      mov       ax,4C00H           ; terminate program
  104.      int       21H
  105.  
  106. sample_disk_blackbox    endp
  107.  
  108. cseg     ends
  109.  
  110.      end sample_disk_blackbox
  111.