Results 1 to 4 of 4

Thread: INT 21h - Exec function: Out Of Memory

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,945

    INT 21h - Exec function: Out Of Memory

    EDIT:
    I solved the problem with INT 21h, 48h (Allocate Memory Blocks)
    I should write MOV ah, 48h, not MOV ax, 48h
    That only leaves the problem with Exec function to be solved...

    I am trying to write a routine that can run other programs but whenever I run this program INT 21h, 4Bh (Exec Load and Execute Program) reports that the program is out of memory. (error code 8) As far as I understand it I need to allocate memory for another program before running it. I can't find any useful information in Helppc or on the internet though. I tried allocating memory with INT 21h, 48h but the program exits instead of allocating memory whenever it attempts to execute that function.

    The program: (All numbers are in DECIMAL notation! Which means that INT 21h, 4Bh is referred to as INT 33, 75 in the code.)

    Code:
    ORG 256
    Main:
    	; Executes the program.
    	MOV ah, 75		; Load and Execute Program
    	MOV al, 0		; Load and execute.
    	MOV dx, .Program	; The path and file name of the program to execute.
    	MOV bx, ds		; Parameter block.
    	MOV es, bx		;
    	MOV bx, .Parameters	;
    	INT 33			; DOS functions interrupt.
    	JMP ErrorTrap
    RET
    
    .Parameters RESB 22
    .Program db "command.com", 0
    
    
    
    ;+---------------------------------------------------+
    ;| Error Trap - Displays the error code. 	     |
    ;| [Parameters in:]			 	     |
    ;| Name:	Description:		Type:	     |
    ;| ax		The error code.		CPU register |
    ;+---------------------------------------------------+
    
    ErrorTrap:
    	; Converts the error code to a user readable format.
    	PUSH ax			; The error code.
    	CALL cv256to16		; Converts value to user readable format.
    	POP DWORD [.ErrorCode]	;
    
    	; Displays the error code.
    	MOV ah, 9		; Print String.
    	MOV dx, .ErrorCode	;
    	INT 33			; DOS functions interrupt.
    RET
    
    .ErrorCode db "0000", 13, 10, "$"
    
    
    
    ;+-------------------------------------------------------------------------------+
    ;| Convert Byte to Hexadecimal - Converts byte values to hexadecimal number.     |
    ;| [Parameters in:]                                                 		 |
    ;| Name:	Description:				Type:    		 |
    ;| Number	Byte values to be converted.            2 Byte number (by value) |
    ;| Parameters out:]                                                     	 |
    ;| Name:	Description:				Type:    		 |
    ;| Hexadecimal	Converted hexadecimal number.		4 Byte string (by value) |
    ;+-------------------------------------------------------------------------------+
    
    cv256to16:
    	POP WORD [.ReturnAddress]
    	POP WORD [.ByteVal]
    
    	MOV bx, 0					; Digit = 0
    	MOV cl, 12					; BitShift = 12
    	MOV dx, 64410					; BitMask = 64410
    		.GetHexDigits:
    			MOV ax, [.ByteVal]		;
    			AND ax, dx			; Extract a 4 bit value from the byte values.
    			SHR ax, cl			;
    			MOV si, ax			;
    			MOV al, [.HexDigits + si]	; Get the hexadecimal digit for the 4 bit value.
    			MOV [.HexNumber + bx], al	;
    			SHR dx, 4			; Adjust BitMask
    			SUB cl, 4			; and BitShift.
    			INC bx				; Next digit.
    			CMP bx, 4			; Check for last digit.
    		JNE .GetHexDigits
    
    	PUSH DWORD [.HexNumber]
    	PUSH WORD [.ReturnAddress]
    RET
    
    .ByteVal dw 0
    .HexNumber db "0000"
    .HexDigits db "0123456789ABCDEF"
    .ReturnAddress dw 0
    Last edited by Peter Swinkels; Nov 25th, 2004 at 03:22 PM.

  2. #2
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: INT 21h - Exec function: Out Of Memory

    Quote Originally Posted by Peter Swinkels
    EDIT:
    I solved the problem with INT 21h, 48h (Allocate Memory Blocks)
    I should write MOV ah, 48h, not MOV ax, 48h
    That only leaves the problem with Exec function to be solved...

    I am trying to write a routine that can run other programs but whenever I run this program INT 21h, 4Bh (Exec Load and Execute Program) reports that the program is out of memory. (error code 8) As far as I understand it I need to allocate memory for another program before running it. I can't find any useful information in Helppc or on the internet though. I tried allocating memory with INT 21h, 48h but the program exits instead of allocating memory whenever it attempts to execute that function.

    The program: (All numbers are in DECIMAL notation! Which means that INT 21h, 4Bh is referred to as INT 33, 75 in the code.)

    Code:
    ORG 256
    Main:
    	; Executes the program.
    	MOV ah, 75		; Load and Execute Program
    	MOV al, 0		; Load and execute.
    	MOV dx, .Program	; The path and file name of the program to execute.
    	MOV bx, ds		; Parameter block.
    	MOV es, bx		;
    	MOV bx, .Parameters	;
    	INT 33			; DOS functions interrupt.
    	JMP ErrorTrap
    RET
    
    .Parameters RESB 22
    .Program db "command.com", 0
    
    
    
    ;+---------------------------------------------------+
    ;| Error Trap - Displays the error code. 	     |
    ;| [Parameters in:]			 	     |
    ;| Name:	Description:		Type:	     |
    ;| ax		The error code.		CPU register |
    ;+---------------------------------------------------+
    
    ErrorTrap:
    	; Converts the error code to a user readable format.
    	PUSH ax			; The error code.
    	CALL cv256to16		; Converts value to user readable format.
    	POP DWORD [.ErrorCode]	;
    
    	; Displays the error code.
    	MOV ah, 9		; Print String.
    	MOV dx, .ErrorCode	;
    	INT 33			; DOS functions interrupt.
    RET
    
    .ErrorCode db "0000", 13, 10, "$"
    
    
    
    ;+-------------------------------------------------------------------------------+
    ;| Convert Byte to Hexadecimal - Converts byte values to hexadecimal number.     |
    ;| [Parameters in:]                                                 		 |
    ;| Name:	Description:				Type:    		 |
    ;| Number	Byte values to be converted.            2 Byte number (by value) |
    ;| Parameters out:]                                                     	 |
    ;| Name:	Description:				Type:    		 |
    ;| Hexadecimal	Converted hexadecimal number.		4 Byte string (by value) |
    ;+-------------------------------------------------------------------------------+
    
    cv256to16:
    	POP WORD [.ReturnAddress]
    	POP WORD [.ByteVal]
    
    	MOV bx, 0					; Digit = 0
    	MOV cl, 12					; BitShift = 12
    	MOV dx, 64410					; BitMask = 64410
    		.GetHexDigits:
    			MOV ax, [.ByteVal]		;
    			AND ax, dx			; Extract a 4 bit value from the byte values.
    			SHR ax, cl			;
    			MOV si, ax			;
    			MOV al, [.HexDigits + si]	; Get the hexadecimal digit for the 4 bit value.
    			MOV [.HexNumber + bx], al	;
    			SHR dx, 4			; Adjust BitMask
    			SUB cl, 4			; and BitShift.
    			INC bx				; Next digit.
    			CMP bx, 4			; Check for last digit.
    		JNE .GetHexDigits
    
    	PUSH DWORD [.HexNumber]
    	PUSH WORD [.ReturnAddress]
    RET
    
    .ByteVal dw 0
    .HexNumber db "0000"
    .HexDigits db "0123456789ABCDEF"
    .ReturnAddress dw 0

    Try including the full path to the file you want to execute. DirveName:\Path\filename
    Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. - Oscar Wilde

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,945

    Re: INT 21h - Exec function: Out Of Memory

    Well, the problem isn't that the program I want to execute can't be found by DOS, the problem is that DOS claims there isn't enough memory to load and the execute program. I find that highly unlikely. It's more likely I did something wrong in the code. I did some fiddeling with the Allocate Memory function, it won't allocate even one paragraph (16 bytes.) Just like the EXEC function it claims there isn't enough memory.

    Just to be on the safe side, I tried using the full path as you suggested. I got the same error again.

    BTW:
    Perhaps I should have mentioned that the code I posted in my previous message in this thread returns an error code if an error occurs.
    The error codes are DOS error codes. According to HelpPC these are important when using int 21h:

    01 Invalid function number
    02 File not found
    03 Path not found
    04 Too many open files (no handles left)
    05 Access denied
    06 Invalid handle
    07 Memory control blocks destroyed
    08 Insufficient memory
    09 Invalid memory block address
    0A Invalid environment
    0B Invalid format
    0C Invalid access mode (open mode is invalid)
    0D Invalid data
    0E Reserved
    0F Invalid drive specified
    10 Attempt to remove current directory
    11 Not same device
    12 No more files
    Last edited by Peter Swinkels; Dec 3rd, 2004 at 09:50 AM.

  4. #4
    Hyperactive Member Maven's Avatar
    Join Date
    Feb 2003
    Location
    Greeneville, TN
    Posts
    322

    Re: INT 21h - Exec function: Out Of Memory

    Quote Originally Posted by Peter Swinkels
    Well, the problem isn't that the program I want to execute can't be found by DOS, the problem is that DOS claims there isn't enough memory to load and the execute program. I find that highly unlikely. It's more likely I did something wrong in the code. I did some fiddeling with the Allocate Memory function, it won't allocate even one paragraph (16 bytes.) Just like the EXEC function it claims there isn't enough memory.

    Just to be on the safe side, I tried using the full path as you suggested. I got the same error again.

    BTW:
    Perhaps I should have mentioned that the code I posted in my previous message in this thread returns an error code if an error occurs.
    The error codes are DOS error codes. According to HelpPC these are important when using int 21h:

    01 Invalid function number
    02 File not found
    03 Path not found
    04 Too many open files (no handles left)
    05 Access denied
    06 Invalid handle
    07 Memory control blocks destroyed
    08 Insufficient memory
    09 Invalid memory block address
    0A Invalid environment
    0B Invalid format
    0C Invalid access mode (open mode is invalid)
    0D Invalid data
    0E Reserved
    0F Invalid drive specified
    10 Attempt to remove current directory
    11 Not same device
    12 No more files
    You may want to try posting at hutchs board, under the 16bit forum.
    http://www.masmforum.com/
    Education is an admirable thing, but it is well to remember from time to time that nothing that is worth knowing can be taught. - Oscar Wilde

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width