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

📄 模拟时钟3.asm

📁 一个模拟时钟的汇编语言程序
💻 ASM
字号:
data segment
col     dw    320
row     dw    240
x       dw    320,  330,  340,   350,  360
        dw    370,  378,  386,   394,  400
        dw    406,  411,  415,   417,  419    
        dw    420,  419,  417,   415,  411  
        dw    406,  400,  394,   386,  378
        dw    370,  360,  350,   340,  330 
        dw    320,  309,  299,   289,  279
        dw    270,  261,  253,   245,  239
        dw    233,  228,  224,   222,  220
        dw    220,  220,  222,   224,  228
        dw    233,  239,  245,   253,  261 
        dw    269,  279,  289,   299,  309

   
        
     
y       dw  140,   140,   142,   144,   148
        dw  153,   159,   165,   173,   181
        dw  189,   199,   209,   219,   229
        dw  240,   250,   260,   270,   280
        dw  290,   298,   306,   314,   320
        dw  326,   331,   335,   337,   339 
        dw  340,   339,   337,   335,   331
        dw  326,   320,   314,   306,   298 
        dw  290,   280,   270,   260,   250 
        dw  240,   229,   219,   209,   199 
        dw  190,   181,   173,   165,   159 
        dw  153,   148,   144,   142,   140


   

mx  dw      320,   329,   338,   347,   356
    dw      365,   372,   380,   386,   392
    dw      397,   402,   405,   408,   409   
    dw      410,   409,   408,   405,   402
    dw      397,   392,   386,   380,   372
    dw      365,   356,   347,   338,   329
    dw      320,   310,   301,   292,   283
    dw      275,   267,   259,   253,   247
    dw      242,   237,   234,   231,   230
    dw      230,   230,   231,   234,   237
    dw      242,   247,   253,   259,   267
    dw      274,   283,   292,   301,   310

 
  
my  dw    150,   150,   151,   154,   157
    dw    162,   167,   173,   179,   187
    dw    194,   203,   212,   221,   230
    dw    240,   249,   258,   267,   276
    dw    285,   292,   300,   306,   312
    dw    317,   322,   325,   328,   329
    dw    330,   329,   328,   325,   322
    dw    317,   312,   306,   300,   292
    dw    285,   276,   267,   258,   249
    dw    240,   230,   221,   212,   203
    dw    195,   187,   179,   173,   167
    dw    162,   157,   154,   151,   150

 

hx  dw    320,    350,   371,    380,   371
    dw    350,    320,   290,    268,   260
    dw    268,    290   
hy  dw    180,    188,   209,    240,   270
    dw    291,    300,   291,    270,   240
    dw    210,    188   

r       dw     ?
lcolor  db     ?
parac  dw     4 dup(0)
data ends
;--------------------------------------------------------------------
code segment
main    proc    far  
          assume cs:code,ds:data,es:data
start:    mov ax,data
          mov ds,ax
          mov es,ax
          
mv:       mov ah,0
          mov al,12h
          int 10h

          
          mov si,offset x
          mov di,offset y
          mov bl,60
init:     mov ax,0c05h
          mov bh,0
          mov dx,[di]
          mov cx,[si]
          int 10h
          inc si
          inc si
          inc di
          inc di
          dec bl
          jne init
          
          mov si,offset x
          mov di,offset y
          mov bl,12
init1:    mov ax,0c03h
          mov bh,0
          mov dx,[di]
          mov cx,[si]
          int 10h
          add si,10
          add di,10
          dec bl
          jne init1
          
          
          mov col,320
          mov row,240

          mov ah,2ch
          int 21h   
          mov si,offset x
          mov di,offset y
          add dh,dh
          mov al,dh
          mov ah,00h
          add si,ax
          add di,ax
          mov lcolor,0fh
          call near ptr draw_line
          
          mov ah,2ch
          int 21h  
          mov si,offset mx
          mov di,offset my
          add cl,cl
          mov al,cl
          mov ah,00h
          add si,ax
          add di,ax
          mov lcolor,0ah
          call near ptr draw_line
          
          mov ah,2ch
          int 21h   
          mov si,offset hx
          mov di,offset hy
          mov al,ch
          mov ah,00h
          mov bl,12
          div bl
          add ah,ah
          mov al,ah
          mov ah,00h
          add si,ax
          add di,ax
          mov lcolor,09h
          call near ptr draw_line
          
          
          mov ah,2ch
          int 21h
          cmp cl,59
          jne con
          cmp dh,55
          jl  con
          call near ptr beep
          call near ptr delay1
          jmp last 
         
con:      mov ah,2ch
          int 21h
          cmp cl,0
          jne con1
          cmp dh,0
          jne con1
          call near ptr beep
          call near ptr delay1
          jmp last
          
