|
Тема |
Re: RealTime Timer Control in Assembler [re: Duncan Griffin] |
|
Автор | dido (Нерегистриран) | |
Публикувано | 29.01.04 16:22 |
|
|
Instrukcijata e RDTSC i chete wutreshnija 64 bitow brojach na ciklite w pentium - chudesna e za profiling na code, no ne e towa, koeto mu trjabwa na choweka. Ako iska da pipa po RTC-to, trjabwa da go prawi pod DOS i da polzwa njakakuw DOS-owski assembler - primerno TASM ili MASM.
Za RTC-to:
interfeifsa kum registrite mu e e prez portowe 070h - za izbor na RTC registur i 071h - chetene/zapis na stojnostta na izbranija registur . Na Assembly moze da se dostupwa taka:
chetene na RTC registur
---------------------------------------------------------
cli ; zabrana na interrupts
mov al, address ; izbor na adresa na RTC registur, ot kojto shte chetem
out 70h,al
in al,71h ; chetene na stojnostta na registura
sti ; razreshenie na interrupts
zapis w RTC registur
---------------------------------------------------------
cli ; zabrana na interrupts
mov al, address ; izbor na adresa na RTC registur, w kojto shte pishem
out 70h,al
mov al,value
out 71h,al ; zapis na stojnostta w RTC registura
sti ; razreshenie na interrupts
RTC moze da generira prekuswane - 070h, no po-dobre ne pipaj tam, ako njamash nuzda
Po-dolu e spisuka na RTC registrite:
Address Function
--------------------------------------
0 actual second
1 alarm second
2 actual minute
3 alarm minute
4 actual hour
5 alarm hour
6 day of week (not used by the BIOS nor DOS)
7 day of month
8 month
9 year
A status A
B status B
C status C
D status D
E - 3F buffered memory that holds the BIOS setup
40 - 7F buffered memory available with some clones
status A (Control 1)
--------
Bit 0-3: interrupt frequency (PC: 0110b = 1024 ints per second)
4-6: xtal frequency (PC: 010b = 32,768 kHz)
7: UIP (update in progess: if 1, time is invalid)
UIP tells you when you can't read the registers 0, 2, 4, 6 - 9 at the
moment. It is usually high for less than a millisecond.
You can change bits 0-6. These are the values that produce useful results
in a PC:
Bits 6-4
--------
010 use 32,768 Hz xtal
others don't do anything useful in PCs, really...
Bits 3-0
--------
0000 seems to inhibit the whole RTC
0001 divides xtal by 128 (PC: 256 ints per second)
0010 divides xtal by 256 (PC: 128 ints per second)
0011 divides xtal by 4 (PC: 8192 ints per second)
0100 divides xtal by 8 (PC: 4096 ints per second)
0101 divides xtal by 16 (PC: 2048 ints per second)
0110 divides xtal by 32 (PC: 1024 ints per second)
0111 divides xtal by 64 (PC: 512 ints per second)
1000 divides xtal by 128 (PC: 256 ints per second)
1001 divides xtal by 256 (PC: 128 ints per second)
1010 divides xtal by 512 (PC: 64 ints per second)
1011 divides xtal by 1024 (PC: 32 ints per second)
1100 divides xtal by 2048 (PC: 16 ints per second)
1101 divides xtal by 4096 (PC: 8 ints per second)
1110 divides xtal by 8192 (PC: 4 ints per second)
1111 divides xtal by 16384 (PC: 2 ints per second)
Obviously you should only use values 0011 - 1111. Note also that
8192 ints per second is an awful lot for slow computers.
status B (Control 2)
--------
Bit 0: 1=daylight savings flag (German "Sommerzeit"-"summer time")
1: 0=12hr, 1=24hr mode (PC: 1)
2: 0=BCD, 1=binary mode (PC: 0)
3: 1=square wave generator on (PC: 0)
4: 1=generate time update interrupts (every second) (PC: 0)
5: 1=alarm interrupt (int when alarm time reached) (PC: 0)
6: 1=generate periodic interrupt (see status A) (PC: 0)
7: 1=inhibit time increment (while setting the clock)
status C (interrupt cause)
--------
Bit 4: 1=time changed (generated every second)
5: 1=alarm time reached
6: 1=periodic int
others not defined
status D (battery)
--------
Bit 7: 1=battery OK, 0=battery weak
others undefined
|
| |
|
|
|