alright I have this cheesy project description for a clock that keeps time in 100ths of a second up to an hour i.e. hour:min:sec:100th. This is being run on an integrated 8088 board with some leds, where time is displayed useing software refresh loops, and some input switches.
I have setup timer 2 to call an interrupt at 100hz, then I hook and chain code that increases a timer variable every 100th of a second. after that I just increase second counter when timer reaches 100, min counter when timer reaches 6000.
Now, there is a switch that when pressed and held, time should advance at 3600x normal rate i.e. display will increase 3600 sec for every 1 sec of real time.
The problem is this: 1st access to code, timer inc to 1 100th, advanced time 3600 100ths. 2nd time the code is called, timer increased to 2 100ths, advanced time 7200 100ths, but this is 1200 100ths past one second, so the advanced second variable will not be increased to 1 after 6000 100ths like it should be, instead it will be increased to 1 after 7200 100ths. basically, I need to be able to increase the advanced second timer every 1.667 calls to the timer code, or be able to multiply by 1.667, but I don't know how to multiply by fractions in asm.
I have setup timer 2 to call an interrupt at 100hz, then I hook and chain code that increases a timer variable every 100th of a second. after that I just increase second counter when timer reaches 100, min counter when timer reaches 6000.
Now, there is a switch that when pressed and held, time should advance at 3600x normal rate i.e. display will increase 3600 sec for every 1 sec of real time.
The problem is this: 1st access to code, timer inc to 1 100th, advanced time 3600 100ths. 2nd time the code is called, timer increased to 2 100ths, advanced time 7200 100ths, but this is 1200 100ths past one second, so the advanced second variable will not be increased to 1 after 6000 100ths like it should be, instead it will be increased to 1 after 7200 100ths. basically, I need to be able to increase the advanced second timer every 1.667 calls to the timer code, or be able to multiply by 1.667, but I don't know how to multiply by fractions in asm.
An unsigned 32-bit variable could accumulate 497 days worth of 100th seconds. You may want to consider keeping the accumulated "clock ticks" in such a variable, incrementing it by 1 at every interrupt in normal mode or incrementing it by 3600 in accelerated mode.
After the increment is done, you load the EAX register with the variable, zero the EDX register and dividing by 100 would leave the 100th second result in EDX which you can store to modify the 100th LED. The remaining value in EAX would be the total elapsed seconds.
Then after zeroing EDX and dividing by 60, the seconds would be in EDX which you can store to modify the seconds LED. The remaining value in EAX would be the elapsed minutes. Repeating the zeroing EDX and dividing by 60 will leave the actual minutes in EDX to modify the minutes LED leaving the accumulated hours in EAX.
As you can see, it can be done without using fractions.
Raymond
After the increment is done, you load the EAX register with the variable, zero the EDX register and dividing by 100 would leave the 100th second result in EDX which you can store to modify the 100th LED. The remaining value in EAX would be the total elapsed seconds.
Then after zeroing EDX and dividing by 60, the seconds would be in EDX which you can store to modify the seconds LED. The remaining value in EAX would be the elapsed minutes. Repeating the zeroing EDX and dividing by 60 will leave the actual minutes in EDX to modify the minutes LED leaving the accumulated hours in EAX.
As you can see, it can be done without using fractions.
Raymond
Hi,
This really belongs in the electronics forum, the 8088 is not suitable for Win32 programming ;)
This really belongs in the electronics forum, the 8088 is not suitable for Win32 programming ;)
thank you very much raymond :alright: ..
i'll post further questions in the other forum..
i'll post further questions in the other forum..