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

📄 test.asm

📁 人工造字汇编程序
💻 ASM
字号:
.286
data segment
mes db 128 dup(0ffh),'$'
mes1 db 10 dup(0ffh),12 dup (00h),106 dup (0ffh)
mode db 00000010b
color db 0ffh
count db 00h
addr dw 19213 ;//240行,52列
left db 00000001b
right db 00000010b
drawaddr dw ?
printaddr dw ?
mesaddr dw ?
masknote db ?
black db 00h
white db 00fh
px dw 30
py dw 150
clickx dw 321
clicky dw 200
recentx dw ?
recenty dw ?
non_code_msg db '****sorry,there is no such code for words******',0dh,0ah,'$'
character db 10
	db 9 dup (0ffh)
pathnam db 'c:\1.txt',0
openmsg db '**** open error******', 0dh,0ah ,'$'
readmsg db '*****read error *****' , 0dh, 0ah, "$"
handle dw ?
doublemsg db '*****sorry,you code have been used ,please choose anther***', 0dh,0ah,'$'
endcde db 0
errormsg db 'the file is not created successfully',0dh,0ah,'$'
buff db 10,10,10 dup (?) ,'$'
buff1 db 'dddddddddddddddddddddddd','$'
inputmsg db 'please input the code',0dh,0ah,'$'
testmsg db '******this is your target *******',0dh,0ah,'$'
counth db ?
higher_order dw 0
lower_order dw 0
buff_in_data db 10,10,10 dup(?),'$'
judgeresult db 1
readhresult db 1
headmsg db '*****please select a function*****',0dh,0ah
	 db  '**(E)--edit,(W)--print with code , (Q)--exit**',0dh,0ah,'$'
printx dw 300
printy dw 200
newcount dw ?
print_code_msg db '***the code you have been tape justnow is',0dh,0ah,'$'
data ends

extra segment
inputbuffer db 10,10,10 dup(?),'$'
extra ends


stack segment
  db 2000 dup (0)

  stack ends


code segment
	assume cs:code, ds:data



set_mode proc far
	pusha
	mov ax,0600h
	mov bh,07
	mov cx,0
	mov dx,184fh
        int 10h
	mov ah, 0
	mov al,12h
	int 10h

	mov dx,3ceh
	mov al,5
	out dx,al
	mov dx,3cfh
	mov al,mode
	out dx,al
	mov dx,3ceh
	mov al,8
	out dx,al
	mov dx,3cfh
	mov al,0ffh
	out dx,al
	mov dx,py
	mov ax,80
	mul dx
	add ax,px
	mov si,ax
	mov ax,0a000h
	mov es,ax
	mov al,white
        mov cx,256
loop1:  mov dx,32
loop2:	mov es:[si],al
	inc si
	dec dx
	cmp dx,0
	jnz loop2
	add si,48
	loop loop1
        popa
	ret
set_mode endp


init_mouse proc far
	pusha
	mov ax, 00h
	int 33h
	MOV AX,01H
	INT 33H
repeat:
	mov ah,0bh
	int 21h
	cmp al,0
	jnz  next2
	mov ax,03h
	int 33h
	mov al,bl
	and al,left
	cmp al,left
	jz leftdown
	mov al,bl
	and al,right
	cmp al,right
	jnz repeat
	jmp rightdown
leftdown:
	mov al,white
	mov color,al
	mov clickx,cx
	mov clicky,dx
	call small_square
	call waitf
	mov ax,03h
	int 33h
	and bl, left
	cmp bl,left
	jz leftdown 
	jmp repeat
rightdown:
	mov al,black
	mov color ,al
	mov clickx,cx
	mov clicky,dx
	call small_square
	call waitf
	mov ax,03h
	int 33h
	and bl,right
	cmp bl,right
        jz rightdown
	jmp repeat
next2:  
	call scan
        popa
	ret
init_mouse endp


small_square proc near
	pusha
	mov ax,0a000h
        mov es,ax
	mov dx,px
	mov ax,8
	mul dx       
	mov cx,clicky
	mov ax,clickx
	mov bx,8
	div bx
	mov bl,al
	mov bh,0
	mov ax,80
	mul cx
	add ax,bx
	mov si,ax
	mov cx,8
        mov al,color
	cmp al,white
	jz next1
	mov al,white
	jmp loop3
