用組合語言編寫時鐘程式,能顯示時分秒的,還要有秒錶就是計

時間 2021-08-11 17:28:52

1樓:雪蕻軒

stack1 segment stack

dw 200 dup (?)

stack1 ends

data segment

space db 1000 dup (' ')

pattern db 6 dup (' '),0c9h,26 dup (0cdh),0bbh,6 dup (' ')

db 6 dup (' '),0bah,26 dup (20h),0bah,6 dup (' ')

db 6 dup (' '),0c8h,26 dup (0cdh),0bch,6 dup (' ')

dbuffer db 8 dup (':'),12 dup (' ')

dbuffer1 db 20 dup (' ')

str1 db 0dh,0ah, 'please input date(d) or time(t) or quit(q): $'

data ends

code segment

assume cs:code,ds:data,es:data,ss:stack1

start: mov ax,0001h ;設定顯示方式為40*25彩色文字方式

int 10h

mov ax,data

mov ds,ax

mov es,ax

mov bp,offset space

mov dx,0b00h

mov cx,1000

mov bx,0040h

mov ax,1300h

int 10h

mov bp,offset pattern ;顯示矩形條

mov dx,0b00h

mov cx,120

mov bx,004eh

mov ax,1301h

int 10h

lea dx,str1 ;顯示提示資訊

mov ah,9

int 21h

mov ah,1 ;從鍵盤輸入單個字元

int 21h

cmp al,44h ;al='d'?

jne a

call date ;顯示系統日期

a: cmp al,54h ;al='t'?

jne b

call time ;顯示系統時間

b: cmp al,51h ;al='q'?

jne start

mov ah,4ch ;返回dos狀態

int 21h

date proc near ;顯示日期子程式

dis:mov ah,2ah ;取日期

int 21h

mov si,0

mov ax,cx

mov bx,100

div bl

mov bl,ah

call bcdasc1 ;日期數值轉換成相應的ascii碼字元

mov al,bl

call bcdasc1

inc si

mov al,dh

call bcdasc1

inc si

mov al,dl

call bcdasc1

mov bp,offset dbuffer1

mov dx,0c0dh

mov cx,20

mov bx,004eh

mov ax,1301h

int 10h

mov ah,02h ;設定游標位置

mov dx,0300h

mov bh,0

int 10h

mov bx,0018h

repea: mov cx,0ffffh ;延時

repeat:loop repeat

dec bx

jnz repea

mov ah,01h ;讀鍵盤緩衝區字元到al暫存器

int 16h

je dis

jmp start

mov ax,4c00h

int 21h

retdate endp

time proc near ;顯示時間子程式

display1:mov si,0

mov bx,100

div bl

mov ah,2ch ;取時間

int 21h

mov al,ch

call bcdasc ;將時間數值轉換成ascii碼字元

inc si

mov al,cl

call bcdasc

inc si

mov al,dh

call bcdasc

mov bp,offset dbuffer

mov dx,0c0dh

mov cx,20

mov bx,004eh

mov ax,1301h

int 10h

mov ah,02h

mov dx,0300h

mov bh,0

int 10h

mov bx,0018h

re: mov cx,0ffffh

rea: loop rea

dec bx

jnz re

mov ah,01h

int 16h

je display1

jmp start

mov ax,4c00h

int 21h

rettime endp

bcdasc proc near ;時間數值轉換成ascii碼字元子程式

push bx

cbwmov bl,10

div bl

add al,'0'

mov dbuffer[si],al

inc si

add ah,'0'

mov dbuffer[si],ah

inc si

pop bx

retbcdasc endp

bcdasc1 proc near ;日期數值轉換成ascii碼字元子程式

push bx

cbwmov bl,10

div bl

add al,'0'

mov dbuffer1[si],al

inc si

add ah,'0'

mov dbuffer1[si],ah

inc si

pop bx

retbcdasc1 endp

code ends

end start

cursor equ 45h

attrib equ 2fh

code segment

assume cs:code,ds:code

start:

jmp go

oldcur dw ?

old1c dw 2 dup(?)

newint1c:

pushf

call dword ptr cs:old1c

push ax

push bx

push cx

push dx

xor bh,bh

mov ah,3

int 10h

mov cs:oldcur,dx

mov ah,2

xor bh,bh

mov dx,cursor

int 10h

mov ah,2     ;讀取系統時鐘

int 1ah

push dx

push cx

pop bx

push bx

call showbyte

call showcolon

pop bx

xchg bh,bl

call showbyte

call showcolon

pop bx

call showbyte

mov dx,cs:oldcur

mov ah,2

xor bh,bh

int 10h

pop dx

pop cx

pop bx

pop ax

iret

showbyte proc near

push bx

mov cl,4

mov al,bh

shr al,cl

add al,30h

call show

call curmove

pop bx

mov al,bh

and al,0fh

add al,30h

call show

call curmove

retshowbyte endp

showcolon proc near

mov al,':'

call show

call curmove

retshowcolon endp

curmove proc near

push ax

push bx

push cx

push dx

mov ah,3

mov bh,0

int 10h

inc dl

mov ah,2

int 10h

pop dx

pop cx

pop bx

pop ax

retcurmove endp

show proc near

push ax

push bx

push cx

mov ah,09h

mov bx,attrib

mov cx,1

int 10h

pop cx

pop bx

pop ax

retshow endp

go:push cs

pop ds

mov ax,351ch ;取中斷向量

int 21h

mov old1c,bx      ;儲存原中斷向量

mov bx,es

mov old1c+2,bx

mov dx,offset newint1c ;置新的中斷向量

mov ax,251ch

int 21h

mov dx,offset go

sub dx,offset start

mov cl,4

shr dx,cl

add dx,11h

mov ax,3100h       ;結束並駐留

int 21h

code ends

end start

組合語言程式設計問題編寫組合語言程式。能每隔10秒顯示數字分別為

org 0000h 數碼管共陰 ajmp main org 000bh t0ms equ not 50000 100 ms 晶振 6.000 mhz pjsbz equ 20h pjsbzy equ 21h pst0 mov tl0,low t0ms t0 中斷 mov th0,high t0ms ...

組合語言編寫的程式顯示有語法錯誤

已經除錯通過的 data segment timer db 4 dup 0 data ends stack segment db 100 dup 0 stack ends code segment assume cs code,ds data,ss stackstart mov ax,0 mov d...

怎麼用組合語言編寫程式,統計字串的長度並輸出

允天曼 ho彙編?不是很懂.用字串.length 看是不是能獲得長度?int i 字串.indexof 獲得位置字串.substring i, 組合語言編語言也分好多種的,你說的是哪一種語言 data segment msg1 db length shex db 0123456789abcdef m...