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

📄 temp9.asm

📁 这是一个在两台pc机之间通过串口传输文件的汇编程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
          .model small
         .stack 64
;------------------------------------------------------
          .data
filer label byte
maxlenr db 30
namelenr db ?
filenamer db 30 dup(' ')

filew label byte
maxlenw db 30
namelenw db ?
filenamew db 30 dup(' ')
;------------------------------------------------------
pathnamer db 30 dup(?)

pathnamew db 30 dup(?)
;------------------------------------------------------
row db 0
signal db 2
;------------------------------------------------------
come db '                                 WELCOME'
show db 'pass or receive a file? hit "p" to pass, hit "r" to receive and hit "e" to exit'
welcomer db 'Input the name of file for pass: '
welcomew db 'Create the name of file for receive: '
outputr db 'File passed successfully'
outputw db 'File received successfully'
fixme db 'Invalid input'
err db 'Fail'
err1 db 'Can not open readfile'
err2 db 'Can not open writefile'
succ1 db 'Open readfile'
succ2 db 'Open writefile'
ts db 'Starting at'
tf db 'Finishing at'
ti db 'Transfering time is'
;------------------------------------------------------
handler dw ?
handlew dw ?
area db 103 dup(?)
areat db 103 dup(?)
filelen dw ?
nowfile dw 0
count db 0
;------------------------------------------------------
times db ?,?,':',?,?,':',?,?
timef db ?,?,':',?,?,':',?,?
inter db ?,?,':',?,?,':',?,?
time1 db ?,?,'/','1','0','0'
time2 db '1','0','0','/','1','0','0'
s1 db ?
s2 db ?
m1 db ?
m2 db ?
h1 db ?
h2 db ?

carry1 db 0
carry2 db 0
;------------------------------------------------------
          .code
main proc far
          mov ax,@data
          mov ds,ax
          mov es,ax
          mov ax,0600h
          call screen
          call cursor
          
          mov dx,3fbh
          mov al,10000000b
          out dx,al
         
          mov dx,3f8h
          mov al,0ch
          out dx,al
          inc dx
          mov al,00h
          out dx,al
         
          mov dx,3fbh
          mov al,00001011b
          out dx,al
         
          inc dx
          mov al,00000011b
          out dx,al
         
          mov dx,3f9h
          mov al,0
          out dx,al


          mov ah,40h
          mov bx,01
          mov cx,40
          lea dx,come
          int 21h
          call scroll;;;;;;;;;;;;;;;;;

continue: mov signal,2
          call select
          cmp signal,3
          je endme
          cmp signal,2
          je fix
          call filein
          ;;cmp signal,0
          ;;jne cw
          ;;cmp namelenr,0
          ;;jne continue
          ;;jmp endme
;;cw:       cmp namelenw,0
          ;;jne continue
          ;;jmp endme
          jmp continue
fix:      ;inc row
          ;call cursor
          ;call scroll;;;;;;;;;;;;;;;
          mov ah,40h
          mov bx,01
          mov cx,13
          lea dx,fixme
          int 21h
          call scroll;;;;;;;;;;;;;;;;
          ;inc row
          ;call cursor
          jmp continue
endme:    mov ax,4c00h
          int 21h
main endp
;------------------------------------------------------
select proc near
          ;call scroll
          mov ah,40h
          mov bx,01
          mov cx,79
          lea dx,show
          int 21h
          call scroll;;;;;;;;;;
          ;inc row
          ;call cursor
readagain:mov ah,1
          int 16h
          jz readagain
          mov ah,0
          int 16h
          
          ;call scroll;;;;;;;
          mov bx,0
          mov ah,0eh
          int 10h

          cmp al,'p'
          je passf
          cmp al,'r'
          je passr
          cmp al,'e'
          jne go
          mov signal,3
          call scroll
          ret
passr:    mov signal,1
          call scroll;;;;;;;;;;;;;;
          ret
passf:    mov signal,0
go:       call scroll
          ret
select endp
;------------------------------------------------------
screen proc near
          mov bh,1eh
          mov cx,0
          mov dx,184fh
          int 10h
          ret
screen endp
;------------------------------------------------------
cursor proc near
          mov ah,02
          mov bh,0
          mov dh,row
          mov dl,0
          int 10h
          ret