con1:     
          call near ptr gensound
          call near ptr delay
last:     mov ah,0bh
          int 21h
          cmp al,0
          jne exit
          jmp mv 
          mov ah,4ch
          int 21h
exit:     mov ah,4ch
          int 21h
main endp
;-------------------------------------------------------------         
clear     proc   near
          push   ax
          push   bx
          push   cx
          push   dx
          mov    ah,6
          mov    al,0
          mov    bh,7
          mov    ch,0
          mov    cl,0
          mov    dh,24
          mov    dl,79
          int    10h
          mov    dx,0
          mov    ah,2
          int    10h
          pop    dx
          pop    cx
          pop    bx
          pop    ax
          ret
clear     endp
;----------------------------------------------------------
delay      proc      near
           push ax
           push bx
           push cx
           push dx
           mov bx,8000
wt:      mov cx,55afh
rt:    loop  rt
           dec bx
           jnz wt
           pop dx
           pop cx
           pop bx
           pop ax
           ret
delay     endp
;-------------------------------------------------------------------
delay1      proc      near
           push ax
           push bx
           push cx
           push dx
           mov bx,6700
wt1:      mov cx,55afh
rt1:    loop  rt1
           dec bx
           jnz wt1
           pop dx
           pop cx
           pop bx
           pop ax
           ret
delay1    endp

;-----------------------------------------------------------------
draw_line   proc    near
             push ax
             push bx
             push cx
             push dx
             mov ax,col
             sub ax,[si]
             jb  rl
             mov parac,ax
             mov parac+2,-1
             jmp rc
rl:          neg ax
             mov parac,ax
             mov parac+2,1
rc:          mov ax,row
             sub ax,[di]
             jb  cll
             mov parac+4,ax
             mov parac+6,-1
             jmp out1
cll:         neg ax
             mov parac+4,ax
             mov parac+6,1
out1:        mov bx,parac
             sub ax,bx
             jb  clgrl
             mov cx,0
rlgcl:       mov ax,parac
             mul cx
             mov bx,parac+4
             div bx
             cmp parac+2,1
             je xsl
             neg ax
xsl:         add ax,col
             mov dx,ax
             push cx
             cmp parac+6,1
             je plush
             neg cx
plush:       add cx,row
             mov ah,0
             xchg cx,dx
             mov ah,0ch
             mov al,lcolor
             int 10h
             pop cx
             inc cx
             cmp cx,parac+4
             jbe rlgcl
             jmp endline
clgrl:       mov cx,0
clgrl1:      mov ax,parac+4
             mul cx
             mov bx,parac
             div bx
             cmp parac+6,1
             je xsh
             neg ax
xsh:        add ax,row
             mov dx,ax
             push cx 
             cmp parac+2,1
             je plusl
             neg cx
plusl:       add cx,col
             mov bh,0
             mov ah,0ch
             mov al,lcolor
             int 10h
             pop cx
             inc cx
             cmp cx,parac
             jbe clgrl1
endline:     pop dx
             pop cx
             pop bx
             pop ax
             ret
draw_line    endp 

;---------------------------------------------
gensound        proc    near
        push    ax
        push    bx
        push    cx
        push    dx
        push    di
        mov     di,1500
        mov     al,0b6h
        out     43h,al
        mov     dx,12h
        mov     ax,3280h
        div     di
        out     42h,al
        mov     al,ah
        out     42h,al
        in      al,61h
        mov     ah,al
        or      al,3
        out     61h,al
        mov     bx,100
wait1:  mov     cx,2800
dy:  loop    dy
        dec     bx
        jne     wait1
        mov     al,ah
        out     61h,al
        pop     di
        pop     dx
        pop     cx
        pop     bx
        pop     ax
        ret
gensound        endp
;----------------------------------------------------------------------------------
beep  proc   near
        push    ax
        push    bx
        push    cx
        push    dx
        push    di
        cmp     dh,0
        je      n
        mov     di,500
        jmp     n1   
n:      mov     di,1500        
n1:     mov     al,0b6h
        out     43h,al
        mov     dx,12h
        mov     ax,3280h
        div     di
        out     42h,al
        mov     al,ah
        out     42h,al
        in      al,61h
        mov     ah,al
        or      al,3
        out     61h,al
        mov     bx,10000
w:      mov     cx,2800
d:      loop    d
        dec     bx
        jne     w
        mov     al,ah
        out     61h,al
        pop     di
        pop     dx
        pop     cx
        pop     bx
        pop     ax   
      ret
beep   endp
;---------------------------------------------------------------------------------
code ends
        end start

⌨️ 快捷键说明

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