next1:
	mov al,black

loop3:
	mov es:[si],al
	add si,80
	loop loop3		
	popa
	ret
small_square endp


scan proc near
	pusha
	mov ax,0a000h
	mov es,ax
	mov dx,3ceh
	mov al,5
	out dx,al
	mov dx,3cfh
	mov al,00001000b
	out dx,al
	mov dx,3ceh
	mov al,2
	out dx,al
	mov dx,3cfh
	mov al,white
	out dx,al
	mov dx,3ceh
	mov al,7
	out dx,al
	mov al,00001111b
	mov dx,3cfh
	out dx,al
	mov ax,py
	mov bx,80
	add ax,4
	mul bx
	add ax,px
        mov si,ax
        mov di,0
        mov cx,32
loop5:
	mov dx,4
        mov bl,0h
loop4:
	mov al,es:[si]
	cmp al,0
	jz next3
	 add bl,000000001b
next3:
	inc si
	mov al,es:[si]
	cmp al,0
	jz next4
        add bl,00000010b


next4:
	inc si
	mov al,es:[si]
	cmp al,0
	jz next5
        add bl,00000100b
next5:
	inc si
	mov al,es:[si]
	cmp al,0
	jz next6
        add bl,00001000b

next6:
	inc si
	mov al,es:[si]
	cmp al,0
	jz next7
        add bl,00010000b

next7:
	inc si
	mov al,es:[si]
	cmp al,0
	jz next8
        add bl,00100000b

next8:
	inc si
	mov al,es:[si]
	cmp al,0
	jz next9
        add bl,01000000b

next9:
	inc si
	mov al,es:[si]
	cmp al,0
	jz next10
        add bl,10000000b ;black --0,white --1

next10:
	mov mes[di],bl
	mov bl,0
	inc si
        inc di
	dec dx
	cmp dx , 0
	jz next11
	jmp loop4
next11:
       add si,608
       loop loop5
next12:
	mov ax,0600h
	mov bh,07h
	mov cx,0
	mov dx,184fh
	int 10h
	mov ah,0
	mov al,12h
	int 10h
        popa
	ret
scan endp



waitf proc near
	pusha
	mov cx,10
   waitf1:
	in al,61h
	and ah,10h
	cmp al,ah
	je waitf1
	mov ah,al
	loop waitf1
	popa
	ret
waitf endp

errm proc near
	pusha
	lea dx,errormsg
	mov ah,09h
	int 21h
        mov ah,4ch
	int 21h
        popa
	ret
errm endp


openh proc near
	pusha
	lea dx,pathnam
	mov ah,3dh
	mov al,02h
	int 21h

	jnc succ

	call errm
succ:
	
	mov handle,ax
	mov bx,handle
	  mov cx,0
	  mov dx,0
	  mov al,1
	  mov ah, 42h
	  int 21h
	  mov lower_order, ax
	  mov higher_order, dx
        popa
        ret
openh endp


writeh proc near
	pusha
noncode:
	lea dx,inputmsg
	mov ah,09h
	int 21h
	mov ah,0ch
        mov al,0ah
	lea dx,buff_in_data
	int 21h
	mov si,dx
        inc si
	mov bl,[si]
	cmp bl,0
	je noncode
	mov di,1
	lea si,buff_in_data+1
	cld
	mov ax,extra
        mov es,ax
	mov cl,bl
	mov ch,0
        inc cx
	rep movsb
	call judgeh
	cmp judgeresult,1
	jz doublename
	mov cl,bl
	mov ch,0
	inc cx
	lea dx,buff_in_data+1
	mov bx,handle
	mov ah,40h
	int 21h
        jc error
	lea dx,mes
	mov ah,40h
	mov cx,128
	int 21h
	jc error
	jmp writeh_exit
error:  
	lea dx,errormsg
	mov ah,09h
	int 21h
	mov ah,4ch
	int 21h
