| 1 |
figdor32 |
4 |
; DX = String ptr |
| 2 |
|
|
DOS_PrintString: |
| 3 |
|
|
MOV AH, DISPLAY_STRING |
| 4 |
|
|
INT 21H |
| 5 |
|
|
RET |
| 6 |
|
|
|
| 7 |
|
|
; DX = Filename ptr |
| 8 |
|
|
; CF = 1 Error CF = 0 Pass |
| 9 |
|
|
; AX = File handle/Error code if CF |
| 10 |
|
|
DOS_OpenReadonly: |
| 11 |
|
|
CLC ; Technically not needed, but, uhm... |
| 12 |
|
|
MOV AL, OPEN_ACCESS_READONLY |
| 13 |
|
|
MOV AH, OPEN_FILE ; AH = 3Dh Open a file, DX = Filename ptr, AL = Access control, handle at AX if CF set |
| 14 |
|
|
INT 21H |
| 15 |
|
|
RET |
| 16 |
|
|
|
| 17 |
|
|
; BX = File Handle |
| 18 |
|
|
DOS_CloseFile: |
| 19 |
|
|
MOV AH, CLOSE_FILE |
| 20 |
|
|
INT 21H |
| 21 |
|
|
RET |
| 22 |
|
|
|
| 23 |
|
|
; BX = Paragraphs to allocate |
| 24 |
|
|
; CF = 1 Error CF = 0 Pass |
| 25 |
|
|
; AX = Segment addr/Error code if CF |
| 26 |
|
|
DOS_AllocateMemory: |
| 27 |
|
|
MOV AH, ALLOCATE_MEMORY |
| 28 |
|
|
INT 21H |
| 29 |
|
|
RET |
| 30 |
|
|
|
| 31 |
|
|
; ES = Segment to free |
| 32 |
|
|
; CF = 1 Error CF = 0 Pass |
| 33 |
|
|
; AX = Error code if CF |
| 34 |
|
|
DOS_FreeMemory: |
| 35 |
|
|
MOV AH, FREE_MEMORY |
| 36 |
|
|
INT 21H |
| 37 |
|
|
RET |
| 38 |
|
|
|
| 39 |
|
|
; BX = File Handle |
| 40 |
|
|
; CX = Number of bytes to read |
| 41 |
|
|
; DX = Offset in the buffer |
| 42 |
|
|
; ES = Memory segment |
| 43 |
|
|
; CF = 1 Error CF = 0 Pass |
| 44 |
|
|
; AX = Number of bytes read/Error code if CF |
| 45 |
|
|
DOS_ReadFileIntoES: |
| 46 |
|
|
PUSH DS ; Store the DS for later |
| 47 |
|
|
MOV AX, ES ; Yes |
| 48 |
|
|
MOV DS, AX ; DS = allocated memory segment |
| 49 |
|
|
MOV AH, READ_FILE ; Read file |
| 50 |
|
|
INT 21H ; Magic |
| 51 |
|
|
POP DS ; Restore DS |
| 52 |
|
|
RET |
| 53 |
|
|
|
| 54 |
|
|
; BX = File Handle |
| 55 |
|
|
; CX = Number of bytes to read |
| 56 |
|
|
; DS:DX = Buffer address |
| 57 |
|
|
; CF = 1 Error CF = 0 Pass |
| 58 |
|
|
; AX = Number of bytes read/Error code if CF |
| 59 |
|
|
DOS_ReadFile: |
| 60 |
|
|
MOV AH, READ_FILE ; Read file |
| 61 |
|
|
INT 21H ; Magic |
| 62 |
|
|
RET |