RosettaCodeData/Task/Sleep/8051-Assembly/sleep.8051
2016-12-05 23:44:36 +01:00

23 lines
583 B
Text

ORG RESET
jmp main
ORG TIMER0
; timer interrupt only used to wake the processor
clr tr0
reti
main:
setb ea ; enable interrupts
setb et0 ; enable timer0 interrupt
mov tl0, #0 ; start timer counter at zero
mov th0, #0 ; these two values dictate the length of sleep
mov a, pcon ; copy power control register
setb a.0 ; set idl bit
setb tr0 ; start timer
; sleeping...
mov pcon, a ; move a back into pcon (processor sleeps after this instruction finishes)
; when the timer overflows and the timer interrupt returns, execution will resume at this spot
; Awake!
jmp $