PL/0语言编译程序整理实现:(6)、代码类型

来源:互联网 发布:软件开发模型 编辑:程序博客网 时间:2024/05/22 13:12

unit uCodeType;

 

interface

 

const

    CNT_LevelMax = 3; //--最大允许的块嵌套层数)

    CNT_AddressMax = 2047; //--最大寻址空间

    CNT_Code_MaxLen = 200; //--PCODE目标代码表的最大长度(可容纳代码行数)

 

type

    //--PCODE指令类型

    TInstructionType = (lit,opr,lod,sto,cal,int,jmp,jpc);

 

    //--PCODE指令:指令、层差、操作数

    TInstruction = packed record

        IType: TInstructionType;

        Level: 0..CNT_LevelMax;

        Address: 0..CNT_AddressMax;

    end;

    PInstruction = ^TInstruction;

 

    TInstructions = array[0..CNT_Code_MaxLen] of TInstruction;

    PInstructions = ^TInstructions;

 

const

    CNT_CodeNames: array[TInstructionType] of string = (

        ' lit ',

        ' opr ',

        ' lod ',

        ' sto ',

        ' cal ',

        ' int ',

        ' jmp ',

        ' jpc '

        );

 

implementation

 

(*

   lit 0, a  //--load constant a

   opr 0, a  //--execute opr a

   lod l, a  //--load variable l, a

   sto l, a  //--store variable l, a

   cal l, a  //--call procedure a at level l

   int 0, a  //--increment t-register by a

   jmp 0, a  //--jump to a

   jpc 0, a  //--jump conditional to a

*)

 

end.

 

原创粉丝点击