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


				;0
				page 80,132
				;
				title CP/DOS  DosAllocSeg  mapper
				;
 0000				dosxxx	segment byte public 'dos'
					assume	cs:dosxxx,ds:nothing,es:nothing,ss:nothing
				;
				; ************************************************************************* *
				; *
				; *	 MODULE: DosAllocSeg
				; *
				; *	 FUNCTION: This module allocates a segment of memory to the
				; *		requesting process
				; *
				; *	 CALLING SEQUENCE:
				; *
				; *		push	size		; number of bytes requested
				; *		push@	selector	; selector allocated (returned)
				; *		push	shareind	; whether segment will be shared
				; *		call	dosallocseg
				; *
				; *	 RETURN SEQUENCE:
				; *
				; *		AX = error	, 0 = no error
				; *
				; *	 MODULES CALLED:  DOS int 21h
				; *
				; *************************************************************************
				;
					public	dosallocseg
					.sall
					.list
				;
				str	struc
 0000  0000			old_bp	 dw	 ?
 0002  00000000			return	 dd	 ?
 0006  0000			ShareIndicator	dw	?	; whether segment will be shared
 0008  00000000			SelectorPtr	dd	?	; selector allocated
 000C  0000			SegmentSize	dw	?	; number of bytes requested
 000E				str	ends
				
 0000				dosallocseg proc   far
					Enter	dosallocseg		 ; push registers
				
 000C  8B 5E 0C				mov	bx,[bp].SegmentSize	 ; Get segment size
				
 000F  F7 C3 000F			test	bx,0000fh		 ; check segment size
 0013  74 06				jz	NoRoundRequired
				
 0015  83 E3 F0				and	bx,not 0000fh
 0018  83 C3 10				add	bx,00010h
				
 001B				NoRoundRequired:
 001B  83 FB 00				cmp	bx,0			 ; check for 0 (full seg)
 001E  74 0B				je	AllocateMax		 ; jmp to full seg
				
 0020  D1 EB				shr	bx,1			 ; convert segment in bytes to
 0022  D1 EB				shr	bx,1			 ; paragraph
 0024  D1 EB				shr	bx,1
 0026  D1 EB				shr	bx,1
 0028  EB 04 90				jmp	HaveSize
				
 002B				AllocateMax:
 002B  BB 1000				mov	bx,4096 		 ; setup default paragraph size
				
 002E				HaveSize:
 002E  B4 48				mov	ah,48h			 ; set up for dos allocate call
 0030  CD 21				int	21h			 ; allocate segment
 0032  72 07				jc	ErrorExit		 ; jump if error
				
 0034  C5 76 08				lds	si,[bp].SelectorPtr	 ; get selector address
 0037  89 04				mov	ds:[si],ax		 ; save allocated memory block
				
 0039				AllocDone:
 0039  2B C0				sub	ax,ax			 ; set good return code
Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:13
CP/DOS  DosAllocSeg  mapper                                 Page     1-2


 003B				ErrorExit:
					mexit				 ; pop registers
 0047  CA 0008				ret	size str - 6		 ; return
				
 004A				dosallocseg endp
				
 004A				dosxxx	ends
				
					end

Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:13
CP/DOS  DosAllocSeg  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  . . . . . . . . . . . . . .  	000E	0005
  OLD_BP . . . . . . . . . . . .  	0000
  RETURN . . . . . . . . . . . .  	0002
  SHAREINDICATOR . . . . . . . .  	0006
  SELECTORPTR  . . . . . . . . .  	0008
  SEGMENTSIZE  . . . . . . . . .  	000C

Segments and Groups:

                N a m e         	Length	 Align	Combine Class

DOSXXX . . . . . . . . . . . . .  	004A	BYTE	PUBLIC	'DOS'

Symbols:            

                N a m e         	Type	 Value	 Attr

ALLOCATEMAX  . . . . . . . . . .  	L NEAR	002B	DOSXXX
ALLOCDONE  . . . . . . . . . . .  	L NEAR	0039	DOSXXX

dosallocseg  . . . . . . . . . .  	F PROC	0000	DOSXXX	Global	Length = 004A

ERROREXIT  . . . . . . . . . . .  	L NEAR	003B	DOSXXX

HAVESIZE . . . . . . . . . . . .  	L NEAR	002E	DOSXXX

NOROUNDREQUIRED  . . . . . . . .  	L NEAR	001B	DOSXXX

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


    133 Source  Lines
    157 Total   Lines
     23 Symbols

  47476 + 306759 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors
