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

📄 c.asm

📁 使用汇编语言编写
💻 ASM
字号:
.386


include common.mac

text	segment use16
assume	CS:text, DS:text
	org	256

myproc	proc
	mov	AH,09h		;printing function
	
	printf	g	;print g	
	printf	g1	;print g1
	
	;parse the command line...
	getf	guff	;guff will have the command line

	;is the command line empty?
	cmp	guff[0], 0
	je	expl
	
	;is the command line starting with ?
	cmp	guff[0], '?'
	je	expl
	
	;we are reading the disk
	cmp	guff[0], '^'
	je	readdisk
		
	;nothing else but to write...
	jmp	writedisk
writedisk:
	printf	g2
	waitenter
	mov	AH, 09h	;writing out
	printf	g3	;what are we doing
	printf	guff	;file name
	call	disk_write ;write to disk
	jmp	rc
readdisk:
	printf	g2
	waitenter
	call	disk_read ;write from disk
	jmp	rc
expl:
	printf	gline
	jmp	rc
rc:	;return
	mov	AX, 4C00h
	int	21h
myproc	endp	

;====================================================================
;====================================================================
;====================   Procedure:  disk_read =======================
;====================================================================
;====================================================================

disk_read proc
	mov	AH, 02h ;read raw input
	mov	AL, 1	;number of sectors
	mov	CH, 0	;cylinder
	mov	CL, 1	;sector
	mov	DH, 1	;head
	mov	DL, 0	;disk drive - floppy
	lea	BX, guff
	int	13h	;call BIOS
	jnae	ocr

	;now guff stores file name
	mov	AH, 02h
	mov	AL, 1
	mov	CH, 1
	mov	CL, 1
	mov	DH, 0
	mov	DL, 0
	lea	BX, file
	int	13h	;call BIOS
	jnae	ocr
	
	;decrypt data
	call	chiper

	;write output to the file saved
	mov	AH, 3Ch		;create file
	mov	CX, 0		;no attributes
	lea	DX, guff	;name
	int	21h		;call DOS
	mov	handle, AX	;get file handle

	mov	AH, 40h		;write to file
	mov	BX, handle	;handle

;get len
	mov	CX, 0	;dump CX and SI
	mov	SI, 0
clen:
	cmp	file[SI], 0 ;is it zero yet?
	je	clenf	;this is the len

	inc	SI	;increase counting
	inc	CX	;increase counting
	jmp	clen	;jump	back
clenf:

	lea	DX, file	;file data
	int	21h		;call DOS
	
	mov	AH, 3Eh		;close file
	mov	BX, handle	;handle
	int	21h		;call DOS

	;open file for writing....
	mov	AH, 09h
	printf	success
	jmp	finr
ocr:
	mov	AH, 09h
	printf  error
finr:	ret
disk_read endp

;====================================================================
;====================================================================

;====================================================================
;====================================================================
;====================   Procedure:  disk_write ======================
;====================================================================
;====================================================================
disk_write proc
	;write file name
	mov	AH, 03h		;write raw output
	mov	AL, 1		;write 1 sector
	mov	CH, 0		;cylinder zero
	mov	CL, 1		;sector no 1
	mov	DH, 1		;head 1
	mov	DL, 0		;disk drive A:
	lea	BX, guff 	;set buffer
	int	13h	 	;call BIOS

	;read file...	
	mov	AH, 3Dh		;open file
	mov	AL, 2		;read-write
	lea	DX, guff	;file name
	int	21h		;call DOS
	mov	handle, AX	;get handle
	
	mov	AH, 3Fh		;reading file
	mov	BX, handle	;set handle
	mov	CX, 1024		;reading
	lea	DX, file	;buffer
	int	21h		;call DOS
	
	;encrypt data
	call	chiper	
	
	;looping through each
	mov	AH, 03h
	mov	AL, 1
	mov	CH, 1
	mov	CL, 1
	mov	DH, 0
	mov	DL, 0
	lea	BX, file
	int	13h
	
	;show message	
	jnb	okw
occ:
	mov	AH, 09h
	printf	error
	jmp	fin
okw:
	mov	AH, 09h
	printf	success
fin:	ret	;return backwards
disk_write endp
;====================================================================
;====================================================================

;====================================================================
;====================================================================
;====================   Procedure:  chiper ==========================
;====================================================================
;====================================================================
chiper	proc
	mov	SI, 0
	;xor values
chipe:
	cmp	file[SI], 0
	je	chipf	;jump if zero...
	xor	file[SI], 3
	inc	SI	;increase counter
	jmp	chipe
chipf:		
	ret ;return
chiper	endp
;====================================================================
;====================================================================


	g	db	'Welcome to Disk Encryptor 1.1...', 10, 13, 'This program allows you to save encrypted data onto the disk....', 10, 13, 'Features: Data Chipering, Maximum of 1024 bytes of raw data', 10, 13,'Software Written in Assembler', 10, 13, '$'
	gline	db	10, 13, '? - help', 10, 13, '^ - reads a file from the floppy', 10, 13, '[Filename] - Saves the file onto a floppy', 10, 13, '$'
	g1	db	'Copyright (C) darksheen 2007. All Rights Reserved.', 10, 13, 10, 13, '$'
	g2	db	10, 13, 'Please insert a floppy and press any key...', 10, 13, '$'
	g3	db	10, 13, 'About to write $'
	error	db	10, 13, 'Error occured$'
	success	db	10, 13, 'Operation Completed$'
	num	db	4 dup(0), '$'
	guff	db	15	dup(0)	
	
	;file storage
	handle	dw	0
	file	db	1024	dup(0)

text	ends
	end	myproc

⌨️ 快捷键说明

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