time in pmode
Re:time in pmode
The second is where it is in real mode; in register 0 of CMOS (minute in reg 2 and hour in reg 4)...
Re:time in pmode
What register? Do u mean ports?? Can you give a simple example code to read second?
Re:time in pmode
Yes, I mean ports.Hamza wrote: What register? Do u mean ports?? Can you give a simple example code to read second?
Of course.
Code: Select all
In Al,70h??????; Read current NMI status
And Al,10000000b???; Bit 7 controlls NMI, do not modify
Add Al,0??????; CMOS port for second
Out 70h,Al??????; Request value from port (invoke port)
Jmp short $+2??????; Create a tiny delay so port hardware have time
?????????; to recover and be set to the right register
In Al,71h??????; Read value
Code: Select all
CheckIfCMOSUpdateInProgress:
Push Eax
CheckIfCMOSUpdateInProgress_TestBit
In Al,70h??????; Read current NMI status
And Al,10000000b???; Bit 7 controlls NMI, do not modify
Add Al,0xA??????; CMOS port for Status A
Out 70h,Al??????; Request value from port (invoke port)
Jmp short $+2??????; Create a tiny delay so port hardware have time
?????????; to recover and be set to the right register
In Al,71h??????; Read value
Test Al,10000000b???; Test bit 7 - Update In Progress
Jnz CheckIfCMOSUpdateInProgress_TestBit
Pop Eax
Ret
Hm... it may not be so easy to follow... you asked for simple code... Basicly, this is it:
Code: Select all
Mov Al,0
Out 70h,Al
Jmp short $+2
In Al,71h
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:time in pmode
time to remove some mistery about hardware design:
a "register" is a scratch memory area where any kind of binary value may be stored.
when you modify the volume on a soundcard, you actually don't modify the volume itself, but a register on the soundcard that will store the value that the soundcard reuses for volume mixing.
Those registers act the very same way generic register do in the CPU, but as they're located on other chips, you can't access them directly. Instead, the CPU will issue an I./O cycle that will tell "read value from I/O address X" or "store value Y at I/O address X", and the address will be recognized by one of the external chip which will later decode it to find which of its internal registers it maps to ...
In some chips, each "accessible" register has a single I/O address (which is the case for instance for Sound Blaster, or for IDE controllers), while some other chips have so much registers that they actually only "export" two : the "address register" and the "data register". Writing a value in the "address register" tells which internal register should be mapped through the virtual "data register".
VGA cards, for instance, work this way, as does the CMOS chip (afaik)
a "register" is a scratch memory area where any kind of binary value may be stored.
when you modify the volume on a soundcard, you actually don't modify the volume itself, but a register on the soundcard that will store the value that the soundcard reuses for volume mixing.
Those registers act the very same way generic register do in the CPU, but as they're located on other chips, you can't access them directly. Instead, the CPU will issue an I./O cycle that will tell "read value from I/O address X" or "store value Y at I/O address X", and the address will be recognized by one of the external chip which will later decode it to find which of its internal registers it maps to ...
In some chips, each "accessible" register has a single I/O address (which is the case for instance for Sound Blaster, or for IDE controllers), while some other chips have so much registers that they actually only "export" two : the "address register" and the "data register". Writing a value in the "address register" tells which internal register should be mapped through the virtual "data register".
VGA cards, for instance, work this way, as does the CMOS chip (afaik)