📄 code.h
字号:
/* code.h
* TM code emitting utilities for the TINY compiler
* and interface to the TM machine
*
* Compiler Construction: Principles and Practice
* Kenneth C. Louden
* 编译原理及实践
* (美) Kenneth C. Louden 著
* 冯博琴 冯岚 等译
* 机械工业出版社 IBSN 7-111-07703-2
* 源代码:zwf编辑并修订
* Code Modify:
*/
#ifndef _CODE_H_
#define _CODE_H_
/* pc = program counter */
#define pc 7
/* mp = "memory poniter" points
* to top of memory (for temp storage)
*/
#define mp 6
/* gp = "global pointer" points
* to bottom of memory for (global)
* variabl storage
*/
#define gp 5
/* accumulator */
#define ac 0
/* 2nd accumulator */
#define ac1 1
/* code emitting utilities */
/* Procedure emitRO emits a register-only
* TM instruction
* op = the opcode
* r = target register
* s = 1st source register
* t = 2nd source register
* c = a comment to be printed if TraceCode is TRUE
*/
void emitRO(char *op, int r, int s, int t, char *c);
/* Procedure emitRM emits a register-to-memory
* TM instruction
* op = the opcode
* r = target register
* d = the offset
* s = the base register
* c = a comment to be printed if TraceCode is TRUE
*/
void emitRM(char *op, int r, int d, int s, char *c);
/* Function emitSkip skips "howMany" code
* locations for later backpatch, It also
* return the current code position
*/
int emitSkip(int howMany);
/* Procedure emitBackup backs up to
* loc = a previously skipped location
*/
void emitBackup(int loc);
/* Procedure emitRestore restores the current
* code position to the highest previously
* unemitted position
*/
void emitRestore(void);
/* Procedure emitComment prints a comment line
* with comment c in the code file
*/
void emitComment(char *c);
/* Procedure emitRM_Abs converts an absolute reference
* to a pc-relative reference when emitting a
* register-to-memory TM instruction
* op = the opcode
* r = target register
* a = the absolute location in memory
* c = a comment to be printed if TraceCode is TRUE
*/
void emitRM_Abs(char *op, int r, int a, char *c);
#endif /* _CODE_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -