More generic macros for specific encodings
This commit is contained in:
parent
d47321c53b
commit
21c3c59489
73
edlin.asm
73
edlin.asm
|
@ -21,36 +21,39 @@ sys_set_dta equ 0x1a
|
|||
sys_block_read equ 0x27
|
||||
|
||||
; Special instruction encodings
|
||||
%macro add_cx_ax 0
|
||||
db 0x03, 0xC8 ; add cx, ax (direction swapped)
|
||||
%endmacro
|
||||
%macro add_di_cx 0
|
||||
db 0x03, 0xF9 ; 023E add di, cx (direction swapped)
|
||||
%endmacro
|
||||
%define r_ax 0
|
||||
%define r_cx 1
|
||||
%define r_dx 2
|
||||
%define r_bx 3
|
||||
%define r_sp 4
|
||||
%define r_bp 5
|
||||
%define r_si 6
|
||||
%define r_di 7
|
||||
|
||||
%macro sub_cx_di 0
|
||||
db 0x2b, 0xcf ; sub cx, di (direction swapped)
|
||||
%endmacro
|
||||
%define r_al 0
|
||||
%define r_cl 1
|
||||
%define r_dl 2
|
||||
%define r_bl 3
|
||||
%define r_ah 4
|
||||
%define r_ch 5
|
||||
%define r_dh 6
|
||||
%define r_bh 7
|
||||
|
||||
%macro or_al_al 0
|
||||
db 0x0a, 0xc0 ; or al, al (direction swapped)
|
||||
; Direction swapped reg, reg
|
||||
%macro addw 2
|
||||
db 0x03, 0xc0 + 8 * %1 + %2
|
||||
%endmacro
|
||||
|
||||
%macro xor_ax_ax 0
|
||||
db 0x33, 0xc0 ; xor ax, ax (direction swapped)
|
||||
%macro orb 2
|
||||
db 0x0a, 0xc0 + 8 * %1 + %2
|
||||
%endmacro
|
||||
|
||||
%macro mov_ax_cx 0
|
||||
db 0x8b, 0xc1 ; mov ax, cx (direction swapped)
|
||||
%macro subw 2
|
||||
db 0x2b, 0xc0 + 8 * %1 + %2
|
||||
%endmacro
|
||||
%macro mov_dx_cx 0
|
||||
db 0x8b, 0xD1 ; mov dx, cx (direction swapped)
|
||||
%macro xorw 2
|
||||
db 0x33, 0xc0 + 8 * %1 + %2
|
||||
%endmacro
|
||||
%macro mov_di_cx 0
|
||||
db 0x8b, 0xf9 ; mov di, cx (direction swapped)
|
||||
%endmacro
|
||||
%macro mov_di_dx 0
|
||||
db 0x8b, 0xfa ; mov di, dx (direction swapped)
|
||||
%macro movw 2
|
||||
db 0x8b, 0xc0 + 8 * %1 + %2
|
||||
%endmacro
|
||||
|
||||
%macro cmp_byteaddr_bytext 2
|
||||
|
@ -84,7 +87,7 @@ ensure_file_argument:
|
|||
je print_filename_missing_error
|
||||
|
||||
; AL at program start a flag of whether drive specifier in first parameter valid
|
||||
or_al_al
|
||||
orb r_al, r_al
|
||||
mov dx, invalid_name_error
|
||||
jnz _trampoline_error_1
|
||||
|
||||
|
@ -100,7 +103,7 @@ open_file:
|
|||
int 0x21
|
||||
|
||||
mov [new_file_flag], al
|
||||
or_al_al
|
||||
orb r_al, r_al
|
||||
jz delete_old_bak
|
||||
|
||||
mov dx, new_file_str
|
||||
|
@ -130,7 +133,7 @@ delete_old_bak: ; 01b9
|
|||
|
||||
mov ah, sys_create_file
|
||||
int 0x21
|
||||
or_al_al
|
||||
orb r_al, r_al
|
||||
jz setup_file_parameters
|
||||
|
||||
mov dx, directory_full_error
|
||||
|
@ -141,7 +144,7 @@ print_bak_error: ; 01e6
|
|||
jmp error
|
||||
|
||||
setup_file_parameters: ; 01ec
|
||||
xor_ax_ax
|
||||
xorw r_ax, r_ax
|
||||
mov [psp_fcb_1 + fcb_record_low], ax
|
||||
mov [psp_fcb_1 + fcb_record_high], ax
|
||||
mov [__0a58_fcb + fcb_record_low], ax
|
||||
|
@ -152,7 +155,7 @@ setup_file_parameters: ; 01ec
|
|||
mov [__0a58_fcb + fcb_record_size], ax
|
||||
|
||||
mov dx, disk_transfer_area
|
||||
mov_di_dx
|
||||
movw r_di, r_dx
|
||||
mov ah, sys_set_dta
|
||||
int 0x21
|
||||
|
||||
|
@ -168,13 +171,13 @@ setup_file_parameters: ; 01ec
|
|||
|
||||
; __0a94 = ¼ available memory
|
||||
shr cx, 1
|
||||
mov_ax_cx
|
||||
movw r_ax, r_cx
|
||||
shr cx, 1
|
||||
mov [__0a94], cx
|
||||
; cx = ¾ available memory
|
||||
add_cx_ax
|
||||
addw r_cx, r_ax
|
||||
|
||||
mov_dx_cx
|
||||
movw r_dx, r_cx
|
||||
add dx, disk_transfer_area
|
||||
mov [__0a96], dx
|
||||
|
||||
|
@ -183,7 +186,7 @@ read_file:
|
|||
mov ah, sys_block_read
|
||||
int 0x21
|
||||
call find_file_end_char
|
||||
add_di_cx
|
||||
addw r_di, r_cx
|
||||
|
||||
__0240:
|
||||
db 0xFC ; 0240 cld
|
||||
|
@ -313,11 +316,11 @@ find_file_end_char: ; 035e
|
|||
|
||||
mov al, 0x1a ; ^Z
|
||||
repne scasb
|
||||
mov_di_cx
|
||||
movw r_di, r_cx
|
||||
|
||||
pop cx
|
||||
lahf
|
||||
sub_cx_di
|
||||
subw r_cx, r_di
|
||||
sahf
|
||||
|
||||
pop di
|
||||
|
|
Loading…
Reference in New Issue