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

📄 appendfile.asm

📁 appendfile:This program appends text to an existing file.
💻 ASM
字号:
TITLE Appending to a File                   (AppendFile.asm)

; This program appends text to an existing file.
; Last update: 1/30/02

INCLUDE Irvine32.inc

.data
buffer BYTE "This text is appended to an output file.",0dh,0ah
bufSize = ($-buffer)
errMsg BYTE "Cannot open file",0dh,0ah,0
filename     BYTE "output.txt",0
fileHandle   DWORD ?	; handle to output file
bytesWritten DWORD ?    	; number of bytes written

.code
main PROC
	INVOKE CreateFile,
	  ADDR filename, GENERIC_WRITE, DO_NOT_SHARE, NULL,
	  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0

	mov fileHandle,eax		; save file handle
	.IF eax == INVALID_HANDLE_VALUE
	  mov  edx,OFFSET errMsg		; Display error message
	  call WriteString
	  jmp  QuitNow
	.ENDIF

	; Move the file pointer to the end of the file
	INVOKE SetFilePointer,
	  fileHandle,0,0,FILE_END

	; Append text to the file
	INVOKE WriteFile,
	    fileHandle, ADDR buffer, bufSize,
	    ADDR bytesWritten, 0

	INVOKE CloseHandle, fileHandle

QuitNow:
	exit
main ENDP
END main

⌨️ 快捷键说明

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