Skip to content

Commit

Permalink
x86 microoptimizations (#123)
Browse files Browse the repository at this point in the history
Co-authored-by: Javier Gutiérrez <[email protected]>
  • Loading branch information
1 parent 4246b8b commit e81872b
Show file tree
Hide file tree
Showing 28 changed files with 180 additions and 172 deletions.
3 changes: 1 addition & 2 deletions command/crit.asm
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ else
endif
call i24_print

mov ah,MS_C_FLUSH ; Clear type ahead buffer
mov al,MS_C_READ ; and then get a character
mov ax,(MS_C_FLUSH * 256) + MS_C_READ ; Clear type ahead buffer and then get a character
int DOS_INT

; In case we get double byte characters...
Expand Down
54 changes: 27 additions & 27 deletions command/cstart.asm
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ endif
mov cs:[int2E_seg],cs
mov cs:[exec_psp],ds

cmp di,0000h ; Disable Code Relocation if we have
test di,di ; Disable Code Relocation if we have
jnz gotCS_10 ; been loaded as an .EXE file
;;mov high_code,FALSE
Expand All @@ -726,7 +726,7 @@ gotCS_10:
mov [crc],ax

mov ah,0ddh ; set Novell error mode
mov dl,0 ; to 00 - BAP
xor dl,dl ; to 00 - BAP
int 21h
mov net_error_mode,al ; save original error mode

Expand Down Expand Up @@ -776,8 +776,8 @@ carry_on:
push es ; Relocate the command processor code
push ds ; into high memory
mov es,ax ; es-> destination segment
mov di,0
mov si,0
xor di,di
xor si,si
mov ds,code_seg ; ds-> code to be moved
mov cx,real_code ; convert bytes to words
shr cx,1
Expand Down Expand Up @@ -820,12 +820,12 @@ exec_name:
push es
mov es,__psp2 ; Get the PSP Segment Address
mov dx,PSP_ENVIRON ; Get the environment segment
cmp dx,0000 ; Have we got an environment ?
test dx,dx ; Have we got an environment ?
jz exec_n11 ; No prevent High Code Support

mov es,dx ; Scan through the environment and
mov di,0 ; determine the Environment size and
mov al,0 ; the Load file name
xor di,di ; determine the Environment size and
xor al,al ; the Load file name
mov cx,7FFFh
exec_n05: ; Scan through the Environment
repne scasb ; searching for the 00 00 terminator
Expand Down Expand Up @@ -1245,9 +1245,9 @@ i2e_10:
; if ds = si = 0 then set batch_seg_ptr to zero and get out.
; This is a clean way of halting batch processing.
mov ax,ds
cmp ax,0
test ax,ax
jne i2e_15
cmp si,0
test si,si
jne i2e_15

mov si,cs:_batch_seg_ptr
Expand Down Expand Up @@ -1534,7 +1534,7 @@ make_fcb10:
;
scan_sepchar:
push di ; Save DI ES points at this segment
mov ah,0 ; Invalidate Separator Character
xor ah,ah ; Invalidate Separator Character

scan_s10:
mov al,[si] ; Get the Character to Test
Expand All @@ -1561,7 +1561,7 @@ scan_s20:
;
scan_filechar:
push di ; Save DI ES points at this segment
mov ah,0 ; Invalidate Separator Character
xor ah,ah ; Invalidate Separator Character
scan_f10:
mov al,[si] ; Get the Character to Test
cmp al,CR
Expand Down Expand Up @@ -1679,7 +1679,7 @@ _readline:
mov ax,cs ; AX = transient code segment
call readline ; do far call to msdos_readline
mov ax,4456h ; Swap to the Application process
mov dl,0 ; History Buffer in DR DOS
xor dl,dl ; History Buffer in DR DOS
int DOS_INT
pop es
pop di
Expand Down Expand Up @@ -2265,7 +2265,7 @@ master_env15:
push ds
mov ds,ax ; DS -> Initial Environment
mov es,PSP_ENVIRON ; ES -> Master Environment
mov si,0
xor si,si
mov di,si
jcxz master_env20 ; If this was a Desqview exec then
rep movsb ; skip the environment copy and
Expand Down Expand Up @@ -2329,7 +2329,7 @@ _int10_cls:
mov ah, 0fh ; get mode
int 10h
and al,7fh
mov ah, 0 ; set mode, clear screen (al bit 7 clear)
xor ah, ah ; set mode, clear screen (al bit 7 clear)
int 10h

push es
Expand Down Expand Up @@ -2388,7 +2388,7 @@ int10_exit:
cginfo:
mov dl, 24 ; assume default # for CGA/MDA
mov ax, 1130h ; character generator info
mov bh, 0
xor bh, bh
int 10h
ret ; dl = nlines - 1

Expand Down Expand Up @@ -2468,7 +2468,7 @@ show_help_10:
int DOS_INT ; do it
pop ds
jc show_help_err2 ; exit on error
cmp ax,0 ; zero bytes read means there's no
test ax,ax ; zero bytes read means there's no
je show_help_err2 ; help seg tagged to file.

ifdef DLS
Expand Down Expand Up @@ -2527,14 +2527,14 @@ write_string_05:
mov al,0ah ;
mov [di],al ;
inc di ;
mov al,0 ;
xor al,al ;
mov [di],al ; terminate string
call flush_buff ; display it
inc bx ;
jmp write_string_00 ; start again

write_string_10:
cmp al,0 ; check for NULL...
test al,al ; check for NULL...
jnz write_string_20 ; ...jump if its not
mov [di],al ; store char
Expand Down Expand Up @@ -2669,7 +2669,7 @@ PRH_PARAM equ word ptr 4[bp]
mov ax,(MS_M_STRATEGY*256)+2
int DOS_INT ; get existing HMA link
mov ah,0
xor ah,ah
push ax ; save it
mov bx,total_length ; get size of resident code/data
sub bx,(dataOFFSET hi_seg_start)-15
Expand Down Expand Up @@ -2803,21 +2803,21 @@ _get_original_envsize PROC NEAR
try_next:
mov es,bx
mov cx,bx ; move into CX
mov bx,0
xor bx,bx
mov ax,es:16h[bx] ; get parent PSP seg in ax
cmp ax,cx ; are they the same ?
je got_org_psp ; yes - found COMMAND.COM PSP
cmp ax,0 ; on MS-DOS parent PSP seg=0
test ax,ax ; on MS-DOS parent PSP seg=0
je null_org_psp
mov bx,ax ; else make this current seg and
jmp try_next ; try again
null_org_psp:
mov ax,cx
got_org_psp:
mov es,ax ; ES = COMMAND.COM PSP seg
mov bx,0
xor bx,bx
mov ax,es:2ch[bx] ; get env seg in ax
cmp ax,0 ; seg = 0000 ?
test ax,ax ; seg = 0000 ?
je bomb_out ; yes - forget it
dec ax ; AX:0000 points to memory descriptor
mov es,ax
Expand Down Expand Up @@ -2868,7 +2868,7 @@ _get_reload_file:
grf_loop:
lodsb
stosb
cmp al,0
test al,al
jnz grf_loop

pop di
Expand Down Expand Up @@ -2904,7 +2904,7 @@ srf_loop:
stosb ; switches, but reload_file is
srf_brian: ; just the file name.

cmp al,0
test al,al
jnz srf_loop

pop di
Expand Down Expand Up @@ -2932,9 +2932,9 @@ _get_out_pipe:
mov ds,[low_seg]
mov si,offset out_pipe
mov cx,8
mov cx,4
cld
rep movsb
rep movsw

pop di
pop si
Expand Down
18 changes: 9 additions & 9 deletions command/csup.asm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ env_e20: ; Found the correct entry now copy
env_e30:
lodsb
stosb ; Copy byte through AL
or al,al
test al,al
jnz env_e30 ; and check for end of string
jmps env_exit
_env_entry ENDP
Expand Down Expand Up @@ -161,7 +161,7 @@ _env_scan PROC near
env_s10:
lodsb
stosb ; Copy byte through AL
or al,al
test al,al
jnz env_s10 ; and check for end of string
jmps env_exit
_env_scan ENDP
Expand Down Expand Up @@ -220,7 +220,7 @@ env_d10:
env_d15:
lodsb
stosb ; Copy through AL checking for the end
or al,al
test al,al
jnz env_d15 ; of the environment after each
jmps env_d10 ; end of string.
env_d20:
Expand Down Expand Up @@ -262,7 +262,7 @@ env_i25:
env_i20:
lodsb
stosb ; Copy the String until a zero byte
or al,al ; then add the environment terminator
test al,al ; then add the environment terminator
loopnz env_i20
mov es:word ptr [di],0
jz env_exit ; Exit with no error if the string is
Expand Down Expand Up @@ -315,7 +315,7 @@ get_key PROC near
push ds
pop es ; Calculate the length of the
mov di,04[bp] ; key by scaning the string for
mov al,0 ; a zero byte.
xor al,al ; a zero byte.
mov cx,-1
repnz scasb
neg cx ; CX is the length of the sting + 2
Expand Down Expand Up @@ -363,7 +363,7 @@ _get_cmdname:
get_cmdname10:
lodsb
stosb
or al,al
test al,al
jnz get_cmdname10
jmp env_exit
Expand Down Expand Up @@ -668,7 +668,7 @@ crm_loop1:
crm_loop2:
lodsb
stosb
cmp al,0
test al,al
jne crm_loop2
loop crm_loop1

Expand Down Expand Up @@ -717,7 +717,7 @@ _dos_parse_filename proc near
mov ax,2901h
int 21h
mov ah,0
mov ah,0 ; Not sure if flags needed so do not replace by xor
pop es
add sp,30h
pop bp
Expand All @@ -733,7 +733,7 @@ _flush_cache proc near
push bp
mov ax,4a10h
mov bx,0
xor bx,bx
mov cx,0edch
int 2fh
Expand Down
Loading

0 comments on commit e81872b

Please sign in to comment.