|
-
Nov 25th, 2004, 03:17 PM
#1
Thread Starter
Frenzied Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|