L install		# install an *interrupt* gate in the IDT
			# no trap gate option here
			# Reflex address in A
			# int vector # in DI
# WHICH IDT in BP


	= 16 to B                # pre-shifted GDT selector 2, ring0 CS
	= 14 to C                # 386 interrupt gate
	upshift 3 to DI          #    vector # is now IDT offset
	+ BP to DI             #     now DI is the address of the gate


		# call-by-fall-through

L makegate              # construct a gate descriptor at DI;4+DI in mem.
                        #       CS offset to handler code in A
                        #       gate type in C
                         #       address of gate in DI
			#   ASSUMES DPL ZERO
       = A to D                         # copy offset
       AND 0x0000ffff to D
       OR  0x100000 to D                # high dual is ring0 CS selector
       = D to @ DI                      # low quad in place

       upshift 8 to C                   # gate type up a byte
       OR 0x8000  to C                  # marked present
       AND 0xffff0000 to A              # high dual of offset
        OR A to C
          = C to @ 4 DI
                       return


L settrap
                              # Reflex address in A
                              # int vector # in DI
       = 16 to B                # pre-shifted GDT selector 2, ring0 CS
       = 14 to C                # 386 interrupt gate
       upshift 3 to DI          #    vector # is now IDT offset
       + BP to DI             #     now DI is the address of the gate
 call makegate
			return


