home *** CD-ROM | disk | FTP | other *** search
- Assembly language provides the most freedom for writing BlackBoxes and
- supporting them in multiple languages. All types of source-code BlackBoxes
- can be easily written under this system.
-
-
- ; ----------------------- MEMORY-BASED BLACKBOXES -----------------------
-
-
- The Following Macros are used for all memory-based BlackBoxes written in
- Assembly Language. We recommend that you do not bypass these macros,
- since they will use the correct segment naming conventions for each of
- the different languages, as well as label naming convensions.
-
-
- _BBX_START_DATA
-
- ; starts the data segment for a blackbox.
- ; this is optional, since a blackbox may contain no private data
-
-
- _BBX_END_DATA
-
- ; Ends the data segment for a blackbox
- ; Required if and only if _BBX_START_DATA has been used.
-
-
- _BBX_START_CODE
-
- ; Starts the code segment for a blackbox
-
-
- _BBX_END_CODE
-
- ; Ends the code segment for a blackbox
-
-
- _END_PROG
-
- ; Ends the file
-
-
- _BBX_PROC name_of_blackbox <, .NO_DATA or , .NOTHING>
-
- ; This begins a BlackBox procedure. For C, an underscore will automatically
- ; be generated in front of the label. The label is automatically public-ed
- ;
- ; If nothing follows the name of the blackbox, then BP is pushed, set to
- ; sp to access the calling stack frame, and then all registers required not
- ; to change are pushed on the stack. Finally, the data segment of the
- ; blackbox's private data is moved into DS, using AX.
- ;
- ; If .NO_DATA follows the name of the blackbox, then the stack frame is set
- ; up exactly as above, but the data segment is not moved into DS. This is
- ; required if no _BBX_START_DATA was used to declare a data segment.
- ;
- ;
- ; If .NOTHING follows the name of the blackbox, then no stack frame is set
- ; up, and no data segment is moved into ds. The procedure is merely declared.
- ;
- ; This should be used ONLY for the BlackBox procedure, not for any near
- ; procedures called within the blackbox. Those would be declared normally,
- ; using the proc operand.
-
-
- _BBX_ENDP name_of_blackbox
-
- ; This ends a BlackBox procedure. For C, an underscore will automatically
- ; be generated in front of the label.
-
-
- _PUBLIC label_to_public
-
- ; declares the label public in the executable .BBX, but does not declare it
- ; public in C, Pascal, or Basic. For symbolic debugging purposes, or to
- ; generate a detailed .MAP file, you may wish to declare labels public.
- ; However, in the .OBJ's created in C or BASIC, these private labels should not
- ; be public, and in Turbo Pascal, these labels CANNOT be public, so the
- ; macro will not declare them when compiled for those languages.
-
-
- _BASIC_STRING segment_register, address_register
-
- ; When working with pointers to text or pointers to check boxes, the BASIC
- ; calling procedure passes the address of a string descriptor, rather than
- ; the address of the data itself. Once the pointer has been loaded into
- ; registers, this macro should be used to get the pointer to the actual
- ; data. In any language except BASIC, this macro does nothing.
- ;
- ; Example:
- ;
- ; les di,PASSED_FILE_NAME
- ; _BASIC_STRING es,di
- ;
- ; ; Now, no matter what language, es:[di] points to the string.
- ;
- ; Note that the address_register must be one that can be used as a pointer!
- ;
- ; If you are not going to support direct compilation of BASIC programs, you
- ; do not have to use this macro.
- ;
-
- _SETUP_STACK
-
- ; This sets up the stack frame as described in _BBX_PROC
- ; You may wish to use this if the .NOTHING parameter was used with _BBX_PROC
-
-
- _RESTORE_STACK pop_value
-
- ; You must use this macro to restore the stack and return from your BlackBox.
- ; The pop_value is the amount to pop off the stack when returning to Pascal
- ; or BASIC programs. If no pop_value is supplied, even in BBX or C compiling,
- ; a warning will be displayed on the screen, but not counted as a warning by
- ; the assembler.
-
-
- _RETURN_VALUE return_address, return_reg
-
- ; This macro will aid in returning check box values from your BlackBox.
- ; The return_address is an equate in the form of [BP+BBXC_BASE+?], and the
- ; return_reg should be a byte register.
-
-
-
- _BBX_ICALL name_of_call, pop_value
-
- ; This macro will call an internal LAYOUT function.
- ; The name of the call is one of the equates described in the beginning of
- ; EQUATES.ASM, and the pop_value is the amount of bytes pushed on the
- ; stack to the internal procedure.
-
-
- _mov_addr register, variable_label
-
- ; This macro will move the offset of a private variable in the BlackBox to
- ; the register indicated. In BBX and Pascal format, this simply uses the
- ; OFFSET operand, but in C and BASIC it uses an LEA instruction because the
- ; OFFSET operand will not work. If LEA is always used to access the address
- ; of a private variable, this macro is not needed.
-
-
- The Following Equates are available to all memory-based BlackBoxes written in
- Assembly Language.
-
- REVERSE_ORDER ; an internal equate indicating whether the current
- ; language of compilation usually passes in reverse order
-
- ; Note that BlackBoxes are ALWAYS passed parameters by
- ; pushing in the requested order, so that the first
- ; requested parameter is ALWAYS at the highest address,
- ; regardless of the calling procedure's language.
-
-
- RETURN_AND_POP ; an internal equate indicating whether the current
- ; language of compilation will pop parameters off the
- ; stack for the BlackBox
-
-
- BBX_LANGUAGE_VALUE ; an internal equate indicating the current language of
- ; compilation.
-
- language_type ; the position from BP in the passing stack frame of the
- ; calling procedure's language value
-
- bbxc_base ; the position from BP in the passing stack frame of the
- ; calling procedure's last requested parameter
-
- _DATA_SEG ; the private data segment
-
-
- language ; an internal equate set at compile time to indicate the
- ; current language of compile. The values for language
- ; are EXE, C, TURBO, BASIC
- ;
- ; To conditionally compile EXE code for example:
- ;
- ; ife language - exe
- ; ; put code for only BBX/EXE here
- ; endif
-
-
-
- The steps for writing a Memory-Basied BlackBox in Assembly are as follows:
-
-
- 1. Include the files LANGUAGE.LIB and EQUATES.ASM
-
- 2. If desired, use the _BBX_START_DATA to declare a data segment
- a. declare internal data
- b. use _BBX_END_DATA to end the data segment
-
- 3. Use _BBX_START_CODE to declare the code segment
-
- 4. If you are putting more than one BlackBox in the current source file,
- you should declare a series of near ptr jumps into the code. This
- guarantees that the entry addresses do not change for BlackBoxes following
- the first, and no change in header files is required.
-
- 5. Declare any external procedures for non .BBX code that will be used.
- This is ONLY for BlackBoxes taking advantage of the INT 0F4H calls.
-
- 6. Declare the passing stack structure in the same method as follows:
-
- your_prog_varln equ 10 + 2 ; always +2 for language
- parameter1 equ [bp+bbxc_base+6] ; passed by reference
- parameter2 equ [bp+bbxc_base+4] ; passed by value
- parameter3 equ [bp+bbxc_base] ; passed by reference
-
- For double word pointers, add 4 to get to the next parameter.
- For values passed as words, add 2 to get to the next parameter.
-
- Always declare a passed variable length (varln) equate to indicate the
- amount that must be popped off the stack before returning to Pascal
- or Basic procedures. Remember that this value will always be 2 more
- than the amount for your declared parameters, since a language type
- value will also always be passed at a lower address than the lowest
- parameter on the stack.
-
- 7. Declare the procedure using _BBX_PROC
-
- 8. Write the code that performs the action of the BlackBox
-
- 9. If you are returning a Check Box parameter, use the _RETURN_VALUE macro
- to do this.
-
- 10. Return from the BlackBox using the macro _RESTORE_STACK
-
- 11. End the procedure using _BBX_ENDP
-
- 12. Repeat steps 5-10 for any other BlackBoxes within this file.
-
- 13. End the BlackBox file using _BBX_END_CODE and _END_PROG
-
- 14. To create a Turbo Pascal version of your object file, you must create a
- .PAS file to compile into a .TPU file. The .PAS file should declare the
- name of the unit, declare the BlackBox procedure(s) (any parameters
- passed by reference should remain untyped) in the interface section,
- declare them again in the implementation section as external procedures,
- and then include the .OBJ using the $L command.
-
- 15. To compile this Blackbox, use the batch file M_BBX.BAT
-
- M_BBX name <, alternate_name>
-
-
- If you wish to compile without the batch file:
-
- MASM name /DEXE_TYPE;
- LINK name, name.bbx;
-
- MASM name,namec /DC_TYPE;
- MASM name,nameb /DBASIC_TYPE;
-
- MASM name,namep /DTURBO_TYPE;
- TPC name
-
-
-
-
- ; ------------------------ DISK-BASED BLACKBOXES ------------------------
-
- A Disk-Based BlackBox can be written in any assembly language style most
- comfortable for the developer. Since it is basically an executable program,
- it is written as a stand-alone program which follows a few basic rules.
-
- 1. Any memory which is allocated by the disk-based blackbox MUST be
- deallocated before exiting the program.
-
- 2. Any File Handles which are opened must be closed before exiting the
- program.
-
- 3. The Disk-Based BlackBox CANNOT leave the screen in text mode before
- exiting, and it should preserve the top two lines of the screen in
- case a menu is present from the calling procedure.
-
- 4. The Interrupt vectors 0F3H and 0F4H cannot be replaced.
-
- 5. The program must exit normally, it cannot terminate and stay resident.
-
-
- The procedure for calling a disk-based blackbox is as follows:
-
- 1. The parameters are pushed on the stack as if calling a memory-based
- blackbox. Note that the last parameter pushed will always be the
- LANGUAGE_TYPE integer value.
-
- 2. The value of the stack pointer and stack segment is stored in the
- graphics device driver using int 0F3H
-
- 3. An EXEC call (DOS CALL 21H, subfunction 4BH) is made to load and
- execute the disk-based blackbox.
-
- 4. Your Disk-Based BlackBox makes a call to int 0F3H to obtain the
- stored pointer to the passed data.
-
- 5. Whatever action required is performed.
-
- 6. Return whatever status values using the pointers passed.
-
- 6. Your Disk-Based BlackBox returns using the DOS CALL 21H, subfunction 4CH
- (the error code is not read by LAYOUT, so a return status of 0 is normal)
-
- 7. The calling program continues execution.
-
-
- The call for obtaining the pointer to the passed data is:
-
- AH = 214
- AL = 7
-
- INT 0F3H
-
- RETURNS: DX = segment
- BX = offset
-
- Example:
-
- mov ax,214*256 + 7
- int 0F3H ; get the pointer to the parameters
-
- mov word ptr parameter_block,bx
- mov word ptr parameter_block[2],dx
-
-
-
-