doublename:
	lea dx,doublemsg
	mov ah,09h
	int 21h
        jmp noncode
writeh_exit:
	  mov bx,handle
	  mov cx,0
	  mov dx,0
	  mov al,1
	  mov ah, 42h
	  int 21h
	  mov lower_order, ax
	  mov higher_order, dx
          popa
	  ret
 writeh endp



set_writecursor proc near
	pusha
	mov ah,42h
	mov al,00
	mov bx,handle
	mov cx,higher_order
	mov dx,lower_order
	int 21h
	popa
	ret

set_writecursor endp


judgeh proc near
	pusha
        mov ah,42h
        mov al,00
        mov cx,00
        mov dx,00
	mov bx,handle
	int 21h
reread1:
         mov bx,handle                        
	  lea dx,buff
	  mov cx,1
	  mov ah,3fh
	  int 21h
	  jc errorread1
	  cmp ax,0
	  je endread1
	  mov cl,buff
	  mov counth,cl
          mov di,1
          cmp cl,es:[di]
	  jnz nextcode11
	 mov bx,handle
          lea dx,buff
          mov ch,0
	  mov di,cx
	  mov ah,3fh
	  int 21h
	  mov cx,di  
	  mov di,2
	  lea si,buff
	  cld
	  repz cmpsb  
	  cmp cx,0
	  jnz nextcode21
	  mov judgeresult ,1
	  jmp exitread1
nextcode11:
	add counth,128
	 mov dl,counth
	 mov dh,0
	 mov cx,0
	 mov bx,handle
	 mov al,1
	 mov ah,42h
	 int 21h
	 jnc next221
	 
	 call errm
nextcode21:
	mov dx,128
	mov cx,0
	mov bx,handle
	mov al,1
	mov ah,42h
        int 21h

next221:
	jmp reread1

errorread1:
	
	call errm

endread1:
	mov judgeresult,0
	
exitread1:
	popa
	ret
judgeh endp


readh proc near
	pusha
	
	
noncode1:
	
	lea dx,inputmsg
	mov ah,09h
	int 21h
	mov ah,0ch
        mov al,0ah
	lea dx,buff_in_data
	int 21h
        lea si,buff_in_data+1

 	mov bl,[si]

	cmp bl,0
	jz noncode1
	mov di,1
	lea si,buff_in_data+1
	cld
	mov ax,extra
	mov es,ax
	mov cl,bl
	mov ch,0
        inc cx
	rep movsb
  	mov ah,42h
        mov al,00
        mov cx,00
        mov dx,00
	mov bx,handle
	int 21h


reread:	  mov bx,handle
	  mov cx,1
	  mov ah,3fh
	  lea dx,buff
	  int 21h 
	  cmp ax,0
	  jnz next300
          jmp endread
next300:
	  mov cl,buff
	  mov ch,0
          mov newcount,cx
	  mov di,1
	  cmp cl,es:[di]
	jnz nextcode
          lea dx,buff
	 mov bx,handle
	  mov ah,3fh
	  int 21h
	  mov cx,newcount
	  inc cx
	  mov di,2
	  lea si,buff
	  cld
	  repz cmpsb
	  cmp cx,0
	  jnz nextcode1
	  mov bx,handle
	  mov cx,128
	  lea dx,mes
	  mov ah,3fh
	  int 21h
	  cmp ax,128
	  jnz errorread
          mov readhresult,1
	  jmp exitread
nextcode:
	add cl,128
	 mov dl,cl
	 mov dh,0
	 mov cx,0
	 mov bx,handle
	 mov al,1
	 mov ah,42h
	 int 21h
	jnc next22
	 call errm
	
nextcode1:
	mov dx,128
	mov cx,0
	mov bx,handle
	mov al,1
	mov ah,42h
	int 21h
	jnc next22
         call errm

next22:
	jmp reread

errorread:
	
	call errm
endread:
	mov readhresult,0
	
exitread:
	popa
	 ret

readh endp


code_to_print proc near
	pusha
	call readh
	cmp readhresult ,1

        jnz code_to_print_exit
	call print_mode
        jmp next23
