1 / 17

和你一起看星星 —Forth 简介

和你一起看星星 —Forth 简介. 董博男. Introduction. Forth 是六十年代末期,由 Charles H. Moore 发展出来在天文台使用的电脑自动控制系统及程序设计语言,允许使用者很容易组合系统已有的简单指令,定义成为功能较复杂的高阶指令。由于其结构精简、执行快速、操作方便,广为当代天文学界使用。八十年代以后,有爱用者成立 'Forth Interest Group' 在世界各地推广,并陆续在各类计算机上建立 Forth 系统 及标准的语言。. History. Forth 并不起源于其它已有的程序设计语言

fancy
Download Presentation

和你一起看星星 —Forth 简介

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 和你一起看星星 —Forth简介 董博男 1/17

  2. Introduction • Forth是六十年代末期,由Charles H. Moore发展出来在天文台使用的电脑自动控制系统及程序设计语言,允许使用者很容易组合系统已有的简单指令,定义成为功能较复杂的高阶指令。由于其结构精简、执行快速、操作方便,广为当代天文学界使用。八十年代以后,有爱用者成立'Forth Interest Group'在世界各地推广,并陆续在各类计算机上建立Forth系统及标准的语言。 2/17

  3. History • Forth 并不起源于其它已有的程序设计语言 • 按照 Forth语言的发明人 Charles Moore( Chuck )的说法: 我第一次把各种想法组合成一个整体之后,它在“第三代计算机” IBM1130 上工作得如此有效,以致于我认为它是“第四代语言”,理所当然地应该被称为 FOURTH 。不过,当时的 IBM 计算机只允许 5 个字符的标识符。所以 FOURTH 变成了 Forth ,这是一个非常好的的文字游戏 • 第一个称为 Forth 的程序大约是在 1970 年编写的。第一个完整的实现是 1971 年在一台 PDP-11 上完成的,用于亚利桑那州国家射电天文台的 11 米射电望远镜。 3/17

  4. Feature • 交互式:较早的交互式语言 • 结构化:自顶向下的设计 • 可扩展:everything is word • 开发快,效率高(code)等等 4/17

  5. Almost shortest “Hello World!” • . “Hello World!” 5/17

  6. Word • . : ; • IF LOOP MAX 6/17

  7. So we can… • :Sayhello .”Hello World!; • Sayhello 7/17

  8. Suffix Expression • (1+2)*3 • 1 2 + 3 * • 1 2 + 3 * • . Or • 1 2 + • Dup 3 * • . 8/17

  9. Easy-Grammer • <cond> IF <true statements> • ELSE <false statements> • THEN • 2 1 > IF 2 . • ELSE 1 . • THEN 9/17

  10. 11 1 DO • I . • LOOP • 1 2 3 4 5 6 7 8 9 10 • +LOOP • 2 +LOOP 10/17

  11. Array • : array ( size +++ ) • CREATE • 2* DUP alloc.mem , \ save seg address • , \ save array size in bytes • DOES> • @ ; • 1000 array array.name 11/17

  12. List • : release.seglist ( -- ) • <list.seg> ?DUP • IF • DEALLOC 0= \ DOS INT 21H - AH=49H • IF • 0 !> <list.seg> • ELSE • ABORT" Failed to deallocate <list.seg> " • THEN • THEN ; • : alloc.seglist ( size -- ) • release.seglist • 2* 2* 4 + \ 4 bytes/node + head • alloc.mem \ allocate memory • !> <list.seg> ; \ <list.seg> = base segment address 12/17

  13. Large Dictionary • Every word you defined will be added into a dictionary • Similar applications can use same dictionary • Less exploiting time possible 13/17

  14. Instance • 10! • 1 • 11 1 DO • I 2dup * • LOOP • . 14/17

  15. Summary • Control system && !data processing • Technical Language && !popular • Core: word & stack 15/17

  16. Reference • Wikipedia • Baike • Forth语言教程 • 4th 16/17

  17. THANKS FOR LISTENING 17/17

More Related