cursor endp
;------------------------------------------------------
scroll proc near
          cmp row,18h
          jae do
          inc row
          call cursor
          ret
do:       mov ax,0601h
          call screen
          call cursor
          ret
scroll endp
;------------------------------------------------------
filein proc near
          ;inc row
          ;call cursor
          cmp signal,0
          jne showw
          
          mov ah,40h
          mov bx,01
          mov cx,33
          lea dx,welcomer
          int 21h
          
          call scroll
          mov ah,0ah
          lea dx,filer
          int 21h
          call scroll
          
notyet:   mov dx,3fdh
          in al,dx
          test al,00000001b
          jz notyet
          mov dx,3f8h
          in al,dx
          cmp al,1
          jne notyet

          cmp namelenr,0
          jne real
          ret
showw:    mov ah,40h
          mov bx,01
          mov cx,37
          lea dx,welcomew
          int 21h
          
          call scroll
          mov ah,0ah
          lea dx,filew
          int 21h
          call scroll
          
          mov al,1
          mov dx,3f8h
          out dx,al

          cmp namelenw,0
          jne real
          ret

real:     call transfer
          ;call scroll
          ret
filein endp
;------------------------------------------------------
transfer proc near
          cmp signal,0
          jne cw
          call changer
          jmp runr
cw:       call changew
          call tempw
          ret
runr:     call tempr
          ret
transfer endp
;------------------------------------------------------
changer proc near
          mov al,namelenr
          mov ah,0
          mov di,ax
          dec di
          push di
loopmer:  mov ah,filenamer[di]
          mov pathnamer[di],ah
          dec di
          cmp di,0
          jne loopmer
          mov ah,filenamer[0]
          mov pathnamer[0],ah
          pop di
          inc di
          mov pathnamer[di],0
          ;inc row
          ;call cursor
          ;mov ah,40h;;;;
          ;mov bx,01;;;;;;;
          ;mov cx,21;;;;;
          ;lea dx,pathnamer;;;;;;;
          ;int 21h;;;;;;;
          ;inc row
          ;call cursor
          ;mov ah,40h;;;;
          ;mov bx,01;;;;;;;
          ;mov cx,21;;;;;
          ;lea dx,output;;;;;;;
          ;int 21h;;;;;;;

          ret
changer endp
;------------------------------------------------------
changew proc near
          mov al,namelenw
          mov ah,0
          mov di,ax
          dec di
          push di
loopmew:  mov ah,filenamew[di]
          mov pathnamew[di],ah
          dec di
          cmp di,0
          jne loopmew
          mov ah,filenamew[0]
          mov pathnamew[0],ah
          pop di
          inc di
          mov pathnamew[di],0
          ;inc row
          ;call cursor
          ;mov ah,40h;;;;
          ;mov bx,01;;;;;;;
          ;mov cx,21;;;;;
          ;lea dx,pathnamer;;;;;;;
          ;int 21h;;;;;;;
          ;inc row
          ;call cursor
          ;mov ah,40h;;;;
          ;mov bx,01;;;;;;;
          ;mov cx,21;;;;;
          ;lea dx,output;;;;;;;
          ;int 21h;;;;;;;

          ret
changew endp
;------------------------------------------------------
tempr proc near
         mov ah,3dh
         mov al,0
         lea dx,pathnamer
         int 21h
         jc er
         mov handler,ax
         jmp nr
         
er:      ;inc row
         ;call cursor
         mov ah,40h
         mov bx,01
         mov cx,21
         lea dx,err1
         int 21h
         call scroll
         jmp finalr

nr:      ;inc row
         ;call cursor
         mov ah,40h
         mov bx,01
         mov cx,13
         lea dx,succ1
         int 21h
         call scroll
  
         call showtimes
         call tolen
tranr:   mov ah,3fh

         mov bx,handler
         mov cx,100
         lea dx,area+3
         int 21h
         cmp ax,0
         jz returnr
         mov word ptr area,ax
         
         add nowfile,ax
         mov ax,100
         mul nowfile
         div filelen
         mov count,al
         
         mov ah,count
         mov area+2,ah
         
         call sysr

         call inoutr
         jmp tranr
         
returnr: mov word ptr area,ax

⌨️ 快捷键说明

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