SLIDE 5 5
VIUF Fall 1997 Ashenden, Wilsey & Martin — SUAVE: Painless Extension 9
Type Derivation Example (cont)
type memory_instruction is abstract new instruction with record base : register_number;
end record memory_instruction; function effective_address_of ( instr : memory_instruction ) return natural; procedure perform_memory_transfer ( instr : memory_instruction ) is abstract; type load_instruction is new memory_instruction with record destination : reg_number; end record load_instruction; procedure perform_memory_transfer ( instr : load_instruction ); type store_instruction is new memory_instruction with record source : reg_number; end record store_instruction; procedure perform_memory_transfer ( instr : store_instruction );
VIUF Fall 1997 Ashenden, Wilsey & Martin — SUAVE: Painless Extension 10
Type Derivation Example (cont)
procedure execute ( instr : instruction'class ) is begin disassemble ( instr, trace_file ); if privileged(instr) and execution_mode = user then handle_privilege_violation; else . . . end if; end procedure execute; entity instruction_reg is port ( load_enable : in bit; instr_in : in instruction'class; instr_out : out instruction'class ); end entity instruction_reg;