diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..f651134 --- /dev/null +++ b/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash +#cd `dirname $0` +bin=$1 +nasm -f bin $1 -o `basename $1`.bin +if [[ $? != 0 ]];then + exit +fi +sudo modprobe nbd 8 +sudo qemu-nbd `dirname $0`/test.qcow2 --connect /dev/nbd0 +sudo dd if=`basename $1`.bin of=/dev/nbd0 +sudo qemu-nbd -d /dev/nbd0 +kvm --hda `dirname $0`/test.qcow2 -rtc base=localtime diff --git a/test-kvm.asm b/test-kvm.asm index 563978e..a5ef235 100644 --- a/test-kvm.asm +++ b/test-kvm.asm @@ -74,6 +74,87 @@ showTailText: mov al,[ds:si] mov byte [es:di],al loop showTailTextLoop + + +get_data: + mov di,80*2*25-2 + + ; 读取秒 + mov al,0x00 + call read_time + mov byte [es:di-4],':' + mov byte [es:di-2],ah + mov byte [es:di],al + ; 读取分钟 + mov al,0x02 + call read_time + mov byte [es:di-10],':' + mov byte [es:di-8],ah + mov byte [es:di-6],al + ; 读取小时 + mov al,0x04 + call read_time + mov byte [es:di-14],ah + mov byte [es:di-12],al + ; 读取日 + mov al,0x07 + call read_time + mov byte [es:di-22],'.' + mov byte [es:di-20],ah + mov byte [es:di-18],al + ; 读取月 + mov al,0x08 + call read_time + mov byte [es:di-28],'.' + mov byte [es:di-26],ah + mov byte [es:di-24],al + ; 读取年 + mov al,0x09 + call read_time + mov byte [es:di-32],ah + mov byte [es:di-30],al + mov cx,showTipsStr-tipsStr + sub di,30 + mov ax,tipsStr + mov ds,ax + ; 先跳过文本显示 + jmp near showTipsStrEnd + ; 显示提示文本 + tipsStr: db 'Time:20' + showTipsStr: + mov di,cx + add di,showTipsStr+0x7c0 + mov dl,[ds:di] + mov di,80*2*25-36 + sub di,cx + mov byte [es:di],dl + loop showTipsStr + showTipsStrEnd: + +jmp near get_data + + +read_time: + out 0x70,al + in al,0x71 + call bcd_to_ascii + ret + +; 用于编码转换:BCD=》ASCII +; 输入:AL=bcd码 +; 输出:AX=ascii +bcd_to_ascii: + mov ah,al + and al,0x0f + add al,0x30 + + shr ah,4 + and ah,0x0f + add ah,0x30 + ret + + + poweroff: ; 跳过关机 diff --git a/test-kvm.asm.bin b/test-kvm.asm.bin index 9e528e2..1620764 100644 Binary files a/test-kvm.asm.bin and b/test-kvm.asm.bin differ diff --git a/test.qcow2 b/test.qcow2 new file mode 100644 index 0000000..a6c28b6 Binary files /dev/null and b/test.qcow2 differ