⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 install.asm

📁 random.zip 随机数产生器的汇编源代码 cmdsrc.zip 一个文本编辑器的汇编源代码
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	mov	byte ptr [di],0		;Terminate with a NULL char
	mov	mfile_seen,1		;Indicate that init file specified
	jmp	short @process_args_50
@process_args_20:
	push	ax		;Save the option letter
	xchg	ax,cx		;AX = num of char
	call	near ptr aton	;All other options are numeric values
	jnc	@process_args_22 ;No Errors
	jmp	@process_args_5			;Error
@process_args_22:
;AX contains numeric value
	xchg	ax,cx		;CX = numeric value
	pop	ax		;Restore option letter

	cmp	al,'d'		;Is it the dos history size option ?
	jne	@process_args_25
	test	argflags,dosarg ;Already seen argument ?
	jne	@process_args_50 ;Yes, then don't update
	or	argflags,dosarg ;Remember we've seen this option
	mov	dossize,cx
	jmp	short @process_args_50
@process_args_25:
	cmp	al,'m'		;Is it the macro buf size option ?
	jne	@process_args_35
	test	argflags,macroarg ;Already seen argument ?
	jne	@process_args_50 ;Yes, then don't update
	or	argflags,macroarg ;Remember we've seen this option
	mov	macrosize,cx
	jmp	short @process_args_50

@process_args_35:
	cmp	al,'b'		;Is it the symbol buf size option ?
	jne	@process_args_40
	test	argflags,symarg ;Already seen argument ?
	jne	@process_args_50 ;Yes, then don't update
	or	argflags,symarg ;Remember we've seen this option
	mov	symsize,cx
	jmp	short @process_args_50

@process_args_40:
	cmp	al,'s'		;Is it the dir stack option ?
	je	@process_args_55 ;Yes
	jmp	@process_args_5  ;Invalid arg
@process_args_55:
	test	argflags,dirarg ;Already seen argument ?
	jne	@process_args_50 ;Yes, then don't update
	or	argflags,dirarg ;Remember we've seen this option
	mov	dirsize,cx
	
@process_args_50:

	@restore
	ret
process_args endp


;+
; FUNCTION : aton
;
;	Returns the positive integer value of an ASCII string. The value
;	must be between 0 and 65535. If length of string is 0, then a 0
;	value is returned with no error flags.
;
; Parameters:
;	SI	:= address of first character in string
;	AX	:= count of characters
;
; Returns:
;	AX = 16 bit result if no errors.
;	CF = 1 if error (magnitude too large, invalid character etc.)
;	     0 if no errors.
; Register(s) CX,DX  are destroyed.
;-
aton	proc	near
	@save	si,di
	xor	di,di		;Result
	xchg	ax,cx		;CX <- num of chars
	jcxz	@aton_99	;No chars, result = 0 (CF is also 0)
	cmp	cx,6		;Shouldn't be more'n 5 chars
	cmc			;CF=1 if error
	jb	@aton_99	;Error exit
@aton_10:
	lodsb			;al = char
	sub	al,'0'		;Is ASCII value < '0'
	jb	@aton_99
	mov	dx,9		;Comparison with 9, NOT '9'
	cmp	dl,al
	jb	@aton_99	;Not valid char
	xor	ah,ah
	inc	dx		;DX = 10 (multiplier)
	xchg	ax,di		;ax = result so far
	mul	dx		;Multiply by 10
	jb	@aton_99	;Overflow
	add	ax,di		;Add new character
	jb	@aton_99	;Overflow
	xchg	ax,di		;Remember new result in di
	loop	@aton_10	;Go onto next char
@aton_99:
	xchg	ax,di
	@restore
	ret
aton	endp


;+
; FUNCTION : get_dosversion
;
;
; Stores DOS major and minor versions in dos_version_major and
; dos_version_minor.
;-
get_dosversion proc near
	mov	ah,30h
	int	21h
	mov	dos_version_major,al
	mov	dos_version_minor,ah
	ret
get_dosversion endp




;+
; FUNCTION : abort_install
;
;	Called to abort program before installation. Exits to DOS.
;
; Parameters:
;	AL	= Exit code
;
; Returns:
;	Nothing.
;
; Register(s) destroyed:
;	N/A
;-
abort_install proc near
	@Exit
abort_install endp



;+
; FUNCTION : locate_cmdedit
;
;	Called to locate the first copy of CMDEDIT loaded into memory. This
;	is not foolproof in that if CMDEDIT is loaded into high memory
;	using one of the memory managers like QEMM, it will not be found.
;
; Parameters:
;	None.
;
; Returns:
;	AX - segment of first copy of CMDEDIT in memory.
;
; Register(s) destroyed:
;	<TBA>
;-
locate_cmdedit proc near
	@save	si,di,es
	mov	di,offset DGROUP:cmdedit	;SI and DI will used for
	mov	si,di				;comparisons
	xor	ax,ax				;AX will track segments

@locate_cmdedit_5:
	mov	es,ax
	push	si				;Save offsets that are
;						 compared 
	mov	cx,32				;Count to be matched
	rep	cmpsb
	pop	si				;Restore offsets that are
