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

📄 e3-16.asm

📁 e3 是一个全屏的用户友好的文本编辑器
💻 ASM
📖 第 1 页 / 共 4 页
字号:
	cmp dword [blockbegin],0	je SBlock	cmp [blockbegin],si	ja SBlock	cmp si,[blockende]	jb SB_retSBlock:	clcSB_ret:	ret;-------GetEditScreenSize:	mov al,sHOEHE-1	mov byte [lines],al	mov al,sBREITE	mov byte [columns],al		;columns > 255 are ignored...	ret;-------DelEditScreen:push si	push bp	mov di,help	mov bp,di			;end	add bp,help_ws_size	call DispNewScreen	pop bp	pop si	ret;-------InitBSS:mov cx,EXE_absssize		;init bss	mov di,EXE_startbss	cld 	xor ax,ax	rep stosb	mov word [es:textX],0a0ah	;es: due EXESTUB version	ret;-------%ifndef ELKSGetArg:	mov si,80h			;point to params	mov cl,[si]			;get number of chars	xor ch,ch			;make it a word	inc si				;point to first char	add si,cx			;point to just after last char	mov byte [si],0			;make into an ASCIIZ string	sub si,cx			;get back ptr to first char	cld	jcxz no_filename		;if no file name, then get one	mov dx,cxdel_spaces:lodsb	cmp al,SPACECHAR	jne found_letter		;exit loop if al not space	loop del_spacesfound_letter:dec si			;backup to first ascii char	cmp byte [si],SPACECHAR	jz no_filename	retno_filename:xor si,si	ret%endif;----------------------------------------------------------------------;; FIND/REPLACE related stuff;AskForReplace:mov dx, askreplace1	call WriteMess9MachRand	mov cx,suchtext	mov dx,maxfilenamelen		call InputString	jc AskFor_Ex	mov [suchlaenge],ax	mov dx,askreplace2	call WriteMess9MachRand	mov cx,replacetext	mov dx,maxfilenamelen		call InputString	mov [repllaenge],ax	jc AskFor_Ex	jmp short GetOptionsAskForFind:mov dx,askfind	call WriteMess9MachRand	mov cx,suchtext	mov dx,maxfilenamelen	call InputString	mov [repllaenge],ax	jc AskFor_ExGetOptions:mov dx,optiontext	call WriteMess9MachRand	mov cx,optbuffer	mov dx,optslen	call InputString		; empty string is allowd for std options...	call ParseOptions		; ...(set in ParseOptions)	clcAskFor_Ex:pushf	call RestoreStatusLine	call RestKursPos	popf	ret;-------; check string for 2 possible options; ParseOptions:push si	cld	mov si,optbuffer	mov word[vorwarts],1	mov byte[grossklein],0dfhScan1:	lodsb	and al,5fh	cmp al,'C'	jnz notCopt	xor byte[grossklein],20h	;result 0dfh,   2*C is 20h again -->not U optionnotCopt:cmp al,'B'	jnz notBopt	neg word[vorwarts]		;similar 2*B is backward twice i.e. forwardnotBopt:or al,al	jnz Scan1	pop si	ret;-------; the find subroutine itself;find2:	mov bx,difind3:	lodsb	or al,al			;=end?	jz found	cmp al,41h	jb find7	and al,chfind7:	inc di	mov cl,byte [di]	cmp cl,41h	jb find10	and cl,chfind10:	cmp al,cl	jz find3	mov di,bxFindText:mov dx,[vorwarts]		;+1 or -1	mov ch,[grossklein]		;ff or df	mov si,suchtext	cld	lodsb	cmp al,41h	jb find1	and al,chfind1:	add di,dx			;+1/-1	mov cl,byte [di]	cmp cl,41h	jb find6	and cl,chfind6:	cmp al,cl	je find2	cmp di,bp	ja notfound	cmp di,sot	jnb find1notfound:stc	retfound:	mov di,bx	clc				;di points after location	ret;----------------------------------------------------------------------;; INTERFACE to OS kernel;%ifdef ELKSReadFile:mov ax,3			;(3==sys_read) ;return read byte ax	jmp short IntCall		;bx file / cx buffer / dx count byte;-------WriteFile:mov ax,4			;(4==sys_write)	jmp short IntCall;-------OpenFile:mov ax,5	jmp short IntCall		;cx mode / bx path / dx permissions (if create);-------CloseFile:	push bx	push cx	push dx	push si	push di	push bp	mov ax,6			;bx is file desc	int 80h	pop bp	pop di	pop si	pop dx	pop cx	pop bx	xor ax,ax			;always return "NO_ERROR" 	ret;-------SeekFile:xor cx,cx			;offset	mov word [seekhelp],cx		;due special ELKS kernel interface	mov word [seekhelp+2],cx	;due special ELKS kernel interface	mov cx,seekhelp			;2nd arg is a ptr to long, not a long	mov ax,19			;system call number (lseek)	push bx	int 0x80			;bx file / dx method	pop bx	or ax,ax	js IC2		mov ax,word [seekhelp]		;seek result: file size. 32 bit Linux is different here!	mov dx,word [seekhelp+2]	ret;-------IntCall:int 0x80			;bx file / dx methodIC2:	neg ax	mov [errno],ax	neg ax				;set flags also	ret		;-------IOctlTerminal:mov bx,stdin		;expects dx termios or winsize structure ptr	mov ax,54			;54 == the ioctl syscall no.	int 80h				;cx TCSETS,TCGETS,TIOCGWINSZ	ret;-------%ifdef SYS_FSTATFstat:	mov cx,fstatbuf	mov al,108			;currently  (April 2002) one gets	jmp short IntCall		;error code  38:  Function not implemented%endif%else	;---------------;; ******beside int 21h we have also BIOS calls:; **** 	mov ax,1302h	int 10h; ****	mov ah,0eh	int 10h; ****	mov ah,2	int 10h; ****  mov ah,0	int 16h; *****************************;OpenFile:xchg bx,dx			;elks register style	mov ax,3d02h			;r/w  input bx=^pathIntcall:int 21h				;=ax file	jnc NoErr	mov [errno],ax	mov ax,-1NoErr:	test ax,ax			;set sign flag	retCreateFile:xor dx,dx	xchg bx,dx			;elks style	xor cx,cx			;input bx=^path	mov ah,3ch	jmp short IntcallReadFile:mov ah,3fh	jmp short WFileWriteFile:mov ah,40hWFile:	push dx	xchg dx,cx	int 21h		jnc NoErr2	mov [errno],ax	mov ax,-1NoErr2:	test ax,ax			;set sign flag	pop dx	retCloseFile:mov ah,3eh			;path in bx	jmp short IntcallSeekFile:mov al,dl			;ELKS register style	mov ah,42h	xor dx,dx	xor cx,cx	jmp short Intcall%endifEXE_endcode:;;----------------------------------------------------------------------;section .databits 16EXE_startdata:;; CONSTANT DATA AREA;Ktable	db 45h	;^K@	xlatb table for making pseudo-scancode	db 45h	;^ka	45h points to an an offset in jumptab1	db 41h	;^kb	41h for example points to KeyCtrlKB function offset	db 43h	;^kc	db 5dh	;^kd	db 45h	;^ke	45h means SimpleRet i.e. 'do nothing'	db 45h	;^kf	db 45h	;^kg	db 57h	;^kh	db 45h	;^ki	db 45h	;^kj	db 42h	;^kk	db 45h	;^kl	db 45h	;^km	db 45h	;^kn	db 45h	;^ko	db 45h	;^kp	db 46h	;^kq	db 3dh	;^kr	;not yet for ELKS	db 5ch	;^ks	db 45h	;^kt	db 45h	;^ku	db 56h	;^kv	db 3eh	;^kw	db 44h	;^kx	db 4eh	;^kyQtable	db 45h	;^q@	ditto for ^Q menu	db 54h	;^qa	db 5ah	;^qb	db 58h	;^qc 	db 4fh	;^qd	db 45h	;^qe		db 55h	;^qf	db 45h	;^qg		db 45h	;^qh	db 4Ah	;^qi	db 45h	;^qj	db 5bh	;^qk	db 45h	;^ql	db 45h	;^qm	db 45h	;^qn	db 45h	;^qo	db 4ch	;^qp	db 45h	;^qq	db 59h	;^qr	db 47h	;^qs				db 45h	;^qt	db 45h	;^qu	db 45h	;^qv	db 45h	;^qw	db 45h	;^qx	db 40h	;^qysize equ 2	;(byte per entry)jumptab1:	; The associated key values originaly were BIOS scan codes...		;  ... now using terminal device this does have less sense, so I altered some 		;  ... special cases, like ^PageUp (was 84h, but extends the table too much)		;  ... to some places shortly after 5dh (i.e. shift F10).		; Using terminals the F-keys are not supported on ELKS (but DOS only). lowest 	equ 3bh		dw SimpleRet		;3bh	dw KeyCtrlL		;3ch  ^L   F2 (ditto)	dw KeyCtrlKR		;3dh  ^KR  F3 (etc)	dw KeyCtrlKW		;3eh  ^KW	dw KeyCtrlT		;3fh  ^T	dw KeyCtrlQY		;40h  ^QY	dw KeyCtrlKB		;41h  ^KB	dw KeyCtrlKK		;42h  ^KK	dw KeyCtrlKC		;43h  ^KC	dw KeyCtrlKX		;44h  ^KX  F10	dw SimpleRet		;45h       F11	dw KeyCtrlKQ		;46h       F12	dw KeyHome		;47h	dw KeyUp		;48h	dw KeyPgUp		;49h	dw KeyCtrlQI		;4Ah	dw KeyLeft		;4bh	dw KeyCtrlQP		;(5 no num lock) 	dw KeyRight		;4dh	dw KeyCtrlKY		;(+)  ^KY	dw KeyEnd		;4fh	dw KeyDown		;50H	dw KeyPgDn		;51h	dw KeyIns		;52H	dw KeyDel		;53H	dw KeyCtrlQA		;54h ^QA sF1	dw KeyCtrlQF		;55h ^QF sF2	dw KeyCtrlKV		;56h ^KV	dw KeyCtrlKH		;57h	dw KeyCtrlQC		;58h	dw KeyCtrlQR		;59h	dw KeyCtrlQB		;5Ah ^QB	dw KeyCtrlQK		;5Bh ^QK  sF8	dw KeyCtrlKS		;5ch ^KS  sF9	dw KeyCtrlKD		;5dh ^KD  sF10jumps1 equ ($-jumptab1) / sizejumptab3 dw SimpleRet		;^@	dw KeyCtrlLeft		;^a	dw SimpleRet		;^b	dw KeyPgDn		;^c	dw KeyRight		;^d	dw KeyUp		;^e	dw KeyCtrlRight		;^f	dw KeyDel		;^g 7	dw KeyDell		;^h 8   DEL (7fh is translated to this)	dw NormChar		;^i 9	dw KeyRet		;^j = 0ah	dw CtrlKMenu		;^k b	dw KeyCtrlL		;^l c	dw KeyRet		;^m 0dh	dw SimpleRet		;^n e	dw SimpleRet		;^o f	dw CtrlQMenu		;^p 10	;^P like ^Q 	dw CtrlQMenu		;^q 11	dw KeyPgUp		;^r 12	dw KeyLeft		;^s 13	dw KeyCtrlT		;^t 14	dw SimpleRet		;^u 15	dw KeyIns		;^v 16	dw SimpleRet		;^w 17	dw KeyDown		;^x 18	dw KeyCtrlY		;^y 19;-------optiontext	db 'OPT? C/B ',0filename	db 'FILENAME:',0filesave	db '   SAVE: ',0asksave		db 'SAVE? Y/n',0blockread	db '^KR NAME:',0blocksave	db '^KW NAME:',0asklineno	db 'GO LINE :',0askfind		db '^QF FIND:',0askreplace1	db '^QA REPL:',0askreplace2	db '^QA WITH:',0stdtxtlen	equ filesave-filename%ifdef ELKS screencolors0	db 27,'[40m',27,'[37m' bold0		db 27,'[0m'		;reset to b/w screencolors1	db 27,'[41m',27,'[36m'	;yellow on blue reversevideoX: bold1:		db 27,'[1m'		;bold scolorslen	equ $-screencolors1 boldlen	equ $-bold1		;take care length of bold0 == length of bold1%endif;-------%macro LD 0 %ifdef ELKS  db 10 %else  db 13,10 %endif%endmacro;-------errmsgs:%ifdef ELKSdb "Op not permitted"			;1LDdb "No such file|directory"		;2LDLD					;3LD					;4db "Input/output"			;5LDdb "No such device"			;6LDLD					;7LD					;8db "Bad file descriptor"		;9LDLD					;10LD					;11db "Cannot allocate memory"		;12LDdb "Permission denied"			;13LDLD					;14LD					;15db "Device or resource busy"		;16LDLD					;17LD					;18db "No such device"			;19LDLD					;20db "Is a directory"			;21LDdb "Invalid argument"			;22LDdb "Too many open files"		;23LDdb "Too many open files"		;24LDdb "Inappropriate ioctl"		;25LDdb "Text file busy"			;26LDdb "File too large"			;27LDdb "No space left on device"		;28LDdb "Illegal seek"			;29LDdb "R/O file system"			;30LD%elsedb "Op not permitted"			;1LDdb "No such file|directory"		;2LDdb "Path not found"			;3LDdb "Too much open files"		;4LDdb "Access denied"			;5LDLD					;6LD					;7LD					;8LD					;9LD					;10LD					;11db "Cannot allocate memory"		;12LDLD					;13LD					;14db "Invalid drive"LD					;15LD					;16LD					;17LD					;18db "R/O file system"			;19LDLD					;20db "Drive not ready"			;21LDdb "Invalid argument"			;22LDLD					;23LD					;24db "Illegal seek"			;25LDLD					;26LD					;27LD					;28db "Write"				;29LDdb "Read"				;30LD%endif;-----------------------------------------------------------------------newline:db 10help:db "MicroEditor e3/16bit v0.2 GPL (C) 2002 A.Kleine <kleine@ak.sax.de>"LDdb "Enter filename or leave with RETURN"LDLDdb "Files:	^KR Insert	^KS Save	^KX Save&Exit	^KQ Abort&Exit"LDdb "	^KD Save&Load"		; ^KR not yet ready on ELKSLDLDdb "Blocks:	^KB Start	^KK End		^KC Copy	^KY Del"LDdb "	^KV Move	^KW Write"LDLDdb "Search:	^QF Find	^L  Repeat	^QA Srch&Repl"LDLDdb "Move:	^E  Up		^X  Down	^S  Left	^D  Right"LDdb "	^R  Page Up	^C  Page Dn	^F  Next Word	^A  Prev Word"LDLDdb "Quick-	^QS Home	^QD End		^QR BOF		^QC EOF"LDdb "-Move:	^QB Blk Begin	^QK Blk End	^F  Next Word	^A  Prev Word"LDdb "	^QI Go Line#"LDLDdb "Delete:	^T  Word	^Y  Line	^H  Left	^G  Chr"LDdb "	^QY Line End"LDhelp_ws_size equ $-helpLD%ifndef EXESTUBEXE_enddata:;-----------------------------------------------------------------------;section .bssbits 16%endifEXE_startbss:;%ifdef ELKS screenline_len	equ 256+4*scolorslen	;max possible columns + 4 color ESC seq per line%else	;-------------- screenline_len	equ sBREITE * 2		;2 byte per char%endif%ifdef ELKS termios_size	equ 60 termios	resb termios_size orig		resb termios_size setkplen	equ 10 setkp		resb setkplen		;to store cursor ESC seq like  db 27,'[000;000H' read_b		resw 1			;buffer for GetChar isbold		resw 1			;control of bold display of ws-blocks inverse	resw 1 seekhelp	resd 1			;syscall helper (for seeking more than 16 bit range) perms		resw 1%ifdef SYS_FSTAT fstatbuf	resb 64			;prepared for later%endif%else		;----- zeilenangabe	resb 12			;buffer for showlinenum%endif%ifdef LESSWRITEOPS screenbuffer_size equ 62*(160+32)	;estimated 62 lines 160 columns, 32 byte ESC seq (ca.12k) screenbuffer_dwords equ screenbuffer_size/4 screenbuffer resb screenbuffer_size screenbuffer_end equ $			;If you really have higher screen resolution,%endiferrno		resw 1			;used similar libc, but not excactly equalerror		resb errlen		;reserved space for string: 'ERROR xxx:tttteeeexxxxtttt',0columne		resw 1			;helper for display of current columnzloffset	resw 1			;helper: chars scrolled out at left borderfileptr		resw 1			;helper for temp storage of current pos in filetabcnt		resw 1			;internal helper byte in DispNewScreen() onlykurspos		resw 1			;cursor position set by DispNewScreen()kurspos2	resw 1			;cursor position set by other functionsinsstat		resw 1endedit		resw 1			;byte controls program exitchanged		resw 1			;status byte: (UN)CHANGEDlinenr		resw 1			;current lineshowblock	resw 1			;helper for ^KHblockbegin	resw 1blockende	resw 1bereitsges	resw 1			;byte used for ^Lsuchlaenge	resw 1			;helper for ^QA,^QFrepllaenge	resw 1vorwarts	resw 1grossklein	resw 1			;helper byte for ^QF,^QAold		resw 1			;helper for ^QPveryold		resw 1			;dittoch2linebeg	resw 1			;helper keeping cursor pos max at EOL (up/dn keys)numeriere	resw 1			;byte controls re-numerationlines		resw 1			;equ 23 or similar i.e. screen lines-2 (status-,unused line)columns		resw 1			;equ 80 or similar word (using only LSB)filepath	resb maxfilenamelen+1blockpath	resb maxfilenamelen+1replacetext	resb maxfilenamelen+1suchtext	resb maxfilenamelen+1optbuffer	resb maxfilenamelen+1	;buffer for search/replace options and for ^QIoptslen		equ $-optbufferscreenline	resb screenline_len	;buffer for displaying a text linetextX		resb MAXLENsot 		equ (textX+1)		;start-of-textalignb 4EXE_endbss:	EXE_absssize equ (EXE_endbss-EXE_startbss+3) & (~3)%ifdef EXE	EXE_acodesize equ (EXE_endcode-EXE_startcode+3) & (~3)	EXE_datasize equ EXE_enddata-EXE_startdata	EXE_allocsize equ EXE_acodesize + EXE_datasize +100h%endif%ifndef ELKS%ifdef EXESTUBbits 16section .stack stack	resb 0x800%endif%endif

⌨️ 快捷键说明

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