[Assembler ASM] Own OS - Real Time Interrupts

S

SGC-Fireball

Hi @ll
ich versuche seit 2 Tagen mich in die "Real Time Interrupts" einzuklingen damit ich immer schön ne Uhrzeit bei mir ausgeben kann aber irgendwie klappt das nicht ganz ...
hier der Code
Code:
handler_int20:
	cli
	push si
	mov si,testmsg
	call putstr
	pop si
	sti
	iret

hook_int20:
	push ax
	push es
	xor ax, ax
	mov es, ax
	cli
	mov word [es:0x20*4], handler_int20
	mov [es:0x20*4+2], cs
	sti
	pop es
	pop ax
	ret

Und hier nochmal des ganzen Systems

Code:
org 0x7c00	; This is where BIOS loads the bootloader

entry:
jmp begin ; jump over the DOS boot record data

brINT13Flag		DB		90H             ; 0002h - 0EH for INT13 AH=42 READ
brOEM			DB		'MSDOS5.0'      ; 0003h - OEM name & DOS version (8 chars)
brBPS			DW		512             ; 000Bh - Bytes/sector
brSPC			DB		1               ; 000Dh - Sectors/cluster
brResCount		DW		1               ; 000Eh - Reserved (boot) sectors
brFATs			DB		2               ; 0010h - FAT copies
brRootEntries	DW		0E0H	     	; 0011h - Root directory entries
brSectorCount	DW		2880            ; 0013h - Sectors in volume, < 32MB
brMedia			DB		40             ; 0015h - Media descriptor
brSPF			DW		9               ; 0016h - Sectors per FAT
brSPH			DW		18              ; 0018h - Sectors per track
brHPC			DW		2	        	; 001Ah - Number of Heads
brHidden		DD		0               ; 001Ch - Hidden sectors
brSectors		DD		0	            ; 0020h - Total number of sectors
				DB		0               ; 0024h - Physical drive no.
				DB		0               ; 0025h - Reserved (FAT32)
				DB		29H             ; 0026h - Extended boot record sig
brSerialNum		DD		404418EAH       ; 0027h - Volume serial number (random)
brLabel			DB		'Richard H. '   ; 002Bh - Volume label  (11 chars)
brFSID			DB		'FAT12   '      ; 0036h - File System ID (8 chars)
;///VARIABLEN//////////////////////////////////////////////////////////////////////////////////////////////////////
getchmsg		db		"Bitte druecken Sie eine Taste...",13,10,0
loadmsg 		db		"Codename Igel by SGC-Fireball",13,10,0
prompt  		db		"CNI/dev> ",0
rebootmsg  		db		"Reboot starting...",13,10,0
Input			db		255
zeit 			db		30h,30h,':',30h,30h,':',30h,30h,13,10,0
newline 		db		13,10,0
textcolor		db		02h
hour			db		0
min				db		0
sek				db		0
count			db		0
ctime			db		0
testmsg			db		"Test Okay",13,10,0

;///CODE////////////////////////////////////////////////////////////////////////////////////////////////////////////
begin:
xor	ax, ax				; zero out ax
mov	ds, ax				; set data segment to base of RAM

call beep
call vga_on

	call hook_int20

	mov  si, loadmsg
	call putstr
	mov  dx, 16
	call hr
	mov  dx, 464
	call hr
	mov  si, newline
	call putstr

	mov  si, prompt
	call putstr
	call key

	mov  si,rebootmsg
	call putstr
	call getch
call vga_off
call reboot


;//FUNCTION///////////////////////////////////////////////////////////////////////////////////
key:
	mov [count], byte 0
	xor bx,bx
key_start:
	mov ah, 01h			;auf Tasten druck warten
	int 16h				;Ausführen
	jnz key_read		;Wenn JA dann gehe zu Abholen
	jmp key_start		;Wenn Nein dann gehe zurück
key_read:
	mov ah, 00h
	int 16h				;Ausführen
	cmp al,13			;vergleiche auf Enter
	jz key_end			;Wenn Ja dann gehe zu ende
	cmp al,08
	jz key_del
	
	push bx
	mov ah,0Eh			;Zeichen Ausgeben in al
	mov bx, [textcolor]	;Farbe
	int 10h				;Ausführen
	pop bx

	mov [Input+bx],al	;Speicher in bx string
	inc bx				;Array+1
	jmp key_start		;Wenn Nein dann gehe zurück
