CHAPTER 12 - Interrupts¶

EXAMPLE 12.1 - PG NO: 374¶

In [4]:
## page no 374
## example no 12.1
## ENABLE INTERRUPTS
import math
def hex2dec(s):
return int(s, 16)

def dec2bin(n):
return ''.join(str(1 & int(n) >> i) for i in range(8)[::-1])

print ('EI \n \n')#   ## enable interrupts
print ('MVI A,08H \n')#
a=hex2dec('8')#
b=dec2bin(a)#
print ('A--> ')
print (b)#
print('\n')
print ('SIM \n \n')#  ## enable RST 7.5,6.5, and 5.5
print ('D3=1     SIM functional \n')#
print ('D2=0     Enable RST 7.5 \n')#
print ('D1=0     Enable RST 6.5 \n')#
print ('D0=0     Enable RST 5.5 \n')#

EI

MVI A,08H

A-->
00001000

SIM

D3=1     SIM functional

D2=0     Enable RST 7.5

D1=0     Enable RST 6.5

D0=0     Enable RST 5.5



EXAMPLE 12.2 - PG NO:374¶

In [2]:
## page no 374
## example no 12.2
## RESET 7.5 INTERRUPT
import math
def hex2dec(s):
return int(s, 16)

def dec2bin(n):
return ''.join(str(1 & int(n) >> i) for i in range(8)[::-1])

print ('MVI A,18H \n')#    ## set D4=1
a=hex2dec('18')#
b=dec2bin(a)#
print ('A--> ')
print (b)#
print('\n')
print ('SIM     Reset 7.5 interrupt flip-flop \n')      ## Reset 7.5 interrupt flip flop

MVI A,18H

A-->
00011000

SIM     Reset 7.5 interrupt flip-flop



EXAMPLE 12.3 - PG NO:375¶

In [3]:
## page no 375
## example no 12.3
## CHECK PENDING INTERRUPT
print ('RIM instruction interpretation \n \n');
print ('D7=SID                      Serial input data if any \n');
print ('D6,D5,D4= I7.5,I6.5,I5.5    Pending interrupts: 1= pending \n');
print ('D3=IE                       Interrupt enable flag: 1= enabled \n');

print ('Instructions \n \n');
print ('        MOV B,A \n');        ## save mask information
print ('        ANI 20H \n');        ## check whether RST 6.5 is pending
print ('        JNZ NEXT \n');
print ('        EI \n');
print ('        RET \n');           ## RST 6.5 is not pending, return to main program
print ('NEXT:   MOV A,B \n');       ## get bit pattern; RST 6.5 is pending
print ('        ANI 0DH \n');       ## enables RST 6.5 by setting D1=0
print ('        ORI 08H\n');        ## enable SIM by setting D3=1
print ('        SIM \n');
print ('        JMP SERV \n');      ## jump to service routine for RST 6.5

RIM instruction interpretation

D7=SID                      Serial input data if any

D6,D5,D4= I7.5,I6.5,I5.5    Pending interrupts: 1= pending

D3=IE                       Interrupt enable flag: 1= enabled

Instructions

RIM

MOV B,A

ANI 20H

JNZ NEXT

EI

RET

NEXT:   MOV A,B

ANI 0DH

ORI 08H

SIM

JMP SERV