Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bits 16
- ;; enforce CS:IP
- org 7C00h
- jmp 0x0000: start
- tempdata dw 0x0000
- start:
- call print_time
- jmp $
- ;;; Print the time to wherever cursor is
- ;;; Modified: AX, BX, CX, DX
- print_time:
- call get_real_time_clock_time
- mov al, ch
- call print_bcd_byte
- mov al, ":"
- call print_char
- mov al, cl
- call print_bcd_byte
- mov al, ":"
- call print_char
- mov al, dh
- call print_bcd_byte
- ret
- ;;; Get time of day according to the hardware clock.
- ;;; Return: (all times in BCD)
- ;;; CH = hour
- ;;; CL = minutes
- ;;; DH = seconds
- ;;; DL = daylight savings flag. 0x0 = standard, 0x01 = daylight savings.
- ;;; CF is clear if successful/set on error.
- get_real_time_clock_time:
- mov ah, 0x02
- ;; clear CF (look up how)
- int 0x1a
- ret
- ;;; Print a binary coded byte (two numbers) to where point is.
- ;;; Input:
- ;;; AL = BCD number to print
- ;;; Modified: AX, BX
- print_bcd_byte:
- push ax
- shr al, 4
- add al, 0x30
- call print_char
- pop ax
- and al, 0x0f
- add al, 0x30
- call print_char
- ret
- ;;; Display a single character on the screen.
- ;;; Input:
- ;;; AL = character to write
- ;;; Modified:
- ;;; AH - Set to 0x0e
- ;;; BX - zeroed out.
- print_char:
- mov ah, 0x0e
- ;;clear to 0, lest unexpected color changes happen.
- xor bx, bx
- int 0x10
- ret
Add Comment
Please, Sign In to add comment