;						 compared 
	je	@locate_cmdedit_50		;Matched
	mov	di,si
	inc	ax
	jmp	short @locate_cmdedit_5		;Try next segment

@locate_cmdedit_50:

	@restore
	ret
locate_cmdedit endp


;+
; FUNCTION : uninstall
;
;	Called to uninstall a previously loaded copy of CMDEDIT.
;	The routine does not return. It exits CMDEDIT.
;
; Parameters:
;	None.
;
; Returns:
;	None.
;
; Register(s) destroyed:
;	<TBA>
;-
uninstall proc near
; Free up the memory occupied by the previous loaded copy of CMDEDIT.
; First give back the all interrupts that were taken over.

; Make sure no one else has taken over the 1b break handler since we
; took it over.
	mov	ax,351bh		;Retrieve current 1b handler
	int	21h
	cmp	bx,offset our_break_handler ;Is the offset the ours ?
	je	@uninstall_20		;Yes
@uninstall_10:
; Someone else's taken over the interrupt. Display message and exit.
	@DispStr msg_unload
	mov	ax,-1
	jmp	abort_install
@uninstall_20:
	mov	ax,es			;Now compare segment
	cmp	ax,cmdedit_seg		;Is it what we expect?
	jne	@uninstall_10		;No, display error

; Now check the int 21h handler.
	mov	ax,3521h		;Retrieve current 1b handler
	int	21h
	cmp	bx,offset cmdedit_isr	;Is the offset the ours ?
	jne	@uninstall_10		;No, error
	mov	ax,es			;Now compare segment
	cmp	ax,cmdedit_seg		;Is it what we expect?
	jne	@uninstall_10		;No, display error

; OK, now restore both interrupts
	mov	es,cmdedit_seg		;ES<-segment of loaded CMDEDIT
	mov	dx,es:prev_isr1b	;DS:DX->original 1b handler
	mov	ds,es:prev_isr1b+2
	mov	ax,251bh		;Return int 1b
	int	21h

	mov	dx,es:old_int21vec	;DS:DX->original int 21h handler
	mov	ds,es:old_int21vec+2
	mov	ax,2521h		;Return int 21
	int	21h

	push	cs
	pop	ds			;Restore DS
;
; Finally, return the block of memory taken up by the previous CMDEDIT copy.
	mov	ah,49h			;Release block function, ES->segment
	int	21h			;Free the block
	jnc	@uninstall_90		;No errors
	@DispStr msg_memerr		;Memory allocation error !
	mov	ax,-1
	jmp	abort_install

@uninstall_90:
	@DispStr msg_uninstalled
	xor	ax,ax

	@Exit	0			;Exit to DOS

uninstall endp


;+
; FUNCTION : change_installed_options
;
;	Called to change settings on a previously installed copy of
;	CMDEDIT. The function exits to DOS.
;
;	This function allows the following options to be toggled or
;	changed:
;		/r - toggles autorecall mode
;		/i - toggles insert mode
;		/g - toggles silent mode
;		/p - sets a new ignore character
;
;	If any other option is specified, error message is displayed.
;	
; Parameters:
;	None.
;
; Returns:
;	Nothing.
;
; Register(s) destroyed:
;	<TBA>
;-

change_installed_options proc near
	@DispStr msg_dup
	mov	al,argflags
	and	al,NOT ignore_arg
	je	@change_installed_options_10
; Unallowed options specified.
	@DispStr options_dup
	mov	ax,-1
	jmp	abort_install

@change_installed_options_10:
	@DispCh LF
; Change the options specified.
	mov	es,cmdedit_seg		;ES->segment of previously loaded
;					 CMDEDIT 
; First toggle the insert mode option. If /i specified, default_imode will
; be 1, else 0. Thus just xor it with the memory resident copy to toggle
; default mode.
	mov	al,es:default_imode
	xor	al,default_imode	
	mov	es:default_imode,al	;Toggle memory resident option
	or	al,al
	je	@change_installed_options_15
	@DispStr msg_imode
	jmp	short @change_installed_options_20
@change_installed_options_15:
	@DispStr msg_omode

@change_installed_options_20:
	mov	al,es:auto_recall
	xor	al,auto_recall
	mov	es:auto_recall,al	;Toggle memory resident option
	or	al,al
	jne	@change_installed_options_25
	@DispStr msg_disable_autorecall
	jmp	short @change_installed_options_30
@change_installed_options_25:
	@DispStr msg_enable_autorecall

@change_installed_options_30:
; And now for silent mode
	mov	al,es:silent
	xor	al,silent
	mov	es:silent,al	;Toggle memory resident option
	or	al,al
	je	@change_installed_options_35
	@DispStr msg_disable_bell
	jmp	short @change_installed_options_40
@change_installed_options_35:
	@DispStr msg_enable_bell

@change_installed_options_40:

; Finally change the ignore character if one was specified.
	test	argflags,ignore_arg
	je	@change_installed_options_90 ;None specified
; Change to the new macro ignore char
	mov	al,macro_ignore_char
	mov	es:macro_ignore_char,al
	@DispStr msg_ignore_char

@change_installed_options_90:
; All done
	@Exit	0

change_installed_options endp




CSEG	ENDS

	END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -