     1                                  
     2                                  %if 0
     3                                  
     4                                  ReSizeable RAMDisk - assembly helpers
     5                                  Copyright (C) 1992-1996, 2005 Marko Kohtala
     6                                  Adapted from C source texts' inline assembly by E. C. Masloch, 2025
     7                                  Released under GNU GPL, read the file 'COPYING' for more information
     8                                  
     9                                  %endif
    10                                  
    11                                  %include "lmacros3.mac"
     1                              <1> [list -]
    14                              <2> [list -]
    14                              <1> [list -]
    12                                  
    13                                  %define c_disk_IO 2   ;/* Offset into disk_IO in config_s */
    14                                  %define XMS_handle 0  ;/* Offsets into XMS_alloc structure */
    15                                  %define XMS_entry 2
    16                                  %define EMS_handle 0  ;/* Offsets into EMS_alloc structure */
    17                                  
    18                                  bits 16		; nasm -felf defaults to bits 32
    19                                  
    20                                  ; ia16-gcc default calling convention:
    21                                  ; parameters in reverse order on stack (compared to lframe's)
    22                                  ; caller cleans the stack
    23                                  ; CHG (call clobbered): ax, bx, cx, dx
    24                                  ; Call preserved: si, di, bp, es
    25                                  ; STT (special): ds = ss
    26                                  ; OUT: al, ax, or dx:ax
    27                                  
    28                                  %macro entry 1.nolist
    29                                  	global %1
    30                                  %1:
    31                                  %endmacro
    32                                  
    33                                  
    34                                  ; extern byte far * getlistoflists(void);
    35                                  
    36                                  entry getlistoflists
    37 00000000 06                      	push es
    38 00000001 B452                    	mov ah, 52h
    39 00000003 CD21                    	int 21h
    40 00000005 93                      	xchg ax, bx
    41 00000006 8CC2                    	mov dx, es
    42 00000008 07                      	pop es
    43 00000009 C3                      	retn
    44                                  
    45                                  
    46                                  ; extern word asm_xfer_sector
    47                                  ;  (char rw, int count, dword start, void far * buffer, void far * function);
    48                                  
    49                                  entry asm_xfer_sector
    50                                  	lframe near
    51                                  	lpar dword, function
    52                                  	lpar dword, buffer
    53                                  	lpar dword, start
    54                                  	lpar word, count
    55                                  	lpar word, rw
    56 0000000A 5589E5                  	lenter
    57 0000000D 06                          push es
    58 0000000E 56                          push si
    59 0000000F 57                          push di
    60 00000010 FF7604                      push word [bp + ?rw]
    61 00000013 FF7606                      push word [bp + ?count]
    62 00000016 FF760A                      push word [bp + ?start+2]
    63 00000019 FF7608                      push word [bp + ?start]
    64 0000001C FF760E                      push word [bp + ?buffer+2]
    65 0000001F FF760C                      push word [bp + ?buffer]
    66 00000022 FF5E10                      call far [bp + ?function]
    67 00000025 5F<rep 6h>                   times 6 pop di		; "add sp, 12" without clobering CF
    68                                  				; bug in SRDISK v2.09
    69 0000002B 5F                          pop di
    70 0000002C 5E                          pop si
    71 0000002D 07                          pop es
    72 0000002E 16                           push ss
    73 0000002F 1F                           pop ds
    74 00000030 7303                        jnc .done
    75 00000032 B8FFFF                      mov ax, -1
    76                                  .done:
    77 00000035 5D                      	lleave
    78 00000036 C3                      	retn
    79                                  
    80                                  
    81                                  ; extern dword asm_freemem(void far * function);
    82                                  
    83                                  entry asm_freemem
    84                                  	lframe near
    85                                  	lpar dword, function
    86 00000037 5589E5                  	lenter
    87 0000003A 06                          push es
    88 0000003B 56                          push si
    89 0000003C 57                          push di
    90 0000003D FF5E04                      call far [bp + ?function]	; dx:cx = return
    91 00000040 91                          xchg ax, cx			; put it into dx:ax
    92 00000041 5F                          pop di
    93 00000042 5E                          pop si
    94 00000043 07                          pop es
    95 00000044 16                           push ss
    96 00000045 1F                           pop ds
    97 00000046 5D                      	lleave
    98 00000047 C3                      	retn
    99                                  
   100                                  
   101                                  ; extern word asm_query_drive(byte drive);
   102                                  
   103                                  entry asm_query_drive
   104                                  	lframe near
   105                                  	lpar word, drive
   106 00000048 5589E5                  	lenter
   107 0000004B B80944                          mov ax,0x4409
   108 0000004E 8A5E04                          mov bl,byte [bp + ?drive]
   109 00000051 80EB40                          sub bl,'A'-1
   110 00000054 7219                            jc .no_fix       ;/* Bad drive letter */
   111 00000056 CD21                            int 0x21
   112 00000058 7215                            jc .no_fix       ;/* Failed access drive */
   113 0000005A F6C680                          test dh,0x80
   114 0000005D 7510                            jnz .no_fix      ;/* SUBSTed drive */
   115 0000005F 8A5604                          mov dl, [bp + ?drive]
   116 00000062 80EA40                          sub dl,'A'-1
   117 00000065 B41C                            mov ah,0x1C     ;/* Get Drive Data */
   118 00000067 CD21                            int 0x21
   119 00000069 16                               push ss
   120 0000006A 1F                               pop ds
   121 0000006B B80100                          mov ax, 1		; return true
   122 0000006E A9                              db __TEST_IMM16		; skip xor
   123                                  .no_fix:
   124 0000006F 31C0                    	xor ax, ax		; return false
   125 00000071 5D                      	lleave
   126 00000072 C3                      	retn
   127                                  
   128                                  
   129                                  ; extern byte free_ems_handle(word handle);
   130                                  
   131                                  entry free_ems_handle
   132                                  	lframe near
   133                                  	lpar word, handle
   134 00000073 5589E5                  	lenter
   135 00000076 8B5604                      mov dx, [bp + ?handle]
   136 00000079 B445                        mov ah,0x45  ;/* Free expanded memory block */
   137 0000007B CD67                        int 0x67
   138 0000007D 88E0                        mov al, ah
   139 0000007F 5D                      	lleave
   140 00000080 C3                      	retn
   141                                  
   142                                  
   143                                  ; extern byte alloc_ems_handle(void far * allocs, word pages);
   144                                  
   145                                  entry alloc_ems_handle
   146                                  	lframe near
   147                                  	lpar word, pages
   148                                  	lpar dword, allocs
   149 00000081 5589E5                  	lenter
   150 00000084 8B5E08                      mov bx, word [bp + ?pages]
   151 00000087 B443                        mov ah,0x43      ;/* Allocate */
   152 00000089 CD67                        int 0x67
   153 0000008B 88E0                        mov al, ah
   154 0000008D 84C0                        test al, al
   155 0000008F 7507                        jnz .fail
   156 00000091 C55E04                      lds bx, [bp + ?allocs]
   157 00000094 8917                        mov word [bx + EMS_handle], dx
   158 00000096 16                          push ss
   159 00000097 1F                          pop ds
   160                                  .fail:
   161 00000098 5D                      	lleave
   162 00000099 C3                      	retn
   163                                  
   164                                  
   165                                  ; extern word realloc_ems_handle(void far * allocs, word * pages);
   166                                  
   167                                  entry realloc_ems_handle
   168                                  	lframe near
   169                                  	lpar word, indirectpages
   170                                  	lpar dword, allocs
   171 0000009A 5589E5                  	lenter
   172 0000009D 8B5E08                      mov bx, [bp + ?indirectpages]
   173 000000A0 FF37                         push word [bx]
   174 000000A2 C55E04                      lds bx, [bp + ?allocs]
   175 000000A5 8B17                        mov dx, [bx + EMS_handle]
   176 000000A7 5B                           pop bx
   177 000000A8 16                          push ss
   178 000000A9 1F                          pop ds
   179 000000AA B451                        mov ah,0x51      ;/* Reallocate */
   180 000000AC CD67                        int 0x67
   181 000000AE 88E0                        mov al, ah
   182                                  %if 0	; bug in SRDISK v2.09
   183                                      mov ah, bl			; error code if al != 0
   184                                  %endif
   185 000000B0 84C0                        test al, al
   186 000000B2 7506                        jnz .error			; bug? in SRDISK v2.09
   187 000000B4 53                          push bx
   188 000000B5 8B5E08                      mov bx, word [bp + ?indirectpages]
   189 000000B8 8F07                        pop word [bx]
   190                                  .error:
   191 000000BA 5D                      	lleave
   192 000000BB C3                      	retn
   193                                  
   194                                  
   195                                  ; extern byte copy_ems(void far * pmb);
   196                                  
   197                                  entry copy_ems
   198                                  	lframe near
   199                                  	lpar dword, pmb
   200 000000BC 5589E5                  	lenter
   201 000000BF B80057                      mov ax,0x5700
   202 000000C2 1E                          push ds
   203 000000C3 56                          push si
   204 000000C4 C57604                      lds si, [bp + ?pmb]
   205 000000C7 CD67                        int 0x67
   206 000000C9 5E                          pop si
   207 000000CA 1F                          pop ds
   208 000000CB 88E0                        mov al, ah
   209 000000CD 5D                      	lleave
   210 000000CE C3                      	retn
   211                                  
   212                                  
   213                                  ; extern dword ems_available(void);
   214                                  
   215                                  entry ems_available
   216 000000CF B442                        mov ah,0x42
   217 000000D1 CD67                        int 0x67
   218 000000D3 B81000                      mov ax,16
   219 000000D6 F7E3                        mul bx			; dx:ax = amount KiB available
   220 000000D8 C3                      	retn
   221                                  
   222                                  
   223                                  ; extern byte check_windows(void);
   224                                  
   225                                  entry check_windows
   226 000000D9 B80016                        mov ax,0x1600
   227 000000DC CD2F                          int 0x2f
   228 000000DE 247F                          and al,0x7f
   229 000000E0 7402                          jz .not
   230 000000E2 B001                          mov al, 1
   231                                  .not:
   232 000000E4 C3                      	retn
   233                                  
   234                                  
   235                                  ; extern byte check_xms_3(void far * allocs);
   236                                  
   237                                  entry check_xms_3
   238                                  	lframe near
   239                                  	lpar dword, allocs
   240                                  	lvar dword, entry
   241 000000E5 5589E55050              	lenter
   242 000000EA B400                          mov ah,0      ;/* GET VERSION */
   243 000000EC C55E04                        lds bx, [bp + ?allocs]
   244 000000EF FF5F02                        call far [bx + XMS_entry]
   245 000000F2 16                            push ss
   246 000000F3 1F                            pop ds
   247 000000F4 3D0003                        cmp ax,0x300
   248 000000F7 724D                          jb .noSuperXMS
   249                                  
   250                                  ;/* From CPUID by Intel. Some HIMEM.SYS v3.0 functionality crash with 286.
   251                                  ;
   252                                  ;       This procedure determines the type of CPU in a system
   253                                  ;       and sets the cpu_type variable with the appropriate
   254                                  ;       value.
   255                                  ;       All registers are used by this procedure, none are preserved.
   256                                  ;
   257                                  ;       Intel 8086 CPU check
   258                                  ;       Bits 12-15 of the FLAGS register are always set on the
   259                                  ;       8086 processor.
   260                                  ;*/
   261 000000F9 9C                              pushf
   262 000000FA 9C                              pushf                   ;/* push original FLAGS */
   263 000000FB 58                              pop     ax              ;/* get original FLAGS */
   264 000000FC 89C1                            mov     cx, ax          ;/* save original FLAGS */
   265 000000FE 25FF0F                          and     ax, 0xfff       ;/* clear bits 12-15 in FLAGS */
   266 00000101 50                              push    ax              ;/* save new FLAGS value on stack */
   267 00000102 9D                              popf                    ;/* replace current FLAGS value */
   268 00000103 9C                              pushf                   ;/* get new FLAGS */
   269 00000104 58                              pop     ax              ;/* store new FLAGS in AX */
   270 00000105 9D                              popf
   271 00000106 2500F0                          and     ax, 0xf000      ;/* if bits 12-15 are set, then CPU */
   272 00000109 3D00F0                          cmp     ax, 0xf000      ;/*   is an 8086/8088 */
   273 0000010C 7438                            je      .noSuperXMS      ;/* jump if CPU is 8086/8088 */
   274                                  
   275                                  ;/*       Intel 286 CPU check */
   276                                  ;/*       Bits 12-15 of the FLAGS register are always clear on the */
   277                                  ;/*       Intel 286 processor in real-address mode. */
   278                                  
   279 0000010E 9C                              pushf
   280 0000010F 81C900F0                        or      cx, 0xf000      ;/* try to set bits 12-15 */
   281 00000113 51                              push    cx              ;/* save new FLAGS value on stack */
   282 00000114 9D                              popf                    ;/* replace current FLAGS value */
   283 00000115 9C                              pushf                   ;/* get new FLAGS */
   284 00000116 58                              pop     ax              ;/* store new FLAGS in AX */
   285 00000117 9D                              popf
   286 00000118 2500F0                          and     ax, 0xf000      ;/* if bits 12-15 clear, CPU=80286 */
   287 0000011B 7429                            jz      .noSuperXMS      ;/* if no bits set, CPU is 80286 */
   288                                  
   289                                  subcpu 386
   290                                  
   291                                        ;/* Query free extended to see if SuperXMS really supported */
   292 0000011D B488                          mov ah,0x88   ;/* QUERY FREE (32-bit) */
   293 0000011F C55E04                        lds bx, [bp + ?allocs]
   294 00000122 C55F02                        lds bx, [bx + XMS_entry]
   295 00000125 895EFC                        mov word [bp + ?entry], bx
   296 00000128 8C5EFE                        mov word [bp + ?entry + 2], ds
   297 0000012B 31DB                          xor bx, bx
   298 0000012D 6650                          push eax
   299 0000012F 6651                          push ecx
   300 00000131 6652                          push edx
   301 00000133 FF5EFC                        call far [bp + ?entry]
   302 00000136 665A                          pop edx
   303 00000138 6659                          pop ecx
   304 0000013A 6658                          pop eax
   305 0000013C 80FB80                        cmp bl,0x80  ;/* Not Implemented - not a 32-bit system */
   306 0000013F 16                            push ss
   307 00000140 1F                            pop ds
   308 00000141 7403                          je .noSuperXMS
   309                                  
   310                                  subcpureset
   311 00000143 B001                    	mov al, 1
   312 00000145 A9                      	db __TEST_IMM16		; skip mov
   313                                  .noSuperXMS:
   314 00000146 B000                    	mov al, 0
   315 00000148 89EC5D                  	lleave
   316 0000014B C3                      	retn
   317                                  
   318                                  
   319                                  ; extern byte get_xms_handle_size(void far * allocs, dword * size, byte hasxms3);
   320                                  
   321                                  entry get_xms_handle_size
   322                                  	lframe near
   323                                  	lpar word, hasxms3
   324                                  	lpar word, indirectsize
   325                                  	lpar dword, allocs
   326 0000014C 5589E5                  	lenter
   327 0000014F C55E04                        lds bx, [bp + ?allocs]
   328 00000152 8B17                          mov dx, [bx + XMS_handle]
   329 00000154 807E0A00                      cmp byte [bp + ?hasxms3], 0
   330 00000158 7712                          ja .xms3		; this condition was inverted in SRDISK v2.09
   331                                  .xms2:
   332 0000015A B40E                          mov ah,0xE      ;/* Get handle information */
   333 0000015C FF5F02                        call far [bx + XMS_entry]
   334 0000015F 16                            push ss
   335 00000160 1F                            pop ds
   336 00000161 85C0                    	test ax, ax
   337 00000163 7422                    	jz .fail
   338 00000165 8B5E08                  	mov bx, word [bp + ?indirectsize]
   339 00000168 8917                    	mov word [bx], dx
   340 0000016A EB15                    	jmp .done
   341                                  
   342                                  .xms3:
   343                                  subcpu 386
   344 0000016C 6652                    	push edx
   345 0000016E B48E                          mov ah,0x8E     ;/* Get 32bit handle information */
   346 00000170 FF5F02                        call far [bx + XMS_entry]
   347 00000173 16                            push ss
   348 00000174 1F                            pop ds
   349 00000175 85C0                    	test ax, ax
   350 00000177 740C                    	jz .fail_edx
   351 00000179 8B5E08                  	mov bx, word [bp + ?indirectsize]
   352 0000017C 668917                  	mov dword [bx], edx
   353 0000017F 665A                    	pop edx
   354                                  .done:
   355 00000181 B0FF                    	mov al, -1
   356 00000183 EB04                    	jmp .ret
   357                                  
   358                                  .fail_edx:
   359 00000185 665A                    	pop edx
   360                                  subcpureset
   361                                  
   362                                  .fail:
   363 00000187 B000                    	mov al, 0
   364                                  .ret:
   365 00000189 5D                      	lleave
   366 0000018A C3                      	retn
   367                                  
   368                                  
   369                                  ; extern word free_xms_handle(void far * allocs, word handle);
   370                                  
   371                                  entry free_xms_handle
   372                                  	lframe near
   373                                  	lpar word, handle
   374                                  	lpar dword, allocs
   375 0000018B 5589E5                  	lenter
   376 0000018E C55E04                        lds bx, [bp + ?allocs]
   377 00000191 8B5608                        mov dx, [bp + ?handle]
   378 00000194 B40A                          mov ah,0xA  ;/* Free extended memory block */
   379 00000196 FF5F02                        call far [bx + XMS_entry]
   380 00000199 16                            push ss
   381 0000019A 1F                            pop ds
   382 0000019B 85C0                            test ax, ax
   383 0000019D B0FF                    	mov al, -1
   384 0000019F 88DC                    	mov ah, bl
   385 000001A1 7402                            jz .fail
   386 000001A3 31C0                            xor ax, ax
   387                                  .fail:
   388 000001A5 5D                      	lleave
   389 000001A6 C3                      	retn
   390                                  
   391                                  
   392                                  ; extern word alloc_xms3_handle(void far * allocs, dword size);
   393                                  
   394                                  entry alloc_xms3_handle
   395                                  	lframe near
   396                                  	lpar dword, size
   397                                  	lpar dword, allocs
   398 000001A7 5589E5                  	lenter
   399                                  subcpu 386
   400 000001AA 6652                    	 push edx
   401 000001AC 5A                      	 pop dx
   402 000001AD B489                            mov ah,0x89   ;/* Allocate 32-bit */
   403 000001AF 668B5608                        mov edx, [bp + ?size]
   404 000001B3 C55E04                          lds bx, [bp + ?allocs]
   405 000001B6 FF5F02                          call far [bx + XMS_entry]
   406 000001B9 52                               push dx
   407 000001BA 665A                             pop edx
   408 000001BC 85C0                            test ax, ax
   409 000001BE B0FF                    	mov al, -1
   410 000001C0 88DC                    	mov ah, bl
   411 000001C2 7404                            jz .ret
   412 000001C4 8917                            mov [bx + XMS_handle], dx
   413 000001C6 31C0                            xor ax, ax
   414                                  .ret:
   415 000001C8 16                      	push ss
   416 000001C9 1F                      	pop ds
   417                                  subcpureset
   418 000001CA 5D                      	lleave
   419 000001CB C3                      	retn
   420                                  
   421                                  
   422                                  ; extern word alloc_xms2_handle(void far * allocs, dword size);
   423                                  
   424                                  entry alloc_xms2_handle
   425                                  	lframe near
   426                                  	lpar dword, size
   427                                  	lpar dword, allocs
   428 000001CC 5589E5                  	lenter
   429                                  
   430 000001CF B409                    	mov ah,0x9      ;/* Allocate */
   431 000001D1 8B5608                          mov dx, [bp + ?size]
   432 000001D4 C55E04                          lds bx, [bp + ?allocs]
   433 000001D7 FF5F02                          call far [bx + XMS_entry]
   434 000001DA 85C0                            test ax, ax
   435 000001DC B0FF                    	mov al, -1
   436 000001DE 88DC                    	mov ah, bl
   437 000001E0 7404                            jz .ret
   438 000001E2 8917                            mov [bx + XMS_handle], dx
   439 000001E4 31C0                            xor ax, ax
   440                                  .ret:
   441 000001E6 16                      	push ss
   442 000001E7 1F                      	pop ds
   443                                  
   444 000001E8 5D                      	lleave
   445 000001E9 C3                      	retn
   446                                  
   447                                  
   448                                  ; extern word realloc_xms3_handle(void far * allocs, dword size);
   449                                  
   450                                  entry realloc_xms3_handle
   451                                  	lframe near
   452                                  	lpar dword, size
   453                                  	lpar dword, allocs
   454 000001EA 5589E5                  	lenter
   455                                  subcpu 386
   456 000001ED 56                      	push si
   457 000001EE 6653                    	 push ebx
   458 000001F0 5B                      	 pop bx
   459 000001F1 B48F                            mov ah,0x8F   ;/* Reallocate 32-bit */
   460 000001F3 668B5E08                        mov ebx, [bp + ?size]
   461 000001F7 C57604                          lds si, [bp + ?allocs]
   462 000001FA 8B14                            mov dx, [si + XMS_handle]
   463 000001FC FF5C02                          call far [si + XMS_entry]
   464 000001FF 53                               push bx
   465 00000200 665B                             pop ebx
   466 00000202 5E                              pop si
   467 00000203 85C0                            test ax, ax
   468 00000205 B0FF                    	mov al, -1
   469 00000207 88DC                    	mov ah, bl
   470 00000209 7402                            jz .ret
   471 0000020B 31C0                            xor ax, ax
   472                                  .ret:
   473 0000020D 16                      	push ss
   474 0000020E 1F                      	pop ds
   475                                  subcpureset
   476 0000020F 5D                      	lleave
   477 00000210 C3                      	retn
   478                                  
   479                                  
   480                                  ; extern word realloc_xms2_handle(void far * allocs, dword size);
   481                                  
   482                                  entry realloc_xms2_handle
   483                                  	lframe near
   484                                  	lpar dword, size
   485                                  	lpar dword, allocs
   486 00000211 5589E5                  	lenter
   487 00000214 56                      	push si
   488 00000215 B40F                    	mov ah,0xF      ;/* Reallocate */
   489 00000217 8B5E08                          mov bx, [bp + ?size]
   490 0000021A C57604                          lds si, [bp + ?allocs]
   491 0000021D 8B14                            mov dx, [si + XMS_handle]
   492 0000021F FF5C02                          call far [si + XMS_entry]
   493 00000222 5E                              pop si
   494 00000223 85C0                            test ax, ax
   495 00000225 B0FF                    	mov al, -1
   496 00000227 88DC                    	mov ah, bl
   497 00000229 7402                            jz .fail
   498 0000022B 31C0                            xor ax, ax
   499                                  .fail:
   500 0000022D 16                      	push ss
   501 0000022E 1F                      	pop ds
   502 0000022F 5D                      	lleave
   503 00000230 C3                      	retn
   504                                  
   505                                  
   506                                  ; extern word copy_xms(void far * allocs, void far * pmb);
   507                                  
   508                                  entry copy_xms
   509                                  	lframe near
   510                                  	lpar dword, pmb
   511                                  	lpar dword, allocs
   512 00000231 5589E5                  	lenter
   513 00000234 B40B                        mov ah,0xB
   514 00000236 56                          push si
   515 00000237 06                          push es
   516 00000238 57                          push di
   517 00000239 C57608                      lds si, [bp + ?pmb]
   518 0000023C C47E04                      les di, [bp + ?allocs]
   519 0000023F 26FF5D02                    call far [es:di + XMS_entry]
   520 00000243 5F                          pop di
   521 00000244 07                          pop es
   522 00000245 5E                          pop si
   523 00000246 85C0                            test ax, ax
   524 00000248 B0FF                    	mov al, -1
   525 0000024A 88DC                    	mov ah, bl
   526 0000024C 7402                            jz .fail
   527 0000024E 31C0                            xor ax, ax
   528                                  .fail:
   529 00000250 16                      	push ss
   530 00000251 1F                      	pop ds
   531 00000252 5D                      	lleave
   532 00000253 C3                      	retn
   533                                  
   534                                  
   535                                  ; extern byte get_xms3_available(void far * allocs, dword * size);
   536                                  
   537                                  entry get_xms3_available
   538                                  	lframe near
   539                                  	lpar word, indirectsize
   540                                  	lpar dword, allocs
   541                                  	lvar dword, entry
   542 00000254 5589E55050              	lenter
   543 00000259 C55E04                        lds bx, [bp + ?allocs]
   544 0000025C C55F02                        lds bx, [bx + XMS_entry]
   545 0000025F 895EFC                        mov word [bp + ?entry], bx
   546 00000262 8C5EFE                        mov word [bp + ?entry + 2], ds
   547 00000265 31DB                          xor bx, bx
   548                                  subcpu 386
   549 00000267 6650                    	push eax
   550 00000269 6651                    	push ecx
   551 0000026B 6652                    	push edx
   552 0000026D B488                          mov ah,0x88
   553 0000026F FF5EFC                        call far [bp + ?entry]
   554 00000272 16                            push ss
   555 00000273 1F                            pop ds
   556 00000274 84DB                    	test bl, bl
   557 00000276 7403                    	jz .ok
   558 00000278 6631C0                  	xor eax, eax
   559                                  .ok:
   560 0000027B 8B5E08                  	mov bx, word [bp + ?indirectsize]
   561 0000027E 668907                  	mov dword [bx], eax
   562 00000281 665A                    	pop edx
   563 00000283 6659                    	pop ecx
   564 00000285 6658                    	pop eax
   565                                  subcpureset
   566 00000287 89EC5D                  	lleave
   567 0000028A C3                      	retn
   568                                  
   569                                  
   570                                  ; extern byte get_xms2_available(void far * allocs, dword * size);
   571                                  	; INP:	*size is pre-initialised to zero
   572                                  
   573                                  entry get_xms2_available
   574                                  	lframe near
   575                                  	lpar word, indirectsize
   576                                  	lpar dword, allocs
   577                                  	lvar dword, entry
   578 0000028B 5589E55050              	lenter
   579 00000290 C55E04                        lds bx, [bp + ?allocs]
   580 00000293 C55F02                        lds bx, [bx + XMS_entry]
   581 00000296 895EFC                        mov word [bp + ?entry], bx
   582 00000299 8C5EFE                        mov word [bp + ?entry + 2], ds
   583 0000029C 31DB                          xor bx, bx
   584 0000029E B408                          mov ah, 8
   585 000002A0 FF5EFC                        call far [bp + ?entry]
   586 000002A3 16                            push ss
   587 000002A4 1F                            pop ds
   588 000002A5 84DB                    	test bl, bl
   589 000002A7 7402                    	jz .ok
   590 000002A9 31C0                    	xor ax, ax
   591                                  .ok:
   592 000002AB 8B5E08                  	mov bx, word [bp + ?indirectsize]
   593 000002AE 8907                    	mov word [bx], ax
   594 000002B0 89EC5D                  	lleave
   595 000002B3 C3                      	retn
   596                                  
   597                                  
   598                                  ; extern dword asm_call_alloc(void far * function, dword size);
   599                                  
   600                                  entry asm_call_alloc
   601                                  	lframe near
   602                                  	lpar dword, size
   603                                  	lpar dword, function
   604 000002B4 5589E5                  	lenter
   605 000002B7 06                      	 push es
   606 000002B8 57                      	 push di
   607 000002B9 56                      	 push si
   608 000002BA FF760A                  	push word [bp + ?size + 2]
   609 000002BD FF7608                  	push word [bp + ?size]
   610 000002C0 FF5E04                  	call far [bp + ?function]
   611 000002C3 5E                      	 pop si
   612 000002C4 5F                      	 pop di
   613 000002C5 07                      	 pop es
   614 000002C6 16                      	push ss
   615 000002C7 1F                      	pop ds
   616 000002C8 5D                      	lleave
   617 000002C9 C3                      	retn