key_del:
	cmp [count], byte 0
	jz key_start

	push bx
	mov al,08			;al = Del
	mov ah,0Eh			;Zeichen Ausgeben in al
	mov bx, [textcolor]	;Farbe
	int 10h				;Ausführen
	mov al,32			;al = Space
	mov ah,0Eh			;Zeichen Ausgeben in al
	mov bx, [textcolor]	;Farbe
	int 10h				;Ausführen
	mov al,08			;al = Del
	mov ah,0Eh			;Zeichen Ausgeben in al
	mov bx, [textcolor]	;Farbe
	int 10h				;Ausführen
	pop bx

	dec byte [count]
	jmp key_read
key_end:
	mov al, 00h
	mov [Input+bx], al

	mov [count], byte 0
	mov si,newline
	call putstr
	ret					;Zurück springen

beep:
	mov ax,0E07h
	int 10h
	ret

putstr:
	lodsb				; AL = [DS:SI]
	or al, al			; Set zero flag if al=0
	jz putstrd			; jump to putstrd if zero flag is set
	mov ah,0Eh			; video function 0Eh (print char)
	mov bx, [textcolor]	; color
	int 10h
	jmp putstr
putstrd:
	ret

getch:
	mov ah,00h			;Die gewünschte Function
	int 16h				;Ausführen
	mov si, getchmsg
	call putstr
	ret

hr:
	mov ah,0Ch			;Function
	mov bh,00h			;Seite
	mov cx,0			;x
;	mov dx,				;y
	mov al,04h			;Farbe
hr_loop:
	int 10h				;Ausführen
	inc cx				;cx = cx + 1
	cmp cx,640			;IF cx = 310
	je hr_end			;Then jmp hr_end
	jmp hr_loop			;Else jmp hr_loop
hr_end:
	ret

vga_on:
	mov ax,12h			;VGA 640x480x16
	int 10h				;Ausführen
	ret

vga_off:
	mov ax,03h			;Text Modus
	int 10h				;Ausführen
	ret

time:
	mov ah,02h			;Hole Zeit
	int 1ah				;Ausführen
	mov [hour], ch
	mov [min], cl
	mov [sek], dh

	xor ax,ax
	mov al,[hour]
	shl ax,4
	shr al,4
	add ax,3030h
	mov [zeit+0],ah
	mov [zeit+1],al

	xor ax,ax
	mov al,[min]
	shl ax,4
	shr al,4
	add ax,3030h
	mov [zeit+3],ah
	mov [zeit+4],al

	xor ax,ax
	mov al,[sek]
	shl ax,4
	shr al,4
	add ax,3030h
	mov [zeit+6],ah
	mov [zeit+7],al

	mov si, zeit
	call putstr
	ret

reboot:
	db 0xEA
	dw 0x0000
	dw 0xFFFF

handler_int20:
	cli
	push si
	mov si,testmsg
	call putstr
	pop si
	sti
	iret

hook_int20:
	push ax
	push es
	xor ax, ax
	mov es, ax
	cli
	mov word [es:0x20*4], handler_int20
	mov [es:0x20*4+2], cs
	sti
	pop es
	pop ax
	ret


;//SYS//////////////////////////////////////////////////////////////////////////////
times 1024-($-$$)-2 db 0	; Dateilänge: 512 Bytes
dw 0xAA55					; Bootsignatur

Keine Ahnung wieso das nicht geht ....
Jemand ne Ahnug ?

THX schonmal
 
Zuletzt bearbeitet von einem Moderator:
Hi,
wieso versuchst du dich in den INT20h einzuklinken? Der hat mit der RTC doch nu herzlich wenig zu tun. Normalerweise ist das der DOS-Interrupt, da du aber kein DOS laufen hast, ist der nich belegt (ausser von dir). ;) Ausserdem ist er mit keiner IRQ-Leitung gekoppelt, ist also ein reiner Software-Interrupt-Vector (es sei denn, du programmierst den PIC um).

Was du brauchst, ist eher INT1Ch, der wird von der RTC alle 18,2 sec. aufgerufen. Direkt den Handler für die RTC umzuschreiben würde ich dir nicht empfehlen, weil das Bios den INT noch für interne Zwecke nutzt. Hoffe, dir geholfen zu haben.

MfG TheAlchimist
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück