8086,汇编,74ls274编写一个电子钟的程序

8086,汇编,74ls274编写一个电子钟的程序,第1张

extrn music:far,gensound:far 程序的3/1 不全写不下了

******************************************************

* 堆栈段

.286******************************************************

STACK_SEG SEGMENT STACK

STACK_BUF DW120 DUP(?)

TOP EQU $-STACK_BUF

STACK_SEG ENDS

******************************************************

* 数据段

******************************************************

DATA_SEG SEGMENT PARA

------------------------------------------------------

TODO: 数据的定义及存储器的分配

ts1 DB0

quitbuf DB'welcome you to run this programme. '

quitbuf2 DB'C: change color B:extend the colck S:reduce the clock'

quitbuf3 DB'press e to soundPress q to quit ! '

sigle DB80h

absx DW0

absy DW0

sut DW0

erroybz DB0

r0DW90

x0DW320

y0DW245

count0db0

count_hourDB11

count_minute DB11

yuanxinx DW0

yuanxiny DW0

s DB0

s2DB0

s3DB0

hour DW0

hour2 DW0

minuteDW0

minute2 DW0

secondDB0

second2 DB0

sin_x DW0

sin_xxDW0

x DW0

y DW0

x1DW0

xminy DW0

yminx DW0

xmax DW0

ymax DW0

ymin DW0

xmin DW0

sjx_xminy DW0

sjx_yminx DW0

sjx_xmax DW0

sjx_ymax DW0

sjx_ymin DW0

sjx_xmin DW0

yuanx DW0

yuany DW0

y1DW0

x2DW0

y2DW0

x3DW0

y3DW0

DIancolor DB0

color DB2

color_hourDB2

color_min DB6

color_second DB9

color4DB10

color5DB11

color6DB12

backgroundcolor DB 1

page1 DB0

y2y1 DW0

x2x1 DW0

sjx_y2y1 DW0

sjx_x2x1 DW0

------------------------------------------------------

DATA_SEG ENDS

******************************************************

* 代码段

******************************************************

CODE_SEG SEGMENT PARA

------------------------------------------------------

MAIN PROC FAR

ASSUMECS:CODE_SEG,DS:DATA_SEG

ASSUMESS:STACK_SEG

START:

MOV AX,STACK_SEG

MOV SS,AX

MOV SP,TOP

MOV AX,DATA_SEG

MOV DS,AX

------------------------------------------------------

TODO: 从这里开始您的代码

------------------------------------------------------

beg: MOV AX,0012h

INT 10h

MOV DX,0010h

CALL b1002

LEA BP,quitbuf

CALL msg

MOV DX,010ah

LEA BP,quitbuf2

CALL msg

MOV DX,020ah

LEA BP,quitbuf3

CALL msg

beg2:CALL skin

CALL skin2

CALL skin3

CALL CLk

MOV second,DH

MOV second2,DH

MOV count_minute,11

CALL minute_lin

XOR DX,DX

MOV AX,minute2

MOV CX,12

DIV CX

MOV CX,AX minurte2/12

POP AX

ADD AX,CX

MOV hour2,AX

MOV count_hour,11

CALL hour_lin

CALL CLk

MOV DL,DH

CALL bcd2

XOR AH,AH

MOV CL,12

DIV CL

MOV count_minute,AHsecond%12初始值

DEC count_minute

XOR DX,DX

MOV AX,minute2

MOV CX,12

DIV CXminurte2%12

MOVcount_hour,DL

DEC count_hour

INC second2

kk3: CLI

CALL second_lin

STI

JMP ks

ks: MOV AH,1

INT 16h

JZkk3

MOV AH,8

INT 21h

CMP AL,'q'

JEquit

CMP AL,'b'

JECHange_rb

CMP AL,'s'

JECHange_rs

CMP AL,'c'

JECHange_color

cmp al,'e'

jea0

JMP kk3

CHange_rs:CMP r0,190

JAks

ADD r0,5

JMP tobeg2

CHange_rb:CMP r0,60

JBks

SUB r0,5

JMP tobeg2

CHange_color: LEA SI,color_hour

MOV CX,6

CHange_kk1: MOV AL, [SI]

INC AL

CMP AL,15

JC CHange_color_kk2

MOV AL,1

CHange_color_kk2:

MOV [SI],AL

INC SI

LOOP CHange_kk1

JMP tobeg2

a0: call music

call music

call music

tobeg2: CALL CLear

JMP beg2

quit: MOV AX,4C00H

INT 21H

*************************************

hour_lin PROC NEAR

PUSHa

CMP count_hour,11

JBtohour_yl

JMP hour_lin_next

tohour_yl:MOV SIgle,3

JMP hour_yl

hour_lin_next:

MOV count_hour,0

MOV SIgle,5

CALL CLk

MOV DL,CH

CALL bcd2

CMP AL,12

JBhour_kk1

SUB AL,12

hour_kk1: MOV CL,30

MUL CL

PUSH AX

XOR DX,DX

MOV AX,minute2

MOV CX,12

DIV CX

MOV CX,AX minurte2/12

POP AX

ADD AX,CX

