Hey, bubach, you have 10 messages, 0 are new. 01/30/05 16:31
Home Help Search Edit Profile Show all Topics with Notification Logout

Mega-Tokyo Message Board  |  Programming  |  OS Development, Design, FAQ, etc (Moderators: df, Tim Robinson, Pype.Clicker, Candy, Solar)  |  Topic: time in pmode « previous next »
Pages: [1] Reply Notify of replies Send the topic Print
   Author  Topic: time in pmode  (Read 110 times)
Hamza
Guest

E-Mail
time in pmode
« on: 07/26/03 15:11 »
Reply with quote Modify message Remove message Split Topic

How can I get second of time in pmode from cmos area? Where is it?
Report to moderator   195.175.110.242
Peter_Vigren
Member
****

Posts: 214





View Profile Instant Message (Offline)
Re:time in pmode
« Reply #1 on: 07/26/03 20:24 »
Reply with quote Modify message Remove message Split Topic

The second is where it is in real mode; in register 0 of CMOS (minute in reg 2 and hour in reg 4)...
Report to moderator   213.204.132.43

Best regards,
Peter Vigren


Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
Hamza
Guest

E-Mail
Re:time in pmode
« Reply #2 on: 07/26/03 22:29 »
Reply with quote Modify message Remove message Split Topic

What register? Do u mean ports?? Can you give a simple example code to read second?
Report to moderator   195.175.230.211
Peter_Vigren
Member
****

Posts: 214





View Profile Instant Message (Offline)
Re:time in pmode
« Reply #3 on: 07/27/03 00:54 »
Reply with quote Modify message Remove message Split Topic

Quote from: Hamza on 07/26/03 22:29
What register? Do u mean ports?? Can you give a simple example code to read second?
Yes, I mean ports.

Of course.

Code:

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

However, before you try to read the register you should check if the CMOS is updating time...

Code:

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


I hope you can read the code even with the comments...

Hm... it may not be so easy to follow... you asked for simple code... Basicly, this is it:

Code:

Mov Al,0
Out 70h,Al
Jmp short $+2
In Al,71h


You send the number of the register you wants to port 0x70 (70h). Then you use a short jmp (that jumps to the next instruction) in order to wait for the data to become available. After that, you read the data at port 0x71 (71h)...
« Last Edit: 07/27/03 01:03 by Peter_Vigren » Report to moderator   213.204.132.50

Best regards,
Peter Vigren


Oh, you know the story. Girl meets boy. Girl modifies boy’s sub routines...
Pype.Clicker
Moderator
Member
*****

Posts: 4041



Use the Source!
98176626 98176626
View Profile WWW E-Mail Instant Message (Offline)
Re:time in pmode
« Reply #4 on: 07/28/03 17:09 »
Reply with quote Modify message Remove message Split Topic

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)
Report to moderator   139.165.203.195

May the Source be with You ::OSID::.:QuickLinkz:.:metawb:
Adeel Mahmood
Member
****

Posts: 139




adeelmahmood1
View Profile WWW E-Mail Instant Message (Offline)
Re:time in pmode
« Reply #5 on: 07/28/03 17:25 »
Reply with quote Modify message Remove message Split Topic

well .. here is all what u need
 cmos.h
Report to moderator   68.77.23.231
Pages: [1] Reply Notify of replies Send the topic Print 
Mega-Tokyo Message Board  |  Programming  |  OS Development, Design, FAQ, etc (Moderators: df, Tim Robinson, Pype.Clicker, Candy, Solar)  |  Topic: time in pmode « previous next »
Jump to: 
Mega-Tokyo Message Board | Powered by YaBB SE
© 2001-2004, YaBB SE Dev Team. All Rights Reserved.