|
主题 : : 实验14,很巧妙的程序。 [已解决] |
回复[ 6次 ]
点击[ 477次 ] | |
|
|
|
|
[帖 主]
[ 发表时间:2010-08-18 14:03 ]
[引用]
[回复]
[ top ] | |
荣誉值:16
信誉值:0
注册日期:2010-07-09 09:48 |
;p271 exam 14 2010.8.18
;编程,以“年/月/日/ 时:分:秒"的格式,显示当前的日期、时间。
assume cs:code
code segment
port: db 9,8,7,4,2,0
start:
mov ax,cs
mov ds,ax
mov ax,0b800h
mov es,ax
mov si,offset port
mov bx,0
mov cx,6
disp: push cx
mov al,[si]
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[bx],ah
mov byte ptr es:[bx+2],al
cmp byte ptr ds:[si],7
jnb above;>=7就转到标号above
cmp byte ptr [si],0
je s0;=0不做操作,转到标号s0
mov byte ptr es:[bx+4],':'
jmp short s0
above:
je equal;=7就转到标号equal
mov byte ptr es:[bx+4],'/'
jmp short s0
equal: mov byte ptr es:[bx+4],' '
s0: inc si
add bx,6;6=2+2+2,时间的个位和十位都用一个字单元来表示(低位是数值,高位是属性)
pop cx
loop disp
mov ax,4c00h
int 21h
code ends
end start | | |
|
|
|
|
[第1楼]
[ 回复时间:2010-08-18 14:08 ]
[引用]
[回复]
[ top ] | |
荣誉值:16
信誉值:0
注册日期:2010-07-09 09:48 |
大量使用转移指令,使用标号来获取端口地址,程序比较简单,就是不太容易读懂。有更好思路的请跟帖。嘿嘿 | | |
|
|
|
|
[第2楼]
[ 回复时间:2010-08-18 14:28 ]
[引用]
[回复]
[ top ] | |
荣誉值:16
信誉值:0
注册日期:2010-07-09 09:48 |
动态显示时间,好像超出了本章的范围。
;p271 exam 14 2010.8.18
;编程,以“年/月/日/ 时:分:秒"的格式,显示当前的日期、时间。
assume cs:code
code segment
port: db 9,8,7,4,2,0
start:
mov ax,cs
mov ds,ax
mov ax,0b800h
mov es,ax
mov si,offset port
mov bx,0
mov cx,6
disp: push cx
mov al,[si]
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[bx],ah
mov byte ptr es:[bx+2],al
cmp byte ptr ds:[si],7
jnb above;>=7就转到标号above
cmp byte ptr [si],0
je s0;=0不做操作,转到标号s0
mov byte ptr es:[bx+4],':'
jmp short s0
above:
je equal;=7就转到标号equal
mov byte ptr es:[bx+4],'/'
jmp short s0
equal: mov byte ptr es:[bx+4],' '
s0: inc si
add bx,6;6=2+2+2,时间的个位和十位都用一个字单元来表示(低位是数值,高位是属性)
pop cx
loop disp
in al,60h
cmp al,10h ;Q键的扫描码
je quit
jmp start ;以上4句为动态获取系统时间的关键
quit: mov ax,4c00h
int 21h
code ends
end start | | |
|
|
|
|
[第3楼]
[ 回复时间:2010-08-18 14:51 ]
[引用]
[回复]
[ top ] | |
荣誉值:268
信誉值:12
注册日期:2010-06-18 22:19 |
|
|
|
|
|
[第4楼]
[ 回复时间:2010-08-18 14:51 ]
[引用]
[回复]
[ top ] | |
荣誉值:16
信誉值:0
注册日期:2010-07-09 09:48 |
花招,纯粹娱乐!
;p271 exam 14 2010.8.18
;编程,以“年/月/日/ 时:分:秒"的格式,显示当前的日期、时间。
assume cs:code
data segment
db "Press 'Q' to quit!!",'$'
data ends
code segment
port: db 9,8,7,4,2,0
start:
mov ah,2
mov bh,0
mov dh,11
mov dl,29
int 10h
mov ax,data
mov ds,ax
mov dx,0
mov ah,9
int 21h
xunhun:
mov ax,cs
mov ds,ax
mov ax,0b800h
mov es,ax
mov si,offset port
mov bx,12*160+30*2
mov cx,6
disp: push cx
mov al,[si]
out 70h,al
in al,71h
mov ah,al
mov cl,4
shr ah,cl
and al,00001111b
add ah,30h
add al,30h
mov byte ptr es:[bx],ah
mov byte ptr es:[bx+2],al
cmp byte ptr ds:[si],7
jnb above;>=7就转到标号above
cmp byte ptr [si],0
je s0;=0不做操作,转到标号s0
mov byte ptr es:[bx+4],':'
jmp short s0
above:
je equal;=7就转到标号equal
mov byte ptr es:[bx+4],'/'
jmp short s0
equal: mov byte ptr es:[bx+4],' '
s0: inc si
add bx,6;6=2+2+2,时间的个位和十位都用一个字单元来表示(低位是数值,高位是属性)
pop cx
loop disp
in al,60h
cmp al,10h
je quit
jmp xunhun
quit: mov ax,4c00h
int 21h
code ends
end start | | |
|
|
|
|
[第5楼]
[ 回复时间:2010-08-18 14:58 ]
[引用]
[回复]
[ top ] | |
荣誉值:16
信誉值:0
注册日期:2010-07-09 09:48 |
检测q键的语句偷学的,:)
还没学到外部中断语句了。 | | |
|
|
|
|
[第6楼]
[ 回复时间:2010-09-01 10:05 ]
[引用]
[回复]
[ top ] | |
荣誉值:16
信誉值:0
注册日期:2010-07-09 09:48 |
此贴由 贴主 于 [ 2010-09-01 10:05 ] 结贴。 结贴原因:问题已解决 | | |
|