MOV hour2,AX

擦掉

MOV Color,0

MOV AX,hour

MOV BX,r0

ADD BX,20

CALL renovate

MOV DX,yuanx

MOV x3,DX

MOV DX,yuany

MOV y3,DX

ADD AX,270

ADD BX,400 90

CALL renovate

MOV DX,yuanx 擦掉

MOV x2,DX

MOV DX,yuany

MOV y2,DX

MOV DX,x0

MOV x1,DX

MOV DX,y0 擦掉

MOV y1,DX

CALL sjx

ADD AX,180

CALL renovate

MOV DX,yuanx 擦掉

MOV x2,DX

MOV DX,yuany

MOV y2,DX

SUB BX,100

CALL renovate

MOV DX,yuanx

MOV x3,DX

MOV DX,yuany

MOV y3,DX擦掉

CALL sjx

MOV SIgle,4

***************************; 重写

hour_yl: MOV AL,color_hour

MOV color,AL

MOV AX,hour2

MOV BX,r0

ADD BX,70

CALL renovate

MOV DX,yuanx

MOV x3,DX

MOV DX,yuany

MOV y3,DX

ADD AX,90

ADD BX,60090

CALL renovate

MOV DX,yuanx

MOV x2,DX

MOV DX,yuany

MOV y2,DX 重写

ADD AX,180

CALL renovate

MOV DX,yuanx

MOV x1,DX

MOV DX,yuany

MOV y1,DX

CALL sjxx

CALL sjxy

ADD AX,270

SUB BX,100

CALL renovate

MOV DX,yuanx

MOV x3,DX重写

MOV DX,yuany

MOV y3,DX

CALL sjx

CALL sjxx

CALL sjxy

MOV CX,hour2

MOV hour,CX

hour_quit:POPa

RET

hour_lin ENDP

********************************

minute_linPROC NEAR

PUSHa

CMP count_minute,11

JBtominute_yl仍是原来的一个

JMP minute_lin_next

tominute_yl: MOV SIgle,0

JMP minute_yl

minute_lin_next:

INC count_hour

CALL CLk

MOV DL,CL

CALL bcd2bcd->16

MOV CL,6

MUL CL al*cl

PUSH AX

MOV DL,second2

CALL bcd2

XOR AH,AH

MOV CL,12

DIV CL

MOV CL,AL second2/12

POP AX

MOV CH,0

ADD AX,CX

MOV minute2,AX

AAAa1:

MOV SIgle,2

MOV Color,0

MOV AX,minute

MOV BX,r0

ADD BX,10

CALL renovate

MOV DX,yuanx

MOV x3,DX

MOV DX,yuany

MOV y3,DX

ADD AX,268

ADD BX,800 90

CALL renovate

MOV DX,yuanx

MOV x2,DX

MOV DX,yuany

MOV y2,DX

MOV DX,x0

MOV x1,DX

MOV DX,y0

MOV y1,DX

CALL sjx

ADD AX,180

CALL renovate

MOV DX,yuanx

MOV x2,DX

MOV DX,yuany

MOV y2,DX

ADD AX,90

SUB BX,200

CALL renovate

MOV DX,yuanx

MOV x3,DX

MOV DX,yuany

MOV y3,DX

CALL sjx

inc count0

cmp count0,5

jnz minute_yl

mov count0,0

call music

call music

call music

求一个程序,微机原理,8086汇编语言,实现一个简单实用功能,如时钟显示

在右上角显示时钟,按任一键结束

用MASM5.0编译通过.

data segment

HH DB 0,0,':'

MM DB 0,0,':'

SS1 DB 0,0

data ends

code segment

main proc far

assume cs:code

start:

push ds

mov ax,0

push ax

mov ax,data

mov ds,ax

AGAIN:

mov ah,2ch 读取系统时咐扮间 CH:CL--时:分 DH:DL--秒:衡历灶百分秒

int 21h

MOV BX ,OFFSET HH

MOV AL,CH

CALL C16_10 转换AL中16进制为10进制,并填入相应位置烂神

MOV BX ,OFFSET MM

MOV AL,CL 分

CALL C16_10

MOV BX ,OFFSET SS1

MOV AL,DH 秒

CALL C16_10

MOV AH,2 光标定位

MOV DH,0 首行

MOV DL,70 70列

MOV BH,0

INT 10H

MOV CX,8

MOV SI,OFFSET HH

NN1:

MOV AH,0EH 电传方式写字符(一次1个)

MOV AL,[SI]

MOV BL,0

INT 10H

INC SI

LOOP NN1

MOV AH,1

INT 16H

JNZ DOWN 按任一键结束

JMP AGAIN

DOWN:

RET

main endp

============

C16_10 PROC NEAR

PUSH CX 将AL中的16进制转为10进制

MOV AH,0

MOV CX,10D

DIV CL

ADD AX,3030H

MOV [BX],AL

INC BX

MOV [BX],AH

POP CX

RET

C16_10 ENDP

=============

code ends

end start


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/8276691.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-14
下一篇 2023-04-14

发表评论

登录后才能评论

评论列表(0条)

保存