一门很有用的编程语言:C--

仅仅用于软件推荐,不适合发求软件或软件使用问题方面的贴子
头像
stlxv
论坛版主
帖子: 8275
注册时间: 2006-05-03 0:39
来自: المريخ

一门很有用的编程语言:C--

#1

帖子 stlxv » 2008-01-10 13:19

官方网站:http://www.cminusminus.org
1 Introduction
C-- is a compiler-target language. The idea is that a compiler for a high-level language translates programs
into into C--, leaving the C-- compiler to generate native code. C--’s major goals are these:
• C-- encapsulates compilation techniques that are well understood, but difficult to implement. Such
techniques include instruction selection, register allocation, instruction scheduling, and optimization
of imperative code with loops.
• C-- is a language, rather than a library (such as gcc’s RTL back end). As such, it has a concrete syntax
that can be read by people, and a semantics that is independent of any particular implementation.
• C-- is a portable assembly language. It is, by design, as low-level as possible while still concealing
details of the particular machine architecture.
• C-- is independent of both source programming language and target architecture. Its design accom-
modates a variety of source languages and leaves room for back-end optimization, all without upcalls
from the back end to the front end.
• C-- is efficient—or at least admits efficient implementation. So C-- provides almost as much flexibility
and performance (assuming a good C-- compiler) as a custom code generator.
A client of C-- is divided into two parts. The front-end compiler generates programs written in the C--
language, which the C-- compiler translates into efficient machine code. This code interoperates with the
front-end run-time system, which implements such services as garbage collection, exception dispatch, thread
scheduling, and so on. The front-end run-time system relies on mechanisms provided by the C-- run-time
system; they interact through the C-- run-time interface. This document describes the C-- language and
run-time interface. It is intended for authors who wish to write clients of the C-- system.
The C-- team has prepared some demonstration front ends that may help you learn to use C--.
• Paul Govereau’s tigerc compiler includes a compiler for Tiger (the language of Andrew Appel’s
compiler text) as well as a small run-time system with garbage collector. The tigerc compiler is
written in Objective Caml.
• Norman Ramsey’s lcc back end works with lcc to translate C into C--. It is written in C.
• Reuben Olinsky’s interpreter, which is packaged with the Quick C-- sources, includes sample run-time
clients for garbage collection and exception dispatch.
All this code is available through the C-- web site at http://www.cminusminus.org.
1.1 What C-- is not
C-- has some important non-goals:
• C-- is not an execution platform, such as the Java Virtual Machine or the .NET Common Language
Runtime. These virtual machines are extremely high-level compared to C--. Each provides a rich type
system, garbage collector, class loader, just-in-time compiler, byte-code verifier, exception-dispatch
mechanism, debugger, massive libraries, and much more besides. These may be good things, but
they clearly involve much more than encapsulating code-generation technology, and depending on your
language model, they may impose a significant penalty in both space and time.
6
• C-- is not “write-once, run-anywhere”. It conceals most architecture-specific details, such as the
number of registers, but it exposes some. In particular, C-- exposes the word size, byte order, and
alignment properties of the target architecture, for two reasons. First, to hide these details would
require introducing a great deal of complexity, inefficiency, or both—especially when the front-end
compiler needs to control the representation of its high-level data types. Second, these details are easy
to handle in a front-end compiler. Indeed, a compiler may benefit, because it can do address arithmetic
using integers instead of symbolic constants such as FloatSize and IntSize.
一个C--的例子:
图片
附件
c--.sample.png
man2.pdf.zip
The C-- Language Specification
Version 2.0
( CVS Revision 1.128 )
(308.6 KiB) 已下载 165 次
PHP是最好的语言!不服来战!
头像
woaiwojia
帖子: 1355
注册时间: 2007-09-10 20:20
系统: Debian
来自: 南京

#2

帖子 woaiwojia » 2008-01-10 14:23

呵呵,学习的好地方
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

#3

帖子 bones7456 » 2008-01-10 14:51

恩,貌似不错啊...
关注我的blog: ε==3
头像
shellex
帖子: 2180
注册时间: 2007-02-18 19:33
系统: OSX
来自: lyric.im
联系:

#4

帖子 shellex » 2008-01-10 15:47

存在的意义是什么?
C--的定位有点窄,而且感觉不是很有必要。
头像
yangyuruc
帖子: 385
注册时间: 2007-09-26 17:23
来自: 云南-香格里拉

#5

帖子 yangyuruc » 2008-01-11 21:57

学不完了哈
njayong080108
帖子: 25
注册时间: 2008-01-08 10:28
来自: 江苏南京

#6

帖子 njayong080108 » 2008-01-12 0:13

一件玩具而已。。。
身在L营心在W
头像
蓝蓝
帖子: 953
注册时间: 2007-06-09 9:19
来自: 上海

#7

帖子 蓝蓝 » 2008-01-12 6:58

想学 而不敢学~怕被套进去- -!
wuxb
帖子: 43
注册时间: 2007-03-13 14:08

#8

帖子 wuxb » 2008-01-12 10:46

想极力贴近汇编级,还能翻译其他的语言,着实不知其所云,这些应该都是编译器做的事情吧,写个把java编译成机器码的编译器未尝不可。只要有功夫去用c之类的实现java的庞大的类库
头像
ljj_jjl2008
论坛版主
帖子: 14255
注册时间: 2007-09-16 8:29

#9

帖子 ljj_jjl2008 » 2008-01-12 11:04

又是一堆英文,我还是看不懂,我再哭!!
:em21 :em21 :em21 :em21 :em20 :em20 :em20 :em20 :em55 :em55 :em55 :em55
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#10

帖子 eexpress » 2008-01-12 13:09

这不好。像汇编了。估计不比我的汇编里面定义的宏高级。
我要搞c--的。打倒这个。
● 鸣学
头像
stlxv
论坛版主
帖子: 8275
注册时间: 2006-05-03 0:39
来自: المريخ

#11

帖子 stlxv » 2008-01-13 2:03

eexpress 写了:这不好。像汇编了。估计不比我的汇编里面定义的宏高级。
我要搞c--的。打倒这个。
官方网站介绍说这其实就是一门可移植的汇编语言
PHP是最好的语言!不服来战!
头像
forrid
帖子: 659
注册时间: 2007-04-23 17:40

#12

帖子 forrid » 2008-01-13 14:58

有汇编就足够了,搞那么多飞机。

吾生也有涯,而知也无涯,以有涯随无涯,SB啊~~~~~~~~~~
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

我以前的,也简单。

#13

帖子 eexpress » 2008-01-13 15:06

代码: 全选

	Cmp	Temp
	Beq	_Cpyid		;校验和正确
	Bra	_Errid
_Newid	Lcall	Getsum,#Nc,#8	;保存校验和到EE
	Sta	Temp
	Sta	Temp+1
	Lcall	E.Write,#Ee_Nc_Sum,#Temp,#2
_Cpyid	Lcall	Copy,#Nc,#Ucode,#8	;第一次读入编号
Chkend	Bclr	Error,Status
	Rts
● 鸣学
头像
ghosTM55
帖子: 86
注册时间: 2007-02-14 18:05
来自: 上海
联系:

#14

帖子 ghosTM55 » 2008-01-17 17:14

.......................
什么时候有c+-
peigen
帖子: 234
注册时间: 2006-10-12 21:31

#15

帖子 peigen » 2008-01-23 10:56

减减,汗~~~

这帮死老外
Peigen废话
http://peigen.info
回复