code_to_print_exit:
	mov ah,09h
	lea dx,non_code_msg
	int 21h
next23:
	popa
	ret
code_to_print endp


print_mode proc near
	pusha
	mov ax,0600h
	mov bh,07
	mov cx,0
	mov dx,184fh
	int 10h
	mov ah,00h
	mov al,12h
	int 10h
	lea dx,print_code_msg
	mov ah,09h
	int 21h
	mov dx,3ceh
	mov al,5
	out dx,al
	inc dx
	mov al,mode
	out dx,al
	mov al,8
	mov dx,3ceh
	out dx,al
	mov dx,3cfh
	mov al,0ffh
        out dx,al
	mov ax,0a000h
	mov es,ax
	mov ax,printx
	mov clickx,ax
	mov ax,printy
        mov clicky,ax
        mov si,0
	mov cx,32
        
loop11:
	mov di,4        
loop10:
	mov dl, mes[si]
	and dl,00000001b
	cmp dl,0
	jz next3010
	mov dl,black
	mov color,dl
        jmp next302
next3010:
	mov dl,white
	mov color,dl
next302:
	call small_square
	add clickx,8
	mov dl, mes[si]
	and dl,00000010b
	cmp dl,0
	jz next3020
	mov dl,black
	mov color,dl
        jmp next303
next3020:
	mov dl,white
	mov color,dl
next303:
	call small_square
	add clickx,8
	mov dl, mes[si]
	and dl,00000100b
	cmp dl,0
	jz next3030
	mov dl,black
	mov color,dl
        jmp next304
next3030:
	mov dl,white
	mov color,dl
next304:
	call small_square
	add clickx,8
	mov dl, mes[si]
	and dl,00001000b
	cmp dl,0
	jz next3040
	mov dl,black
	mov color,dl
        jmp next305
next3040:
	mov dl,white
	mov color,dl
next305:
	call small_square
	add clickx,8

	mov dl, mes[si]
	and dl,00010000b
	cmp dl,0
	jz next3050
	mov dl,black
	mov color,dl
        jmp next306
next3050:
	mov dl,white
	mov color,dl
next306:
	call small_square
	add clickx,8


	mov dl, mes[si]
	and dl,00100000b
	cmp dl,0
	jz next3060
	mov dl,black
	mov color,dl
        jmp next307
next3060:
	mov dl,white
	mov color,dl
next307:
	call small_square
	add clickx,8

	mov dl, mes[si]
	and dl,01000000b
	cmp dl,0
	jz next3070
	mov dl,black
	mov color,dl
        jmp next308
next3070:
	mov dl,white
	mov color,dl
next308:
	call small_square
	add clickx,8


	mov dl, mes[si]
	and dl,10000000b
	cmp dl,0
	jz next3080
	mov dl,black
	mov color,dl
        jmp next309
next3080:
	mov dl,white
	mov color,dl
next309:
	call small_square
	add clickx,8
	inc si

	dec di
	cmp di,0
        jz exit_print
	 jmp loop10
exit_print:
	mov ax,printx
	mov clickx,ax
        add clicky,8
	dec cx
	cmp cx,0
	jz next330
        jmp loop11
next330:
	popa
        ret
print_mode endp

testcode proc near
	pusha
 	lea dx,testmsg
	mov ah,09h
	int 21h
	POPA
	ret
testcode endp


closeh proc near
	pusha
	mov bx,handle
	mov ah , 3eh
	int 21h
	popa
	ret
closeh endp

start:
	mov ax,data
	mov ds,ax
	mov ax,stack
	mov ss,ax
	mov ax,extra
	mov es,ax
select:
	lea dx,headmsg
	mov ah,09h
	int 21h
	mov ah,01h
	int 21h
	cmp al,'e'
	jz next33
	cmp al,'w'
	jz next44
	cmp al,'q'
	jz over_exit
	jmp select
 next33:
 	call set_mode
	call init_mouse
	call openh
	call writeh
        call closeh
	jmp over_exit
next44:
	call openh
	call code_to_print
	call closeh

over_exit:
	mov ah,4ch
	int 21h	
	code ends
	end start

⌨️ 快捷键说明

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