Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:14
CP/DOS  DosReallocSeg  mapper                               Page     1-1


				;
				page 60,132
				;
				title CP/DOS  DosReallocSeg  mapper
				;
 0000				dosxxx  segment byte public 'dos'
				        assume  cs:dosxxx,ds:nothing,es:nothing,ss:nothing
				;
				; ************************************************************************* *
				; *
				; *      MODULE: DosReallocSeg
				; *
				; *      FILE NAME: dos043.asm
				; *
				; *      FUNCTION: This module changes the size of a segment already
				; *             allocated
				; *
				; *      CALLING SEQUENCE:
				; *
				; *             push    size            ; new segment size requested in bytes
				; *             push    selector        ; selector
				; *             call    dosreallocseg
				; *
				; *      RETURN SEQUENCE:
				; *
				; *
				; *
				; *      MODULES CALLED:  DOS Int 21, AH=4A
				; *
				; *
				; *
				; *************************************************************************
				;
				        public  dosreallocseg
				        .sall
				        .list
				
				str     struc
 0000  0000			old_bp  dw      ?
 0002  00000000			return  dd      ?
 0006  0000			Selector        dw      ?       ; segment selector
 0008  0000			SegmentSize     dw      ?       ; new segment size in bytes
 000A				str     ends
				
 0000				dosreallocseg proc   far
				        Enter   dosreallocseg           ; save registers
				
 000C  8B 5E 08			        mov     bx,[bp].SegmentSize     ; Get new segment size
 000F  83 FB 00			        cmp     bx,0                    ; check for 0
 0012  74 0B			        je      AllocateMax             ; jmp to full seg
				
 0014  D1 EB			        shr     bx,1                    ; else convert segment in bytes
 0016  D1 EB			        shr     bx,1                    ; paragraph
 0018  D1 EB			        shr     bx,1
 001A  D1 EB			        shr     bx,1
 001C  EB 04 90			        jmp     HaveSize
Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:14
CP/DOS  DosReallocSeg  mapper                               Page     1-2


				
 001F				AllocateMax:
 001F  BB 1000			        mov     bx,4096                 ; default segment size in paragraph
				
 0022				HaveSize:
 0022  8E 46 06			        mov     es,[bp].Selector        ; set up segment for new size
				
 0025  B4 4A			        mov     ah,4ah                  ; set up for DOS realloc call
 0027  CD 21			        int     21h                     ; realloc segment
 0029  72 02			        jc      ErrorExit               ; jump if error
				
 002B  2B C0			        sub     ax,ax                   ; else set good return code
				
 002D				ErrorExit:
				        Mexit                           ; restore registers
				
 0039  CA 0004			        ret     size str - 6            ; return
				
 003C				dosreallocseg  endp
				
 003C				dosxxx  ends
				
				        end

Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:14
CP/DOS  DosReallocSeg  mapper                               Symbols-1


Macros:

		N a m e			Lines

ENTER  . . . . . . . . . . . . .  	   3
MEXIT  . . . . . . . . . . . . .  	   3
POPAL  . . . . . . . . . . . . .  	   9
PUSHAL . . . . . . . . . . . . .  	   9

Structures and Records:

                N a m e                 Width   # fields
                                        Shift   Width   Mask    Initial

STR  . . . . . . . . . . . . . .  	000A	0004
  OLD_BP . . . . . . . . . . . .  	0000
  RETURN . . . . . . . . . . . .  	0002
  SELECTOR . . . . . . . . . . .  	0006
  SEGMENTSIZE  . . . . . . . . .  	0008

Segments and Groups:

                N a m e         	Length	 Align	Combine Class

DOSXXX . . . . . . . . . . . . .  	003C	BYTE	PUBLIC	'DOS'

Symbols:            

                N a m e         	Type	 Value	 Attr

ALLOCATEMAX  . . . . . . . . . .  	L NEAR	001F	DOSXXX

dosreallocseg  . . . . . . . . .  	F PROC	0000	DOSXXX	Global	Length = 003C

ERROREXIT  . . . . . . . . . . .  	L NEAR	002D	DOSXXX

HAVESIZE . . . . . . . . . . . .  	L NEAR	0022	DOSXXX

@CPU . . . . . . . . . . . . . .  	TEXT  0101h		
@FILENAME  . . . . . . . . . . .  	TEXT  reallseg		
@VERSION . . . . . . . . . . . .  	TEXT  510		


    127 Source  Lines
    151 Total   Lines
     20 Symbols

  47512 + 298531 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors
