Skip to content

Instantly share code, notes, and snippets.

@Gavriel770U
Created March 11, 2024 22:00
Show Gist options
  • Save Gavriel770U/814abc15c007ca65ccd54f7796838612 to your computer and use it in GitHub Desktop.
Save Gavriel770U/814abc15c007ca65ccd54f7796838612 to your computer and use it in GitHub Desktop.
Function to create new file in x86 .asm for DOS
proc create_file
; [bp+4] offset file_name
; [bp+6] offset file_handle
; [bp+8] offset error_message
; [bp+10] file attributes [value]
push bp
mov bp, sp
push ax
push bx
push cx
push dx
xor al, al
mov ah, 3Ch
mov dx, [bp+4]
mov bx, [bp+6]
mov cx, [bp+10]
int 21h
jc create_file_error
mov bx, [bp+6]
mov [bx], ax
pop dx
pop cx
pop bx
pop ax
pop bp
ret 8
create_file_error:
mov dx, [bp+8]
mov ah, 09h
int 21h
pop dx
pop bx
pop cx
pop ax
pop bp
ret 8
endp create_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment