The Bluff Machine (Single Module Version)

John T. Korb · Purdue e-Pubs (Purdue University System) · 1984

This report documents the target machine used by the Compiler Con· struction class (08502) at Purdue University. The Bluff machine is a simple, stack-oriented machine designed to permit straightforward translation from C programs. A Bluff assembler and machine interpreter have been implemented for VAX UNIX systems. The version of Bluff defined in this report is designed for programs consisting of a single module (or for multiple modules combined into a single module at compile or link time). It provides no support for dynamic program loading. A multi-module version is forthcoming. The Bluff Machine (Single Module Version) 1. General Features The Bluff machine is a general-purpose, stack-oriented processor. It uses one·byte opcodes and relative addresses to efficiently encode instructions. The word size is 32 bits. Bluff provides a number of facilities for the implementation of high-level languages. It includes instructions for recursive procedure calls, automatic argument passing, and efficient access to local and global variables. The Bluff machine uses two stacks, a procedure stack and a register stack. The procedure stack contains frames of partially executed procedures, with the currently executing procedure frame on top. The register stack is a block of accumulators that store the results of partially computed expressions. The procedure stack is kept in main memory, although the top few elements may be kept in processor memory. The entire register stack is contained in processor memory. 2. Bluff Registers All registers are thirty-two bits wide. There are two kinds of addresses in Bluff, word addresses and byte addresses. Integers and pointers are addressed using word addresses, instructions are addressed using byte addresses. PC The PC contains the byte address of the next instruction. SP Register SP points to the next available location on the procedure stack. F Register F (frame pointer) points into the procedure stack to the top of the currently executing procedure frame. G Register G (global pointer) points to the global variable table, a block of memory locations for storing values accessible to all procedures. Bluff provides instructions for accessing global variables relative to this pointer. P Register P (procedure pointer) points to the procedure entry point table. The procedure call instruction gives an offset into this list. The format of the procedure entry point table is described in the data structure section. 3. Initialization a.nd Power-On Seqnence When the power is turned on to the Bluff machine, main memory is assumed to be initialized. Bluff initializes its registers by loading them from the following main memory locations. register memory location SP 0 G 1 P 2 After initializing the three registers, Bluff calls the first procedure in the proce· dure table (that is, it executes a CALLe 0 instruction). The procedure call initializes the remaining two registers (PC and F).

Read the paper · More papers on PaperTik