Page 1 of 1

[TI ASM] Converting date to number of seconds since epoch

Posted: Wed 22 Oct, 2008 11:48 am
by benryves
(This is for the TI-84 series with its real-time clock).

I need to be able to convert a date and time, where I know the individual numeric components (ie, year, month, day, hour, minute and second) into a number of seconds since 1997/01/01 to set the clock. I also need to be able to go the other way and convert a number of seconds since 1997/01/01 to a date and time.

Does the TI-OS expose such functionality to assembly programmers?

This is for BBC BASIC's TIME$ pseudo-variable. It's a 24-character string in the form Wed,22 Oct 2008.12:46:25. I've written code to convert the string representation to and from the individual components, but the clock chip I'm using makes life easy by storing the date and time components as packed BCD.

Re: [TI ASM] Converting date to number of seconds since epoch

Posted: Fri 31 Oct, 2008 12:46 pm
by King Harold
I tried to search for something like that on WikiTI
But it is an "attack site"?? wtf?
That can't be true, but it makes it annoying to browse it.. I didn't find any useful BCalls - but that doesn't mean that there are none..

Re: [TI ASM] Converting date to number of seconds since epoch

Posted: Fri 31 Oct, 2008 1:27 pm
by benryves
There's been a problem on Dan's site - something modified the PHP to embed an iframe that linked to a malicious PDF. Andy_J fixed it, but I think he's looking for a new host (current versions of MediaWiki require PHP5, Dan's host only has PHP4).

BrandonW had the answers, though; there are BCALLs to get and set the current date and time via the floating point stack. :)

Re: [TI ASM] Converting date to number of seconds since epoch

Posted: Fri 31 Oct, 2008 1:41 pm
by driesguldolf
That's why you browse with firefox + noscript (it blocks those attempts) (get adblock too while you're at it) plugin :P

Re: [TI ASM] Converting date to number of seconds since epoch

Posted: Fri 31 Oct, 2008 2:40 pm
by benryves
driesguldolf wrote:That's why you browse with firefox + noscript (it blocks those attempts) (get adblock too while you're at it) plugin :P
You can disable JavaScript in any browser and as you can clearly see from the screenshot IE blocks said attempts as well. (The restarted tab is because the malicious PDF crashes Foxit).

Re: [TI ASM] Converting date to number of seconds since epoch

Posted: Fri 31 Oct, 2008 2:53 pm
by driesguldolf
benryves wrote:
driesguldolf wrote:That's why you browse with firefox + noscript (it blocks those attempts) (get adblock too while you're at it) plugin :P
You can disable JavaScript in any browser and as you can clearly see from the screenshot IE blocks said attempts as well. (The restarted tab is because the malicious PDF crashes Foxit).
Well yes, but with noscript allows a much finer degree of control.

(okok... I don't like ie :P)

Re: [TI ASM] Converting date to number of seconds since epoch

Posted: Fri 31 Oct, 2008 3:01 pm
by benryves
Or just use Opera where it's built in. ;) Just trying to avoid the browser fanboyism.

Code: Select all

RTC.Write:
	
	ld hl,(Date.Year)	
	.bcall _SetXXXXOP2
	.bcall _OP2ToOP1
	.bcall _PushOP1
	
	ld a,(Date.Month)
	.bcall _SetXXOP1
	.bcall _PushOP1

	ld a,(Date.DayOfMonth)
	.bcall _SetXXOP1
	
	.bcall $516A ; setDate
	
	ld a,(Time.Hour)
	.bcall _SetXXOP1
	.bcall _PushOP1
	
	ld a,(Time.Minute)
	.bcall _SetXXOP1
	.bcall _PushOP1

	ld a,(Time.Second)
	.bcall _SetXXOP1
	
	.bcall $5170 ; setTime
	
	ret