Presentation is loading. Please wait.

Presentation is loading. Please wait.

8.7 Memory management Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs.

Similar presentations


Presentation on theme: "8.7 Memory management Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs."— Presentation transcript:

1 8.7 Memory management Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs. Paragraph = a chunk of 16 memory bytes, starting at a physical address of type XXXX0H. Input: AH = 48H (function code), BX = the number of requested paragraphs. Output: if succeeds: CF = 0, AX = the starting segment address of the allocated memory block. if DOS cannot allocate the requested memory: CF = 1, AX = error code, BX = the largest free memory block size (in paragraphs). DOS INT 21, function 49H: Free Allocated Memory Specification: frees a memory block. Input: AH = 49H (function code), ES = the block segment address. Output: if succeeds: CF = 0. if DOS cannot free memory block: CF = 1, AX = error code. Constrain: the block segment address must be previously obtained trough INT 21H, function 48H. DOS INT 21, function 4AH: Modify Allocated Memory Blocks Specification: modifies the length of an already allocated memory block. Input: AH = 4AH (function code), ES = the block segment address, BX = the block size (in paragraphs) needed after modification. Output: if succeeds: CF = 0. if DOS cannot modify the memory block: CF = 1, AX = error code, BX = the maximum size available for the requested block (in paragraphs). Constrain: the block segment address must be previously obtained trough INT 21H, function 48H.

2 8.7 Memory management Program A Program B Program C Program A Program C Program A Program C Program D Program C Program D Program E Program C Program D Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs. Paragraph = a chunk of 16 memory bytes, starting at a physical address of type XXXX0H. Input: AH = 48H (function code), BX = the number of requested paragraphs. Output: if succeeds: CF = 0, AX = the starting segment address of the allocated memory block. if DOS cannot allocate the requested memory: CF = 1, AX = error code, BX = the largest free memory block size (in paragraphs). DOS INT 21, function 49H: Free Allocated Memory Specification: frees a memory block. Input: AH = 49H (function code), ES = the block segment address. Output: if succeeds: CF = 0. if DOS cannot free memory block: CF = 1, AX = error code. Constrain: the block segment address must be previously obtained trough INT 21H, function 48H. DOS INT 21, function 4AH: Modify Allocated Memory Blocks Specification: modifies the length of an already allocated memory block. Input: AH = 4AH (function code), ES = the block segment address, BX = the block size (in paragraphs) needed after modification. Output: if succeeds: CF = 0. if DOS cannot modify the memory block: CF = 1, AX = error code, BX = the maximum size available for the requested block (in paragraphs). Constrain: the block segment address must be previously obtained trough INT 21H, function 48H. Program E Program D

3 8.8 Using the Mouse MOUSE INT 33, function 00H: Mouse Reset and Status Specification: reset mouse controller and return status. Input: AH = 00 (function code) Output: AX = Mouse Status (0FFh = mouse initialized, 0 = no mouse functions available) BX = mouse buttons status (bit 0 = 1 =>left button pressed, bit 1 = 1 =>right button pressed. Constrain: INT 33 is neither a DOS or BIOS interrupt. The mouse driver MOUSE.SYS should be loaded or MOUSE.COM executed, to install this interrupt. MOUSE INT 33, function 01H: Show mouse cursor Specification: turn on the mouse cursor (inverse video box in text mode, arrow in graphics mode). MOUSE INT 33, function 02H: Hide mouse cursor Specification: turn off the mouse cursor. MOUSE INT 33, function 03H: Get Button Status and Mouse Position Specification: returns button status and mouse position. Input: AH = 03 (function code) Output:BX = Button Status (similar to function 00), CX = horizontal position of the mouse cursor (CX = 0 => cursor on the most left position. DX = vertical position of the mouse cursor (DX = 0 => cursor on the most upper position. The maximum CX and DX values depend on current video mode. Input: AH = 01(function code) Input: AH = 02 (function code)

4 8.9 Writing a Memory Resident Program DOS INT 21, function 31H: Terminate and Stay Resident Specification: returns control to DOS, keeping allocated memory. Input: AH = 31H (function code), DX the number of paragraphs remaining resident. Note: The keeped memory allocation must be large enough to store the Program Segment Prefix and the necessary code and data segments. DOS INT 21, function 27H: Terminate and Stay Resident (only.COM files) Specification: returns control to DOS, keeping allocated memory. Constrain: used only for.COM programs. Input: AH = 27H (function code), DX = the number of bytes remaining resident. The TSR (Terminate and Stay Resident) program can be activated using an interrupt. To be able to do this, it should be installed = hooking an interrupt (timer, keyboard, serial port...). When discharging the allocated memory, the TSR should restore the IPT (Interrupt Pointer Table) at the previous state. The TSR (when activated by the hooked interrupt) uses the current SS:SP of the interrupted program to save the used registers (beside FLAGS and return address already saved by interrupt acknowledging). If a large stack amount is needed, the TSR should use it’s own stack area (modifying SS:SP) and restore the current SS:SP before returning.


Download ppt "8.7 Memory management Program E Program D System memory DOS INT 21, function 48H: Allocate Memory Specification: allocates a number of memory paragraphs."

Similar presentations


Ads by Google