51单片机-PASCAL语言实例:认识重要单元SYSTEM.PAS

// system.pas 单元开发时不用引用,这是编译器核心包含的
// 该单元定义了8051单片机所有资源
// 熟悉该单元是对使用TRUBO51 开发程序的基础
Unit System;

Interface

Const

  // 定义常用控制字符常量,其值为 ASCII 码
  BELL = $07;
  BS   = $08;
  TAB  = $09;
  LF   = $0A;
  CR   = $0D;
  EOF  = $1A;
  ESC  = $1B;
  DEL  = $7F;

  // 定义常用中断 查询号
  External0 = $0003;     // 外部中断 0
  Timer0    = $000B;     //  定时器0
  External1 = $0013;     //
  Timer1    = $001B;     //
  Serial    = $0023;     //  串口

Type TDeviceWriteProcedure = Procedure;

     TDeviceReadFunction = Function: Char;

     TFileRecord = Record
                     WriteProcedure: TDeviceWriteProcedure;
                     ReadFunction:   TDeviceReadFunction;
                   end;


Var

// Rn registers at absolute address (bank dependent) - Must be declared before 8051 SFR
// Registers ARn SHOULD NOT be used in system unit since system procedures could be called
// from any procedure using any register bank

  AR0:      Byte absolute 0;
  AR1:      Byte absolute 1;
  AR2:      Byte absolute 2;
  AR3:      Byte absolute 3;
  AR4:      Byte absolute 4;
  AR5:      Byte absolute 5;
  AR6:      Byte absolute 6;
  AR7:      Byte absolute 7;

 {
    8051 SFR }

  P0:       Byte absolute $80; Volatile;
  SP:       Byte absolute $81; Volatile;
  DPL:      Byte absolute $82;
  DPH:      Byte absolute $83;
  PCON:     Byte absolute $87; Volatile;
  TCON
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是 Pascal 程序设计语言的文法实例: ``` <program> ::= program <identifier> ; <block> . <block> ::= <declaration-part> <statement-part> <declaration-part> ::= <label-declaration-part> <constant-definition-part> <type-definition-part> <variable-declaration-part> <procedure-and-function-declaration-part> <label-declaration-part> ::= label <label> { , <label> } ; <label> ::= <unsigned-integer> <constant-definition-part> ::= const <constant-definition> { ; <constant-definition> } ; <constant-definition> ::= <identifier> = <constant> <constant> ::= <unsigned-number> | <sign> <unsigned-number> | <string> | <identifier> <type-definition-part> ::= type <type-definition> { ; <type-definition> } ; <type-definition> ::= <identifier> = <type> <type> ::= <simple-type> | <structured-type> | <pointer-type> <simple-type> ::= <scalar-type> | <subrange-type> | <enumerated-type> | <set-type> <scalar-type> ::= <identifier> <subrange-type> ::= <constant> .. <constant> <enumerated-type> ::= ( <identifier> { , <identifier> } ) <set-type> ::= set of <base-type> <base-type> ::= <scalar-type> <structured-type> ::= <array-type> | <record-type> <array-type> ::= array [ <index-range> { , <index-range> } ] of <component-type> <index-range> ::= <simple-type> <component-type> ::= <type> <record-type> ::= record <field-list> end <field-list> ::= <fixed-part> | <fixed-part> ; <variant-part> | <variant-part> <fixed-part> ::= <record-section> { ; <record-section> } ; <variant-part> ::= case <tag-field> of <variant> { ; <variant> } ; [ else <field-list> ] end ; <tag-field> ::= <identifier> : <type> <variant> ::= <variant-selector> : ( <field-list> ) <variant-selector> ::= <constant> .. <constant> | <identifier> <variable-declaration-part> ::= var <variable-declaration> { ; <variable-declaration> } ; <variable-declaration> ::= <identifier> { , <identifier> } : <type> <procedure-and-function-declaration-part> ::= <procedure-declaration> | <function-declaration> | <procedure-declaration> ; <function-declaration> <procedure-declaration> ::= procedure <identifier> ; [ <formal-parameter-list> ] ; <block> ; <function-declaration> ::= function <identifier> ; [ <formal-parameter-list> ] : <type> ; <block> ; <formal-parameter-list> ::= ( [ <parameter-group> { ; <parameter-group> } ] ) <parameter-group> ::= <identifier-list> : <parameter-type> <identifier-list> ::= <identifier> { , <identifier> } <parameter-type> ::= <simple-type> | <structured-type> | <identifier> <statement-part> ::= <compound-statement> <compound-statement> ::= begin <statement> { ; <statement> } end <statement> ::= <simple-statement> | <structured-statement> <simple-statement> ::= <assignment-statement> | <procedure-call-statement> | <goto-statement> | <empty-statement> <assignment-statement> ::= <variable-access> := <expression> <procedure-call-statement> ::= <identifier> [ <actual-parameter-list> ] <actual-parameter-list> ::= <expression> { , <expression> } <goto-statement> ::= goto <label> <empty-statement> ::= <structured-statement> ::= <compound-statement> | <conditional-statement> | <repetitive-statement> | <with-statement> <conditional-statement> ::= if <expression> then <statement> [ else <statement> ] <repetitive-statement> ::= <while-statement> | <repeat-statement> | <for-statement> <while-statement> ::= while <expression> do <statement> <repeat-statement> ::= repeat <statement> { ; <statement> } until <expression> <for-statement> ::= for <control-variable> := <for-list> do <statement> <control-variable> ::= <identifier> <for-list> ::= <initial-value> [ to | downto ] <final-value> <initial-value> ::= <expression> <final-value> ::= <expression> <with-statement> ::= with <record-variable-list> do <statement> <record-variable-list> ::= <variable-access> { , <variable-access> } <expression> ::= <simple-expression> | <simple-expression> <relational-operator> <simple-expression> <relational-operator> ::= = | <> | < | <= | >= | > <simple-expression> ::= <term> | <sign> <term> | <simple-expression> <adding-operator> <term> <sign> ::= + | - <adding-operator> ::= + | - | or <term> ::= <factor> | <term> <multiplying-operator> <factor> <multiplying-operator> ::= * | / | div | mod | and <factor> ::= <variable-access> | <unsigned-constant> | ( <expression> ) | <function-designator> <variable-access> ::= <variable> { <indexed-selector> | <field-selector> } <variable> ::= <identifier> <indexed-selector> ::= [ <expression> { , <expression> } ] <field-selector> ::= . <identifier> <unsigned-constant> ::= <unsigned-number> | <string> | <constant-identifier> <function-designator> ::= <identifier> [ <actual-parameter-list> ] <string> ::= '<character> { <character> }' <constant-identifier> ::= <identifier> ``` 注意:这只是 Pascal 的一个简单实现,实际上 Pascal 的语法非常复杂,因此这里只提供了一部分重要的规则。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值