First commit
This commit is contained in:
commit
9cbd526b37
|
@ -0,0 +1 @@
|
||||||
|
*.com
|
|
@ -0,0 +1,19 @@
|
||||||
|
NASM = nasm
|
||||||
|
|
||||||
|
.SUFFIXES:
|
||||||
|
.SUFFIXES: .asm .com
|
||||||
|
|
||||||
|
all: dosclock.com
|
||||||
|
|
||||||
|
.asm.com:
|
||||||
|
$(NASM) -fbin -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.com
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
|
||||||
|
run: dosclock.com
|
||||||
|
dosbox $<
|
||||||
|
|
||||||
|
.PHONY: all clean distclean run
|
|
@ -0,0 +1,87 @@
|
||||||
|
org 0x100
|
||||||
|
cpu 8086
|
||||||
|
bits 16
|
||||||
|
|
||||||
|
section .code
|
||||||
|
|
||||||
|
setup:
|
||||||
|
; Save original video mode
|
||||||
|
mov ah, 0xf
|
||||||
|
int 0x10
|
||||||
|
mov [original_video_mode], al
|
||||||
|
|
||||||
|
; Move to VGA 320x200 256 color mode
|
||||||
|
mov ah, 0
|
||||||
|
mov al, 0x13
|
||||||
|
int 0x10
|
||||||
|
|
||||||
|
; Set es to point to VGA framebuffer
|
||||||
|
mov ax, 0xa000
|
||||||
|
mov es, ax
|
||||||
|
|
||||||
|
mainloop:
|
||||||
|
mov ah, 0x2c
|
||||||
|
int 0x21
|
||||||
|
cmp ch, [hour]
|
||||||
|
jne .changed
|
||||||
|
cmp cl, [minute]
|
||||||
|
jne .changed
|
||||||
|
cmp dh, [second]
|
||||||
|
jne .changed
|
||||||
|
jmp .unchanged
|
||||||
|
|
||||||
|
.changed:
|
||||||
|
call clear_screen
|
||||||
|
|
||||||
|
mov [hour], ch
|
||||||
|
mov [minute], cl
|
||||||
|
mov [second], dh
|
||||||
|
|
||||||
|
mov bp, 0
|
||||||
|
add bp, [hour]
|
||||||
|
mov byte [es:bp], 1
|
||||||
|
|
||||||
|
mov bp, [width]
|
||||||
|
add bp, [minute]
|
||||||
|
mov byte [es:bp], 2
|
||||||
|
|
||||||
|
mov bp, [width]
|
||||||
|
add bp, [width]
|
||||||
|
add bp, [second]
|
||||||
|
mov byte [es:bp], 4
|
||||||
|
|
||||||
|
.unchanged:
|
||||||
|
hlt
|
||||||
|
jmp mainloop
|
||||||
|
|
||||||
|
exit:
|
||||||
|
; Restore video mode
|
||||||
|
mov ah, 0
|
||||||
|
mov al, [original_video_mode]
|
||||||
|
int 0x10
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
clear_screen:
|
||||||
|
push bp
|
||||||
|
|
||||||
|
xor bp, bp
|
||||||
|
.loop:
|
||||||
|
mov word [es:bp], 0
|
||||||
|
inc bp
|
||||||
|
cmp bp, 320*200/2
|
||||||
|
jne .loop
|
||||||
|
|
||||||
|
pop bp
|
||||||
|
ret
|
||||||
|
|
||||||
|
section .rodata
|
||||||
|
width dw 320
|
||||||
|
height dw 200
|
||||||
|
|
||||||
|
section .data
|
||||||
|
hour dw 0
|
||||||
|
minute dw 0
|
||||||
|
second dw 0
|
||||||
|
|
||||||
|
original_video_mode db 0
|
Loading…
Reference in New Issue