• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >汇编语言 > 汇编源码系列之alarm

汇编源码系列之alarm

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2017-06-28

匿名通过本文主要向大家介绍了冰箱alarm亮灯,alarm,alarm是什么意思,alarm clock,alarm怎么读等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
</div>

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......

cseg  segment para public 'code'
org  100h
alarm  proc far
; Memory-resident program to intercept the timer interrupt and display the
; system time in the upper right-hand corner of the display.
; This program is run as 'ALARM hh:mm x', where hh:mm is the alarm time and
; x is '-' to turn the display off. Any other value of x or no value will
; turn the clock on
intaddr equ 1ch*4    ; interrupt address
segaddr equ 62h*4    ; segment address of first copy
mfactor equ 17478    ; minute conversion factor * 16
whozat  equ 1234h    ; signature
color  equ 14h     ; color attribute
  assume cs:cseg,ds:cseg,ss:nothing,es:nothing
  jmp p150    ; start-up code
jumpval dd 0      ; address of prior interrupt
signature dw whozat    ; program signature
state  db 0      ; '-' = off, all else = on
wait  dw 18      ; wait time - 1 second or 18 ticks
hour  dw 0      ; hour of the day
atime  dw 0ffffh    ; minutes past midnite for alarm
acount  dw 0      ; alarm beep counter - number of seconds (5)
atone  db 5      ; alarm tone - may be from 1 to 255 - the
        ; higher the number, the lower the frequency
aleng  dw 8080h    ; alarm length (loop count) may be from 1-FFFF
dhours  dw 0      ; display hours
  db ':'
dmins  dw 0      ; display minutes
  db ':'
dsecs  dw 0      ; display seconds
  db '-'
ampm  db 0      ; 'A' or 'P' for am or pm
  db 'm'
tstack  db 16 dup('stack  ')  ; temporary stack
estack  db 0      ; end of stack
holdsp  dw 0      ; original sp
holdss  dw 0      ; original ss
p000:        ; interrupt code
  push ax     ; save registers
  push ds
  pushf
  push cs
  pop ds      ; make ds=cs
  mov ax,wait    ; check wait time
  dec ax      ; zero?
  jz p010     ; yes - 1 second has elapsed
  mov wait,ax    ; not this time
  jmp p080    ; return
p010:  cli      ; disable interrupts
  mov ax,ss    ; save stack
  mov holdss,ax
  mov holdsp,sp
  mov ax,ds
  mov ss,ax    ; point to internal stack
  mov sp,offset estack
  sti      ; allow interrupts
  push bx     ; save other registers
  push cx
  push dx
  push es
  push si
  push di
  push bp
  mov ax,18    ; reset wait time
  mov wait,ax
  mov al,state    ; are we disabled?
  cmp al,'-'
  jnz p015    ; no
  jmp p070
p015:  mov ah,0    ; read time
  int 1ah     ; get time of day
  mov ax,dx    ; low part
  mov dx,cx    ; high part
  mov cl,4
  shl dx,cl    ; multiply by 16
  mov bx,ax
  mov cl,12
  shr bx,cl    ; isolate top 4 bits of ax
  add dx,bx    ; now in upper
  mov cl,4
  shl ax,cl    ; multiply by 16
  mov bx,mfactor    ; compute minutes
  div bx      ; minutes in ax, remainder in dx
  cmp ax,atime    ; time to sound the alarm?
  jnz p020    ; no
  call p100    ; yes - beep the speaker twice
  push ax
  mov ax,acount    ; get beep count
  dec ax      ; down by 1
  mov acount,ax    ; save beep count
  cmp ax,0    ; is it zero?
  jnz p018    ; no - keep alarm on
  mov ax,0ffffh    ; turn off alarm
  mov atime,ax
p018:  pop ax
p020:  mov dsecs,dx    ; save remainder
  mov bx,60    ; compute hours
  xor dx,dx    ; zero it
  div bx      ; hours in ax, minutes in dx
  mov dmins,dx    ; save minutes
  cmp ax,0    ; midnight?
  jnz p030    ; no
  mov ax,12    ; yes
  jmp p040a    ; set am
p030:  cmp ax,12    ; before noon?
  jb p040a    ; yes - set am
  jz p040p    ; noon - set pm
  sub ax,12    ; convert the rest
