diff --git a/edlin.asm b/edlin.asm index 3d009da..324c5bb 100644 --- a/edlin.asm +++ b/edlin.asm @@ -223,7 +223,7 @@ initialize_editor: ; 0240 test byte [new_file_flag], 0xff jnz editor_mainloop - call __0370 + call command_a editor_mainloop: ; 0273 mov sp, stack.end @@ -278,6 +278,8 @@ editor_mainloop: ; 0273 repne scasb jne print_entry_error ; Not found + ; CX counts down, so first entry matching gives cx=9, second cx=8, etc. + movw r_bx, r_cx mov ax, [__0a82] orw r_ax, r_ax @@ -366,17 +368,19 @@ parse_line_specifier: ; 02f9 ret commands db 'QWASRDLIE', 13 ; 0340 + +; This is reversed in regards to commands table due to implementation of matching command_addresses: ; 034a - dw command_q ; Q - dw command_w ; W - dw command_a ; A - dw command_s ; S - dw command_r ; R - dw command_d ; D - dw command_l ; L - dw __0370 ; I - dw command_e ; E dw command_cr ; CR + dw command_e ; E + dw command_i ; I + dw command_l ; L + dw command_d ; D + dw command_r ; R + dw command_s ; S + dw command_a ; A + dw command_w ; W + dw command_q ; Q find_file_end_char: ; 035e push di @@ -397,7 +401,7 @@ find_file_end_char: ; 035e __036d: jmp print_eof_str -__0370: +command_a: test byte [new_file_flag], 0xff jnz __036d @@ -487,7 +491,7 @@ __0406: _trampoline_oom_1: ; 0414 jmp oom -command_e: ; 0417 +command_w: ; 0417 db 0x8B, 0x1E, 0x80, 0x0A ; 0417 mov bx,[0xa80] db 0x0B, 0xDB ; 041B or bx,bx db 0x75, 0x1C ; 041D jnz 0x43b @@ -601,7 +605,7 @@ db 0x04, 0x30 ; 0507 add al,0x30 db 0x2A, 0xC3 ; 0509 sub al,bl db 0xE9, 0x16, 0x04 ; 050B jmp 0x924 -command_s: ; 050e +command_l: ; 050e db 0x8B, 0x1E, 0x80, 0x0A ; 050E mov bx,[0xa80] db 0x0B, 0xDB ; 0512 or bx,bx db 0x75, 0x0C ; 0514 jnz 0x522 @@ -668,7 +672,7 @@ db 0xAA ; 0591 stosb db 0xC3 ; 0592 ret db 0xE9, 0xC9, 0x00 ; 0593 jmp 0x65f -command_d: ; 0596 +command_r: ; 0596 db 0xE8, 0xFD, 0x00 ; 0596 call 0x696 db 0x75, 0xF8 ; 0599 jnz 0x593 db 0x8B, 0x36, 0x8C, 0x0A ; 059B mov si,[0xa8c] @@ -725,7 +729,7 @@ db 0xC3 ; 0621 ret db 0xBA, 0x21, 0x0A ; 0622 mov dx,0xa21 db 0xEB, 0x3B ; 0625 jmp short 0x662 -command_l: ; 0627 +command_s: ; 0627 db 0xE8, 0x6C, 0x00 ; 0627 call 0x696 db 0x75, 0x33 ; 062A jnz 0x65f db 0x8B, 0x1E, 0x8A, 0x0A ; 062C mov bx,[0xa8a] @@ -841,7 +845,7 @@ db 0xAA ; 074A stosb db 0x41 ; 074B inc cx db 0xEB, 0xF3 ; 074C jmp short 0x741 -command_r: ; 074e +command_d: ; 074e db 0x8B, 0x1E, 0x80, 0x0A ; 074E mov bx,[0xa80] db 0x0B, 0xDB ; 0752 or bx,bx db 0x75, 0x04 ; 0754 jnz 0x75a @@ -866,7 +870,7 @@ db 0x33, 0xC9 ; 077E xor cx,cx db 0xEB, 0x55 ; 0780 jmp short 0x7d7 db 0xE9, 0x6A, 0xFB ; 0782 jmp 0x2ef -command_q: ; 0785 +command_cr: ; 0785 db 0x8B, 0x1E, 0x80, 0x0A ; 0785 mov bx,[0xa80] db 0x0B, 0xDB ; 0789 or bx,bx db 0x75, 0x05 ; 078B jnz 0x792 @@ -931,7 +935,7 @@ oom: ; 080c int 0x21 jmp editor_mainloop -command_a: ; 08cd +command_i: ; 0816 db 0xB8, 0x23, 0x25 ; 0816 mov ax,0x2523 db 0xBA, 0x7D, 0x08 ; 0819 mov dx,0x87d db 0xCD, 0x21 ; 081C int 0x21 @@ -994,7 +998,7 @@ db 0x4F ; 089E dec di db 0x89, 0x3E, 0x9A, 0x0A ; 089F mov [0xa9a],di db 0xE9, 0xCD, 0xF9 ; 08A3 jmp 0x273 -command_cr: ; 08a6 +command_q: ; 08a6 db 0xBA, 0x45, 0x0A ; 08A6 mov dx,0xa45 db 0xB4, 0x09 ; 08A9 mov ah,0x9 db 0xCD, 0x21 ; 08AB int 0x21 @@ -1012,7 +1016,7 @@ db 0xCD, 0x20 ; 08C2 int 0x20 db 0xC7, 0x06, 0x80, 0x0A, 0xFF, 0xFF ; 08C4 mov word [0xa80],0xffff db 0xE8, 0xA3, 0xFA ; 08CA call 0x370 -command_w: ; 08cd +command_e: ; 08cd db 0xC6, 0x06, 0x7F, 0x0A, 0x01 ; 08CD mov byte [0xa7f],0x1 db 0xBB, 0xFF, 0xFF ; 08D2 mov bx,0xffff db 0xE8, 0x63, 0xFB ; 08D5 call 0x43b