home *** CD-ROM | disk | FTP | other *** search
/ Der Mediaplex Sampler - Die 6 von Plex / 6_v_plex.zip / 6_v_plex / DISK5 / DOS_42 / XLIB30.ZIP / EXAMP1B.ASM < prev    next >
Assembly Source File  |  1993-12-17  |  4KB  |  80 lines

  1. ;This program is the TASM version of the MASM pogram in Example 1 of the XLIB
  2. ;documentation.  TASM programs must resize the DOS memory block in which they
  3. ;are contained so that there will be some free memory for allocation by
  4. ;INITXLIB.  The initialization code for the program below determines the size
  5. ;of the program from the facts that at startup, ES:0000 will equal the address
  6. ;of the program segment prefix, and SS:SP will equal the terminal address of
  7. ;the program.
  8.  
  9.                MASM51                        ;Use MASM 5.1 compatibility mode
  10.                QUIRKS                        ;Allow MASM 5.1 quirks
  11.                NOSMART                       ;No optimization on MASM 5.1
  12.  
  13. PUSHW          MACRO IMMEDIATE16             ;Macro to PUSH 16-bit contant
  14.                IF (@WordSize EQ 4)
  15.                DB             66H
  16.                ENDIF
  17.                DB             68H
  18.                DW             IMMEDIATE16
  19.                ENDM
  20.  
  21. PUSHD          MACRO IMMEDIATE32             ;Macro to PUSH 32-bit constant
  22.                IF (@WordSize EQ 2)
  23.                DB             66H
  24.                ENDIF
  25.                DB             68H
  26.                DD             IMMEDIATE32
  27.                ENDM
  28.  
  29.                .MODEL        LARGE,PASCAL
  30.                .386P
  31.                DOSSEG                        ;Place stack at highest address
  32.  
  33.                INCLUDE        XLIBB.INC      ;Include XLIBB public symbols
  34.                INCLUDELIB     XLIBB.LIB      ;Link with XLIBB.LIB
  35.  
  36.                .STACK         1024
  37.                .CODE
  38.                .STARTUP
  39.                MOV            AX,SP          ;Resize program memory block
  40.                SHR            AX,4
  41.                MOV            BX,SS
  42.                ADD            BX,AX
  43.                INC            BX             ;BX = first para. beyond program
  44.                MOV            AX,ES
  45.                SUB            BX,AX          ;BX = program size in paragraphs
  46.                MOV            AH,4AH         ;Resize memory block at ES:0000
  47.                INT            21H
  48.                JC             MAINEXIT       ;Failed to resize
  49.  
  50.                CALL           INITXLIB       ;Initialize XLIB
  51.                OR             EAX,EAX        ;EAX = 0 if successful
  52.                JNZ            MAINEXIT
  53.  
  54. INITDONE:      PUSHD          <OFFSET DEMOPROC>
  55.                CALL           CALLPM         ;Execute DEMOPROC in protected
  56. MAINEXIT:      MOV            AX,4C00H       ;DOS termination function
  57.                INT            21H
  58.  
  59. ;Protected-mode routines must be placed in following segment:
  60. TSEG           SEGMENT PARA PUBLIC USE32 'CODE'
  61.                ASSUME CS:TSEG, SS:TSEG, DS:TSEG, ES:TSEG, FS:DSEG, GS:DGROUP
  62.  
  63. ;Protected-mode routine to print message to the screen using DOS function.
  64. DEMOPROC       PROC NEAR
  65.                MOV            EBX,OFFSET PMMSG
  66.                MOV            AH,02H
  67. MSGLOOP:       MOV            DL,CS:[EBX]    ;32-bit offset!!!!!
  68.                OR             DL,DL
  69.                JZ             EXIT
  70.                INT            21H            ;Print character with DOS
  71.                INC            EBX
  72.                JMP            MSGLOOP
  73. EXIT:          RET                           ;Go back to real or V86 mode
  74. PMMSG          DB  "In 32-bit protected mode!!!  "
  75.                DB  "Returning to real mode.",10,13,0
  76. DEMOPROC       ENDP
  77.  
  78. TSEG           ENDS
  79.                END
  80.