p040p:  mov bl,'p'
  jmp p040x
p040a:  mov bl,'a'
p040x:  mov ampm,bl
  aam      ; fix up hour
  cmp ax,hour    ; top of the hour?
  jz p060     ; no
  mov hour,ax
  call p120    ; beep the speaker once
p060:  add ax,3030h    ; convert hours to ascii
  xchg ah,al
  mov dhours,ax
  mov ax,dmins    ; get minutes
  aam
  add ax,3030h    ; convert to ascii
  xchg ah,al
  mov dmins,ax
  mov ax,dsecs    ; get seconds (remainder)
  xor dx,dx
  mov bx,60
  mul bx
  mov bx,mfactor
  div bx      ; seconds in ax
  aam
  add ax,3030h
  xchg ah,al
  mov dsecs,ax
  xor ax,ax    ; check monitor type
  mov es,ax
  mov ax,es:[410h]  ; get config byte
  and al,30h    ; isolate monitor type
  cmp al,30h    ; color?
  mov ax,0b000h    ; assume mono
  jz p061     ; its mono
  mov ax,0b800h    ; color screen address
p061:  mov dx,es:[463h]  ; point to 6845 base port
  add dx,6    ; point to status port
  mov es,ax    ; point to monitor
  mov bh,color    ; color in bh
  mov si,offset dhours  ; point to time
  mov di,138    ; row 1, col 69
  cld
  mov cx,11    ; loop count
p062:  mov bl,[si]    ; get next character
p063:  in al,dx    ; get crt status
  test al,1    ; is it low?
  jnz p063    ; no - wait
  cli      ; no interrupts
p064:  in al,dx    ; get crt status
  test al,1    ; is it high?
  jz p064     ; no - wait
  mov ax,bx    ; move color & character
  stosw      ; move color & character again
  sti      ; interrupts back on
  inc si      ; point to next character
  loop p062    ; done?
p070:  pop bp      ; restore registers
  pop di
  pop si
  pop es
  pop dx
  pop cx
  pop bx
  cli      ; no interrupts
  mov ax,holdss
  mov ss,ax
  mov sp,holdsp
  sti      ; allow interrupts
p080:  popf
  pop ds
  pop ax
  jmp cs:[jumpval]
p100  proc near    ; beep the speaker twice
  call p120
  push cx
  mov cx,20000
p105:  loop p105    ; wait around
  pop cx
  call p120
  push cx
  mov cx,20000
p106:  loop p106    ; wait around
  pop cx
  call p120
  ret
p100  endp
p120  proc near    ; beep the speaker once
  push ax
  push cx
  mov al,182
  out 43h,al    ; setup for sound
  mov al,0
  out 42h,al    ; low part
  mov al,atone    ; get alarm tone
  out 42h,al    ; high part
  in al,61h
  push ax     ; save port value
  or al,3
  out 61h,al    ; turn speaker on
  mov cx,aleng    ; get loop count
p125:  loop p125    ; wait around
  pop ax      ; restore original port value
  out 61h,al    ; turn speaker off
  pop cx
  pop ax
  ret
p120  endp
p150:        ; start of transient code
  mov dx,offset copyr
  call p220    ; print copyright
  mov ax,0
  mov es,ax 

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • 汇编源码系列之alarm

相关文章

  • 2017-06-28汇编源代码之MAKE SOUNDS(发声)
  • 2017-06-28汇编语言程序设计(一)
  • 2017-06-28WIN98SE硬盘主引导记录代码数据注释
  • 2017-06-28汇编源码系列之char
  • 2017-06-28汇编源码系列之col
  • 2017-06-28汇编语言编写DOS下的内存驻留程序
  • 2017-06-28汇编源码系列之gameport
  • 2017-06-28Windows下反汇编程序例子
  • 2017-06-28汇编教程:控制转移
  • 2017-06-17伪操作

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 汇编语言学习指南(四)
    • 汇编IDE的选择与配置
    • 一个win32汇编语言程序示例
    • 汇编语言的艺术-基本认识(三)
    • 汇编源代码之一个旋转的3D箱子(动画)
    • 汇编语言中“[]”的用法
    • 汇编实模式与保护模式切换实例
    • 如何分析未文档化的数据结构
    • Casl汇编语言辅导
    • 汇编教程之通用控件

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有