Writing Trap Handlers |
Reference: Computer Systems, Chapter 8, Section 8.2.
A trap instruction executes as if it were a single machine language instruction wired into the instruction set of the CPU.
However, it really executes a sequence of machine language instructions that are initiated by the hardware trap mechanism.
The Pep/8 operating system provides one nonunary trap instruction, NOP
and four unary trap instructions,
NOP0
, NOP1
, NOP2
, and NOP3
, so you can reprogram them to implement
instructions of your own choosing.
Topics: Trap handlers, The .BURN pseudo-op.
NOP0
, NOP1
, NOP2
, NOP3
,
NOP
, DECI
, DECO
, or STRO
.
Select the menu option System->Redefine Mnemonics to change the mnemonics of one of the instructions.
The dialog box requires you to enter a mnemonic and its allowed addressing modes if it is nonunary.
For example, change the mnemonic for the unary instruction NOP0
to ECHO
.
And here is how you would modify it to implement the new ECHO
instruction in place of NOP0
.
CAUTION: You cannot use any trap instructions in your trap handler.
You can save your modified operating system as a .pep
file as you would any other Pep/8 assembly language program.
.BURN
in a program, the assembler assumes that the program will be burned into read-only memory (ROM).
It generates code for those instrctions that follow the burn directive, but not for those that precede it.
The assembler also assumes that the ROM will be installed at the bottom of memory, leaving the top of memory for the application programs.
It therefore calculates tha addresses for the symbol table such that the last byte generated will have the address specified
by the burn directive.
Pep/8 is a 16-bit computer, and can therfore access 216 = 64KB = 65,536 bytes of main memory.
The Pep/8 operating system contains .BURN 0xFFFF
because 0xFFFF
is the address of the 65,536th byte.
It is possible to install a smaller amount of memory in the Pep/8 system.
Simply change the burn directive in the operating system to a smaller value.
For example, you can change the burn directive to .BURN 0x7FFF
, assemble and install the new OS,
and the system will install only 32KB of memory instead of 64KB.
The trap handlers all run correctly, which you can trace in the Memory Dump pane.