Re: A86: asm clock?
[Prev][Next][Index][Thread]
Re: A86: asm clock?
I tried to do this a while back. I've attached the source code for what I
had. I started it late one night and Matt Johnson gave me a little help in
getting the interrupt routine to work. We figured out that the interrupt
was called 174 times a second, which seemed to work for both of our
calculators. Maybe our batteries were at the exact same level, I don't
know. But I remember I timed it with my digital watch and it kept accurate
time to the second for at least 10 minutes, as long as I made sure it
didn't APD (which pauses the clock).
The program displays a clock in the upper left corner of the screen in the
small font. If I remember correctly even the hours work, but I never
tested it that far. I'm about positive it won't roll over when it hits 12
or 24 hours either. Also, there is no way to set the time--it starts at
00:00:00 whenever you (re)run it. And, there is no way to uninstall it.
Maybe the kill-hook, I never messed with it.
This is my first and only interrupt program, so if it crashes your calc or
causes other problems, remember I warned you first.
At 11:21 AM 9/13/98 EDT, you wrote:
>
>even if it isn't accurate, what would be the commands for a clock in asm?
>Just curious
>
>
>-Cliff
>
;
; Clock v1.0
; David Phillips <electrum@tfs.net>
; program started: 08/03/98
; last update: 08/04/98
;
;
; Special thanks to Matt Johnson <matt2000@gte.net> for this interrupt skeleton taken
; from his 86 Central and various other help he gave while I wrote this program
#include "ti86asm.inc"
#define pushR in a,(5) \ push af \ ld a,$0d \ out (5),a \ nop \ nop \ nop
#define popR pop af \ out (5),a
int_addr equ $F8F8 ;Start of interrupt code
.org _asm_exec_ram ;Set instruction counter to $D748 (start of all asm programs)
ld hl,$FA00 ;Source = $FA00 (Start of vector table)
ld de,$FA01 ;Destination = $FA01
ld (hl),$F8 ;Set first byte so it is copied to all of them ($F8F8)
ld bc,256 ;256 bytes (size of vector table)
ldir ;(DE) <- (HL), BC=BC-1, Loop till B=0
ld hl,int_copy ;Source = interrupt routine
ld de,int_addr ;Destination = $F8F8 (as specified in vector table)
ld bc,int_end-int_start ;Length of custom interrupt routine
ldir ;(DE) <- (HL), BC=BC-1, Loop till B=0
ld a,$FA ;Set up address of vector table
ld i,a ; MSB = $FA
; LSB = (byte supplied by data bus - random)
im 2 ;Set interrupt mode 2
ret ;Return
int_copy:
.org int_addr ;Set instruction counter to $F8F8 (start of int handler)
int_start:
ex af,af' ;Exchange af with alternate register af'
exx ;Exchange all other reg's with alternate reg's
;-----Clock code below--------------------------------------
ld hl,ticks
ld a,(hl)
inc a
cp 174
ld (hl),a
jp nz,$66
ld (hl),0
ld hl,text+7
ld a,(hl)
inc a
cp 58
jr z,secd_roll
ld (hl),a
jr show_clock
secd_roll:
ld (hl),48
dec hl
ld a,(hl)
inc a
cp 54
jr z,sec_roll
ld (hl),a
jr show_clock
sec_roll:
ld (hl),48
dec hl
dec hl
ld a,(hl)
inc a
cp 58
jr z,mind_roll
ld (hl),a
jr show_clock
mind_roll:
ld (hl),48
dec hl
ld a,(hl)
inc a
cp 54
jr z,min_roll
ld (hl),a
jr show_clock
min_roll:
ld (hl),48
dec hl
dec hl
ld a,(hl)
inc a
cp 58
jr z,hourd_roll
ld (hl),a
jr show_clock
hourd_roll:
ld (hl),48
dec hl
inc (hl)
show_clock:
ld hl,(_penCol)
ex de,hl
ld hl,0
ld (_penCol),hl
ld hl,text
pushR
call _vputs
popR
ex de,hl
ld (_penCol),hl
;-----------------------------------------------------------
jp $66 ;jump to normal handler so it can do its things
text:
.db "00:00:00",0 ; '0' to '9', 48 to 57
ticks:
.db 0
int_end:
.end
--
David Phillips
mailto:electrum@tfs.net
ICQ: 13811951
AOL/AIM: Electrum32
Follow-Ups:
References: