Dynamic DX-ARC-SWB User's Guide

Browse online or download User's Guide for Network switches Dynamic DX-ARC-SWB. Dynamic DX-ARC-SWB User guide User Manual

  • Download
  • Add to my manuals
  • Print
  • Page
    / 238
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 0
The BCPL Cintsys and Cintpos
User Guide
by
Martin Richards
http://www.cl.cam.ac.uk/users/mr10/
Computer Laboratory
University of Cambridge
Revision date: Wed Jan 14 10:46:33 GMT 2015
Abstract
BCPL is a simple systems programming language with a small fast compiler which
is easily ported to new machines. The language was first implemented in 1967
and has been in continuous use since then. It is a typeless and provides machine
independent pointer arithmeti c allowing a simple way to represent vectors and
structures. BCPL functions are recursive a n d variadic but, like C, do not allow
dynamic free variables, and so can be represented by just their entry addresses.
There is no built-in garbage collector and all input-output is done using library
calls.
This document describes both the si n g le threaded BCPL Cintco de System
(called Cintsys) and the Cintcode version of t he Tripos portable operating system
(called Cintpos). It gives a definition of the language including an extended
version (using the xbcpl compiler) containing such features as floatin g point and
the op - becomes operator. The m anual also describes the standard library and
running environment. The native code version of the system based on Sial and t h e
Cintpos portable operating system are also descri bed. Inst al l at i on instructions
are included. Since May 2013, the standard BCPL distribution supports both
32 and 64 bit Cintcode versions. Since August 2014, standard Cintcode BCPL
includes floati ng point constants and operators.
Keywords
Systems programming language, Typeless language, BCPL, Cintcode, Corou-
tines, Cintpos.
Page view 0
1 2 3 4 5 6 ... 237 238

Summary of Contents

Page 1 - User Guide

The BCPL Cintsys and CintposUser GuidebyMartin [email protected]://www.cl.cam.ac.uk/users/mr10/Computer LaboratoryUniversity of CambridgeRev

Page 2

2 CHAPTER 1. THE SYSTEM OVERVIEWLET start() = VALOFis the heading for the declaration of the function start which, by convention, isthe first function

Page 3 - Contents

92 CHAPTER 3. THE LIBRARYAND messcofn(node) = VALOF{ qitem(node) // Put the message on the work queue for this node{ // Start processing the first mes

Page 4

3.7. COROUTINE EXAMPLES 93writef("*nCosim entered*n*n")writef("Network nodes: %n*n", nodes)writef("Stop time: %n*n", sto

Page 5

94 CHAPTER 3. THE LIBRARY3.8 The Gr a phi cs Libra r yThe graphics library provides facilities for drawing pictures and outputi ng them to file.This li

Page 6

3.8. THE GRAPHICS LIBRARY 953.8.3 The Graphics Functionsopengraphics(xsize, ysize) CIN:y, POS:y, NAT:yThis function opens the graphic s library. It al

Page 7

96 CHAPTER 3. THE LIBRARYfillrect(x0, y0, x1, y1) CIN:y, POS:y, NAT:yThis function dr aws the rectangle (x0, y0), (x 1, y0), ((x1, y1), (x1, y0) filled

Page 8

3.10. THE GL GRAPHICS LIBRARY 97GET "libhdr"MANIFEST { g_sdlbase=nnn } // Only used if the default setting of 450 in// libhdr is not suitabl

Page 9 - The System Overview

98 CHAPTER 3. THE LIBRARY3.11 The Sound Lib ra r yThis library is under developmentThe sound library uses the sys(Syssound,...) fun ct i ons to provid

Page 10

Chapter 4The Command LanguageThe Command Language Interpreter (CLI) is a simple interactive interface between theuser an d the system. It loads and ex

Page 11

100 CHAPTER 4. THE COMMAND LANGUAGEno return link has been stored i nto the stack, this call of start must not attemptto return in the normal way; how

Page 12

4.2. BOOTSTRAPPING CINTPOS 101hold the dumped Cintcode registers. A result of zero, signifying successful completion,causes execution of Cintsys to te

Page 13

1.1. A CINTSYS CONSOLE SESSION 38: DATAW 0x6174730B12: DATAW 0x2020747216: DATAW 0x20202020// Entry to: start20: L1:20: L121: SP322: L4:22: LP323: LF

Page 14

102 CHAPTER 4. THE COMMAND LANGUAGEAll console input and output within BOOT and the standalone debugger is doneusing the standalone version of rdch an

Page 15

4.2. BOOTSTRAPPING CINTPOS 103startroot is entered by the recursive call of interpret from BOOT with a newstack and a different global vector from that

Page 16

104 CHAPTER 4. THE COMMAND LANGUAGEIt always starts execution at the start of the function irqrtn wit h Cintcode registerST set to 3 to indicate that

Page 17

4.3. COMMANDS 105or global vector. There are thus 16 posible states a task can have of which only sixindicate that it is runnable, they are as follows

Page 18

106 CHAPTER 4. THE COMMAND LANGUAGEadjclock OFFSET CIN:y, POS:y, NAT:yThe syntax of the OFFSET argument is [-][h][:m], that is: an optional minus sign

Page 19 - The BCPL Language

4.3. COMMANDS 107causes a line to be output by the com pi l e r for each non local identifier occurring in t heprogram. A typical such line is as follo

Page 20 - 2.1 Language Overv i ew

108 CHAPTER 4. THE COMMAND LANGUAGEThe HARD options causes both syntax and translation phase errors to callabort(100). This is useful in commands such

Page 21 - 2.1.3 Conditional Compilation

4.3. COMMANDS 109bgpm FROM,TO/K,UPB/K CIN:y, POS:y, NAT:yThis is an implementation of Chr i s toph er Strachey’s GPM macrogenerator. It takesinput fro

Page 22 - 2.2 Expressions

110 CHAPTER 4. THE COMMAND LANGUAGEbin-hex FROM/A,TO/K CIN:y, POS:y, NAT:yThis outputs the bytes of the FROM in hex. For instance, if the file xxx wasA

Page 23

4.3. COMMANDS 111% Comment - skip all characters unti l a non white space ch ar-acter on a later input line.[Start of a new macro call.!Argument separ

Page 24

4 CHAPTER 1. THE SYSTEM OVERVIEWthe debugger. The data word at location 4 holds a special bit pattern indicatingthe presence of a func ti o n name pla

Page 25

112 CHAPTER 4. THE COMMAND LANGUAGEbounce CIN:n, POS:y, NAT:nThis command is part of the bounce demonstration that is only available underCintpos. It

Page 26 - 2.2.4 Method Calls

4.3. COMMANDS 113casech FROM/A,TO/A,DICT/K,U/S,L/S,A/S CIN:y, POS:y, NAT:yThis command systematically converts all reserved words of a BCPL program to

Page 27

114 CHAPTER 4. THE COMMAND LANGUAGEwise it is sent to the standard output stream. The MSECS options causes the time tohave higher precision. Typical o

Page 28 - 2.2.7 Boolean Evaluati on

4.3. COMMANDS 115endcli CIN:n, POS:y, NAT:nThis Cintpos command causes a CLI task to commit suicide.enlarge /A,TO/K CIN:y, POS:y, NAT:yThis command ou

Page 29 - 2.2.9 Expression Precedence

116 CHAPTER 4. THE COMMAND LANGUAGEhexdump FROM/A,N,P,RL/K,RLB/K,TO/K CIN:y, POS:y, NAT:yThis program dumps a file specified by FROM in a combination of

Page 30 - 2.3 Commands

4.3. COMMANDS 117input TO/A,TERM/K CIN:y, POS:y, NAT:yThis command will copy text from the current input sending it the the file specifiedby the AS argu

Page 31 - 2.3.3 Conditional Commands

118 CHAPTER 4. THE COMMAND LANGUAGEkeyword. BLOCKS outputs a list of all blocks whether allocated or free in the blockchain used by getvec. CODE outpu

Page 32 - 2.3.5 SWITCHON command

4.3. COMMANDS 119mkjunk NAME,SIZE/N CIN:y, POS:y, NAT:yThis creates a file as described in the mkdata command and then tests randomaccess to this file b

Page 33 - 2.3.7 Compound Commands

120 CHAPTER 4. THE COMMAND LANGUAGEprmcode CIN:y, POS:y, NAT:yThis command converts an MCODE (intermediate code for MCPL) file specified byFROM to a mor

Page 34 - 2.4 Declarations

4.3. COMMANDS 121This is command differs from fail since it terminates the execution of a completecommand-command while fail allows a command-command t

Page 35 - 2.4.4 Static Declarations

1.1. A CINTSYS CONSOLE SESSION 5This first loads the entry point of clihook (held in global va r ia b l e 4) and sets(b1) a breakpoint numbered 1 at th

Page 36 - 2.4.5 LET Declarations

122 CHAPTER 4. THE COMMAND LANGUAGEThe COUNT argument allows the user to specify how many Cintcode instr uct i ons toobey for each raster line. The de

Page 37

4.3. COMMANDS 123SYNTRNCGGET StreamDeclaration VectorCompiled Code BufferCode OutputStackInput streamSYN Parse Tree TRN Parse Tree CG Parse TreeOCODE

Page 38 - 2.4.9 Dynamic Free Variables

124 CHAPTER 4. THE COMMAND LANGUAGECintsys and Cintpos logical variables are held in a linked list held in the rootnodeelement rtn envlist. If both NA

Page 39 - 2.5 Separate Compilation

4.3. COMMANDS 125stats TO/K,PROFILE/S,ANALYSIS/S CIN:y, POS:y, NAT:yThis command controls the tallying facili ty which counts the ex e cut i on of i n

Page 40 - 2.6 The objline1 Feature

126 CHAPTER 4. THE COMMAND LANGUAGEtcpdump CIN:n, POS:y, NAT:nThis outputs the list of Cintpos TCP/IP devices that c ur r e ntly exist. The listinclud

Page 41 - The Library

4.3. COMMANDS 127vecstats CIN:y, POS:y, NAT:yThis command output information about blocks of Cintcode memory that are cur-rently allocated. Typical ou

Page 42 - 34 CHAPTER 3. THE LIBRARY

128 CHAPTER 4. THE COMMAND LANGUAGEresulting file. Either FILE or LIST or both must be supplied. If given FILE is the firstfilename to be encoded followe

Page 43 - 3.1. MANIFEST CONSTANTS 35

4.4. CLI.B AND CLI INIT.B 129clifaillevel CIN:y, POS:y, NAT:yclidata CIN:y, POS:y, NAT:yThis holds CLI data dependant on the context in which the CLI

Page 44 - 36 CHAPTER 3. THE LIBRARY

130 CHAPTER 4. THE COMMAND LANGUAGEclibit noprompt Do not output prompts even when not in a command-command.clibiteofdel Delete this task when EOF is

Page 45 - 3.1. MANIFEST CONSTANTS 37

Chapter 5Console Input and OutputWhen cintsys or cintpos is started a stream i s opened to recei ve input from standardinput which is normally the key

Page 46 - 38 CHAPTER 3. THE LIBRARY

6 CHAPTER 1. THE SYSTEM OVERVIEW* \ A= 3 B= 1 46279: LF 46332* \ A= fact B= 3 46281: K9* \ A= 3 B= 3 46332: JNE0 46336* \ A= 3 B= 3 46336: LM1* \ A= -

Page 47 - 3.1. MANIFEST CONSTANTS 39

132 CHAPTER 5. CONSOLE INPUT AND OUTPUT5.2 Cintpos console strea m sUnder Cintpos interaction with the console is somewhat more compli c at ed since C

Page 48 - 40 CHAPTER 3. THE LIBRARY

5.2. CINTPOS CONSOLE STREAMS 133Sequence Purpose@A Set flag 1 in the currently selected task@BSet flag 2 in the currently selected task@CSet flag 3 in th

Page 49 - 3.1. MANIFEST CONSTANTS 41

134 CHAPTER 5. CONSOLE INPUT AND OUTPUT5.2.2 Exclusive InputThe console handler can be set to exclusive input mode by the call:sendpkt(notinuse, conso

Page 50 - 42 CHAPTER 3. THE LIBRARY

Chapter 6Cintpos De vi cesCintpos allows asynchronous communication with peripheral devices using the qpktand taskwait functi ons. If the pkt id field

Page 51 - 3.2 Global Vari a bl es

136 CHAPTER 6. CINTPOS DEVICES6.0.5 The Keyboard DeviceThis device has i d entifier -2 and is currently not treated specially, and so it has a DCB,and

Page 52 - 3.3 Global Functi on s

137Tcprcvbufsz arg1: sock arg2: szThis sets the receive buffer size of the given socket to size bytes. A zero resu l tindicates success.Tcpbind arg1: s

Page 53 - 3.3. GLOBAL FUNCTIONS 45

138 CHAPTER 6. CINTPOS DEVICESa specified timeout p er i od. If timeout is greater than zero it i s the timeout period inmilli-seconds, if it is zero t

Page 54 - 46 CHAPTER 3. THE LIBRARY

Chapter 7The DebuggerBoth Cintsys and Cintpos have interactive debuggers but these are slightly differentand so wi l l be described separately.7.1 The

Page 55 - Figure 3.1: A coroutine stack

140 CHAPTER 7. THE DEBUGGER* ?? Print list of debug commandsGn Pn Rn Vn VariablesG P R V Pointersn #b101 #o377 #x7FF ’c Constants*e /e %e +e -e |e &am

Page 56 - 48 CHAPTER 3. THE LIBRARY

7.1. THE CINTSYS DEBUGGER 141* 10sv1 11sv2 Put 10 and 11 in variables 1 and 2* vt5 Display the first 5 variablesV 0: 0 10 11 0 0** v1*50+v2= 511 A calc

Page 57 - 3.3. GLOBAL FUNCTIONS 49

1.2. A CINTPOS CONSOLE SESSION 7This shows that the total size of th e compiler is 34,576 bytes and t h at it can becompiled (on a 1.6GHz Pentium mach

Page 58 - 50 CHAPTER 3. THE LIBRARY

142 CHAPTER 7. THE DEBUGGERAt this point the fi rs t instruction of rdargs is about to be executed. Its return addressis in P1, so a breakpoint can be

Page 59 - 3.3. GLOBAL FUNCTIONS 51

7.2. THE CINTPOS DEBUGGER 143Command Effect. Select current coroutine, Display next stack frame; Select parent coroutine[ Select first coroutine] Select

Page 60 - 52 CHAPTER 3. THE LIBRARY

144 CHAPTER 7. THE DEBUGGERclock device) interfere with single ste ppi ng of Cintcode instructions, the K command isprovided to turn clock interrupts

Page 61 - 3.3. GLOBAL FUNCTIONS 53

Chapter 8The Design of OCODEBCPL was designed to be a portab l e language wit h a compiler that is easily transfe r r edfrom machine to machine. To he

Page 62 - 54 CHAPTER 3. THE LIBRARY

146 CHAPTER 8. THE DESIGN OF OCODEexample, if the file test.b is the following:GET "libhdr"LET start() BE { LET a, b, c = 1, 0, -1writef(&quo

Page 63 - 3.3. GLOBAL FUNCTIONS 55

8.3. LOADING AND STORING VALUES 147to S in the description of OCODE s tat em ents should be regarded as a specification ofS for the subsequent statemen

Page 64 - 56 CHAPTER 3. THE LIBRARY

148 CHAPTER 8. THE DESIGN OF OCODEStatement MeaningLF Ln P!S := entry point Ln; S := S+1LN nP!S := n; S := S+1FNUM m eP!S := <make float>(m, e);

Page 65 - 3.3. GLOBAL FUNCTIONS 57

8.5. EXPRESSION OPERATORS 149but if op is non zero it repr es ents and assignment operator (assop) and the statementis equivalent to:SLCT len:sh:0 OF

Page 66

150 CHAPTER 8. THE DESIGN OF OCODEStatement MeaningGETBYTE S := S-1; P!(S-1) := P!(S-1) % P!SMULTS := S-1; P!(S-1) := P!(S-1) * P!SFMULTS := S-1; P!(S

Page 67

8.6. FUNCTIONS AND ROUTINES 151ENTRY Li n C1. . . CnSAVE sbody of function or routineENDPROCLi is the label alloc ate d for the entry point. As a debu

Page 68 - 60 CHAPTER 3. THE LIBRARY

8 CHAPTER 1. THE SYSTEM OVERVIEWThere is a benchmark program cal l ed bench100.b which can be compiled andrun as follows.0.000 1> c bc bench100bcpl

Page 69 - 3.3. GLOBAL FUNCTIONS 61

152 CHAPTER 8. THE DESIGN OF OCODEE1 E2 En ESPOld stack frame New stack framekFigure 8.4: The moment of calling E(E1,E2,...En)8.7 ControlThe statement

Page 70 - 62 CHAPTER 3. THE LIBRARY

8.9. DISCUSSION 153Static variables and tables are allocated space in the program area using statementsof the form ITEMN n, where n is the ini ti al v

Page 71 - 3.3. GLOBAL FUNCTIONS 63

154 CHAPTER 8. THE DESIGN OF OCODE

Page 72 - 64 CHAPTER 3. THE LIBRARY

Chapter 9The Design of CintcodeThe original version of Cintcode was a byte stream interpretive code designed to beboth compact and capable of efficient

Page 73 - 3.3. GLOBAL FUNCTIONS 65

156 CHAPTER 9. THE DESIGN OF CINTCODEThe registers A and B are used for expression evaluation, and C is used in in bytesubscription. P and G are point

Page 74 - 66 CHAPTER 3. THE LIBRARY

9.1. DESIGNING FOR COMPACTNESS 157OperationExecutions Static countLoading a local var ia b l e 3777408 1479Updating a local variable1965885 1098Loadin

Page 75 - 3.3. GLOBAL FUNCTIONS 67

158 CHAPTER 9. THE DESIGN OF CINTCODELGLG1LGHbhB := A; A := G!(b+256)B := A; A := G!bB := A; A := G!hbHere, b and h are unsigned 8 and 16 bit values,

Page 76 - 68 CHAPTER 3. THE LIBRARY

9.2. THE CINTCODE INSTRUCTION SET 159command. The use of a 16 bit resol v i ng word places a slight restriction on the maximumsize of relative referen

Page 77 - 3.3. GLOBAL FUNCTIONS 69

160 CHAPTER 9. THE DESIGN OF CINTCODE0 32 64 96 128 160 192 2240 - K LLP L LP SP AP A1 FLTOP KH LLPH LH LPH SPH APH AH2 BRK KW LLPW LW LPW SPW APW AW3

Page 78 - 70 CHAPTER 3. THE LIBRARY

9.2. THE CINTCODE INSTRUCTION SET 161compile code with the opp osi t e endianess to that of the machine on which the compileris running, see the descr

Page 79 - 3.3. GLOBAL FUNCTIONS 71

1.2. A CINTPOS CONSOLE SESSION 9Notice that the root CLI (task 1) completes the execution of the run com m a n dand issues a prompt (0.000 1>) befo

Page 80 - 72 CHAPTER 3. THE LIBRARY

162 CHAPTER 9. THE DESIGN OF CINTCODELLP b B := A; A := @P!bLLPH h B := A; A := @P!hLLPW w B := A; A := @P!wLLG b B := A; A := @G!bLLG1 b B := A; A :=

Page 81 - 3.3. GLOBAL FUNCTIONS 73

9.2. THE CINTCODE INSTRUCTION SET 163These in st ru ct i ons provide for all the normal arithmetic and bit pattern dyadic opera-tors. The instructions

Page 82 - 74 CHAPTER 3. THE LIBRARY

164 CHAPTER 9. THE DESIGN OF CINTCODE9.2.6 Indirect AssignmentPBYT B%A := CXPBYT A%B := CST A!0 := BSTn 1 ≤ n ≤ 3 A!n := BST0Pn 3 ≤ n ≤ 4 P!n!0 := AST

Page 83 - 3.3. GLOBAL FUNCTIONS 75

9.2. THE CINTCODE INSTRUCTION SET 165Kn 3 ≤ n ≤ 11K bKH hKW wThese instructi ons call the function or routine whose e ntry point is in A and whose firs

Page 84 - 76 CHAPTER 3. THE LIBRARY

166 CHAPTER 9. THE DESIGN OF CINTCODE9.2.8 Flow of Co ntrol and RelationsThe following instruction s are used in the compilation of conditional and un

Page 85 - 3.3. GLOBAL FUNCTIONS 77

9.2. THE CINTCODE INSTRUCTION SET 167dlab to jump to the default label. See Section 9.1.3 for details on how resolving halfwords are interpreted.SWB fi

Page 86 - 78 CHAPTER 3. THE LIBRARY

168 CHAPTER 9. THE DESIGN OF CINTCODEThese instructions are used move val ue s between register A, B and C.NOPThis instruction has no effect.SYSThis in

Page 87

9.2. THE CINTCODE INSTRUCTION SET 1699.2.11 Floating-point InstructionsFloating-point operations other than those performed by SELST are provided by t

Page 88 - 3.3.1 Streams

170 CHAPTER 9. THE DESIGN OF CINTCODE9.2.14 Corruption of BTo i mpr ove the efficiency of some hand writte n machine code interpreters, the followingins

Page 89 - 3.3.2 The Filing System

Chapter 10The Design of SialSial is an internal intermediate assembly language designed for BCPL. The first versionwas called Cial ( Compac t Internal

Page 90 - 82 CHAPTER 3. THE LIBRARY

10 CHAPTER 1. THE SYSTEM OVERVIEW}task, count := 7, 1_000_000IF argv!0 DO task := !argv!0IF argv!1 DO count := !argv!1pkt!0, pkt!1, pkt!2 := notinuse,

Page 91 - 3.6 Environment Variables

172 CHAPTER 10. THE DESIGN OF SIALThis can be converted into something slightly more readable using the command:sial-sasm hello.sial to * giving: This

Page 92 - 3.7 Coroutine examples

10.1. THE SIAL SPECIFICATION 173call *%eax# L K0xorl %ebx,%ebx# RTNmovl 4(%ebp),%eaxmovl 0(%ebp),%ebpjmp *%eax# STRING M9001 K6 C72 C101 C108 C108 C11

Page 93 - 3.7.2 Hamming’s Problem

174 CHAPTER 10. THE DESIGN OF SIALF An opcode or dir e c ti veP A stack offset, 0 to #xFFFFFFG A global variable number, 0 to 65535K A 24-bit unsi gned

Page 94 - 86 CHAPTER 3. THE LIBRARY

10.1. THE SIAL SPECIFICATION 175lkp Kk Pn a := P!n!klkg Kk Gn a := G!n!krv a := ! arvp Pn a := P!n!arvk Kn a := a!kst !a := bstp Pn P!n!a := bstk Kn a

Page 95 - 3.7. COROUTINE EXAMPLES 87

176 CHAPTER 10. THE DESIGN OF SIALlsh a := b << arsh a := b >> aand a := b & aor a := b | axor a := b XOR aeqv a := b EQV agbyt a := b

Page 96 - 88 CHAPTER 3. THE LIBRARY

10.1. THE SIAL SPECIFICATION 177brk Breakpoint instructionnop No operationchgco Change coroutinemdiv a := muldiv(P!3, P!4, P!5)sys System functionsect

Page 97 - 3.7. COROUTINE EXAMPLES 89

178 CHAPTER 10. THE DESIGN OF SIALjfeq Ln Jump to Ln if b #= a; b := ?jfne Ln Jump to Ln if b #~= a; b := ?jfls Ln Jump to Ln if b #< a; b := ?jfgr

Page 98 - 90 CHAPTER 3. THE LIBRARY

10.1. THE SIAL SPECIFICATION 179C41 C32 C61 C32 C37 C105 C52 C10F113 K4 C102 C97 C99 C116F111 L2F92 L5F11 K1F77F111 L5F12 K1F16 P3F69F9 L2F31 P4F73 P3

Page 99 - 3.7. COROUTINE EXAMPLES 91

180 CHAPTER 10. THE DESIGN OF SIALLF L2K P4ATBLP P3MULRTNGLOBAL K1G1 L1G94MODEND10.2 The sial-386 TranslatorThe source of an unoptimi se d Sial transl

Page 100 - 92 CHAPTER 3. THE LIBRARY

10.2. THE SIAL-386 TRANSLATOR 181# SP P9movl %ebx,36(%ebp)# LP P3movl 12(%ebp),%ebx# SP P8movl %ebx,32(%ebp)# LSTR M1leal MA1,%ebxshrl $2,%ebx# KPG P4

Page 101 - 3.7. COROUTINE EXAMPLES 93

Chapter 2The BCPL LanguageThe design of BCPL owes much to th e work done on CPL (originally CambridgeProgramming Language) which was conceived at Camb

Page 102 - 3.8 The Gr a phi cs Libra r y

182 CHAPTER 10. THE DESIGN OF SIALLA2:movl %ebp,0(%edx)movl %edx,%ebppopl %edxmovl %edx,4(%ebp)movl %eax,8(%ebp)movl %ebx,12(%ebp)# JNE0 L5orl %ebx,%e

Page 103 - 3.8.3 The Graphics Functions

10.2. THE SIAL-386 TRANSLATOR 183When implementing sial-386 it was necessary to decide how t he Intel regis te r swere to be used and what the BCPL ca

Page 104 - 96 CHAPTER 3. THE LIBRARY

184 CHAPTER 10. THE DESIGN OF SIALThe call cvfpg("KPG") reads the Sial stateme nt knowing it is of the form: KPGPk Gn. This outputs the stat

Page 105

10.3. COMPACTION OF SIAL 18510.3 Compaction of SialIn order to transmit program to a device such as a mobile phone or s pac e probe over aslow connect

Page 106 - 3.12 The EXT L i br ar y

186 CHAPTER 10. THE DESIGN OF SIAL

Page 107 - The Command Language

Chapter 11The MC PackageThis chapt er describes the MC package which provides a machine independent way togenerate and execut e native machine code at

Page 108 - Figure 4.1: The initial state

188 CHAPTER 11. THE MC PACKAGEMANIFEST {A=mc_a; B=mc_b; C=mc_c; D=mc_d; E=mc_e; F=mc_fa1=1; a2; a3}LET start() = VALOF{ // Load the dynamic code gener

Page 109 - 4.2 Bootstrapping Cintpos

11.1. MC EXAMPLE 189// MV A,A1movl 20(%ebp), %eax573: 8B 45 14// ADD A,A2addl 24(%ebp), %eax576: 03 45 18// LAB L1lab L1579: L1:// ADD A,A3addl 28(%eb

Page 110 - 4.2.2 startroot

190 CHAPTER 11. THE MC PACKAGEFunction OperandsmcF No operandmcK One integer operandmcR One MC register operandmcA One operand specifying an argument

Page 111

11.2. MC LIBRARY FUNCTIONS 191mcRK Two operands, R and KmcAK Two operands, A and KmcVK Two operands, V and KmcGK Two operands, G and KmcMK Two operand

Page 113 - 4.3 Commands

12 CHAPTER 2. THE BCPL LANGUAGEvariant of GPM, called BGPM, is included in the standard BCPL distribution.BCPL was initially similar to this subset of

Page 114

192 CHAPTER 11. THE MC PACKAGEmcRK(mc_mv, A, #x10000000)mcPRF("With D=%8x ", D)mcPRF("A=%8x ", A)mcPRF("B=%8x*n", B)mcR(

Page 115 - 4.3. COMMANDS 107

11.3. THE MC LANGUAGE 193When an MC function is decl ar ed it has a specified number of arguments and localvariables (see the ENTRY statement below). W

Page 116

194 CHAPTER 11. THE MC PACKAGEALIGND KAlign the next item of data to an address which is a multiple of k which must be2, 4 or 8.AND RA RV RG RM RL RD

Page 117 - 4.3. COMMANDS 109

11.3. THE MC LANGUAGE 195DEC R A V G M L D DX DXs DXsBDecrement the specified register or memory word by 1, leaving the condition codeundefined.DIV K R

Page 118

196 CHAPTER 11. THE MC PACKAGEJLT JS JL JRJump to the spec i fie d location if the first operand of a previous CMP instruction wasless than its second o

Page 119 - 4.3. COMMANDS 111

11.3. THE MC LANGUAGE 197RK AK VK GK MK LK DK DXK DXsK DXsBKMove the zero extended 16-bit val ue specified by the second operand into the first.LEA RA R

Page 120

198 CHAPTER 11. THE MC PACKAGESEQ RSet the specified register to one if the first operand of a previous CMP instructionwas equal to its second operand,

Page 121 - 4.3. COMMANDS 113

11.3. THE MC LANGUAGE 199UJGE JS JL JRJump to the speci fie d location if the first operand of a previous CMP instruction wasgreater than or equal to it

Page 122

200 CHAPTER 11. THE MC PACKAGE11.4 MC Debugging AidsThe primary debugging aid is to inspect the generated code and the is controlled bythe DEBUG direc

Page 123 - 4.3. COMMANDS 115

11.5. THE N-QUEENS DEMONSTRATION 201UNLESS rdargs("mc,lo/n,hi/n,-c/s,-m/s,-a/s,-b/s", argv, 50) DO{ writef("Bad arguments for mcqueens*

Page 124

2.1. LANGUAGE OVERVIEW 132.1.2 The GET DirectiveA directives of the form GET "filename" is replaced by the contents of the namedfile. Ear l y

Page 125 - 4.3. COMMANDS 117

202 CHAPTER 11. THE MC PACKAGE}AND gencode(n) BE{ LET all = (1<<n) - 1mcKKK(mc_entry, n, 3, 0)mcRK(mc_mv, ld, 0)mcRK(mc_mv, col, 0)mcRK(mc_mv, r

Page 126

11.5. THE N-QUEENS DEMONSTRATION 203mcRR(mc_add, col, p) // col := col+pmcRR(mc_add, rd, p)mcRK(mc_rsh, rd, 1) // rd := (rd+p)>>1cmpltry(i+1, n,

Page 127 - 4.3. COMMANDS 119

204 CHAPTER 11. THE MC PACKAGE

Page 128

Chapter 12InstallationThe implementation of BCPL described in this report is freely available via my HomePage [3] to individuals for private use and t

Page 129 - 4.3. COMMANDS 121

206 CHAPTER 12. INSTALLATIONSome web browsers will have already decompressed the .tgz file, so you may haveuse the following command instead:cd distrib

Page 130

12.1. LINUX INSTALLATION 207to the end of the file .bashrc in your home directory so the the BCPL environmentvariables are automatically setup whenever

Page 131 - 4.3. COMMANDS 123

208 CHAPTER 12. INSTALLATIONc compall6) The BCPL programs that are part of the system are: boot.b, blib.b, dlib andcli.b. These reside i n BCPL/cintco

Page 132

12.3. INSTALLATION ON OTHER MACHINES 209-m n Set the Cintcode memory size to n words.-t n Set the tally vector size to n words.-s Enter the Cintcode s

Page 133 - 4.3. COMMANDS 125

210 CHAPTER 12. INSTALLATIONI installed the fre e l y available .NET Framework 3.5 and the corresponding SDK 3.5.This provided amongst many other thi

Page 134

12.6. INSTALLATION FOR WINDOWS CE2.0 21112.6 Installation for Windows CE2.0A version of the BCPL Cintcode System is available for handheld machines ru

Page 135 - 4.3. COMMANDS 127

14 CHAPTER 2. THE BCPL LANGUAGE2.1.4 Section BracketsHistorically BCPL used the symbols $( and $) to bracket commands and decla-rations. These symbols

Page 136 - 4.4 cli.b and cli

212 CHAPTER 12. INSTALLATION

Page 137 - 4.4. CLI.B AND CLI INIT.B 129

Chapter 13Example Programs13.1 CoinsThe following program prints out how many different ways a sum of money can becomposed from coins of various denomi

Page 138

214 CHAPTER 13. EXAMPLE PROGRAMS13.2 PrimesThe following program prints out a table of all primes less than 1000, using the sie vemethod.GET "lib

Page 139 - Console Input and Output

13.4. FRIDAYS 215LET start() = VALOF{ all := 1FOR i = 1 TO 16 DO{ count := 0try(0, 0, 0)writef("Number of solutions to %i2-queens is %i9*n",

Page 140 - 5.2 Cintpos console strea m s

216 CHAPTER 13. EXAMPLE PROGRAMS13.5 Lambda EvaluatorThe following program is a simple parser and evaluator for lambda expressions.GET "libhdr&qu

Page 141 - 5.2.1 Devices

13.5. LAMBDA EVALUATOR 217// *************** Syntax analyser ***********************// Construct Corresponding Tree// a ,.., z --> [Id, ’a’] ,.., [

Page 142 - 5.2.2 Exclusive Input

218 CHAPTER 13. EXAMPLE PROGRAMSAND lex() BE SWITCHON ch INTO{ DEFAULT: writef("Bad ch in lex: %c*n", ch)CASE Eof: token := EofRETURNCASE ’

Page 143 - Cintpos De vi ces

13.5. LAMBDA EVALUATOR 219AND prim() = VALOF{ LET a = TABLE Num, 0SWITCHON token INTO{ DEFAULT: writef("Bad expression*n"); ENDCASECASE Id:

Page 144 - 6.0.7 TCP/IP Devices

220 CHAPTER 13. EXAMPLE PROGRAMSAND try(expr) BE{ LET v = VEC 2000space := v+2000writef("Trying %s*n", expr)writef("Answer: %n*n",

Page 145

13.6. FAST FOURIER TRANSFORM 221LET start() = VALOF{ writef("fft with N = %n and omega = %n modulus = %n*n*n",N, omega, modulus)data := getv

Page 146

2.2. EXPRESSIONS 15The following are exam p l es of valid nu mbers:12341_234_456#B_1011_1100_0110#o377#X3fff#x_DEADC0DESince August 2014, floating poin

Page 147 - The Debugger

222 CHAPTER 13. EXAMPLE PROGRAMSAND reorder(v, n) BE{ LET j = 0FOR i = 0 TO n-2 DO{ LET k = n>>1// j is i with its bits is reverse orderIF i<

Page 148 - 140 CHAPTER 7. THE DEBUGGER

Bibliography[1] D . T. Ross et al. AED-0 programmer’s guide and user k it. Technical report, Elec-tronic Systems Laboratory M.I.T, 1964.[2] C. Jobson

Page 150 - 142 CHAPTER 7. THE DEBUGGER

Appendix ABCPL Syntax DiagramsThe syntax of standard B CPL is specified using the transition diagrams given in fig-ures A.1, A.2, A.3 and A.4. In extend

Page 151 - 7.2 The C intpos Debugger

226 APPENDIX A. BCPL SYNTAX DIAGRAMSand not{ IF i>10 DO i := i/2 } REPEATUNTIL i<5A useful property of these diagrams is that, once a test box h

Page 152 - 144 CHAPTER 7. THE DEBUGGER

227nameSTATICMANIFEST = E0 ; }D{};E0:nameGLOBALLET nameAND=nameVEC E0,,= E0,( name,)BE C= E0{Figure A.2: Declarations

Page 153 - The Design of OCODE

228 APPENDIX A. BCPL SYNTAX DIAGRAMSGOTOTESTFOR name THENUNLESSIFE0 INTO,E0:=:=E0E0is callis name : CCASEDEFAULTE0E0 TO E0 BY E0DOCE0 THENDOC ELSE CE0

Page 154

229TRUEEn?FALSEnamenumbercharacterstring!@+−ABS(NOTTABLE,E0E8E5E4E3E2E1E0 , E0CE0,E3E5E7))E0VALOFE4( n<9! n<8* n<6/ n<6+ n&

Page 155

230 APPENDIX A. BCPL SYNTAX DIAGRAMS

Page 156 - 8.4 Field Selection Operators

16 CHAPTER 2. THE BCPL LANGUAGESLCT shift:offset means SLCT 0:shift:offsetSLCT offset means SLCT 0:0:offsetCharacter constants consist of a si n gl e char

Page 157 - 8.5 Expression Operators

2.2. EXPRESSIONS 17Escape Replacement*n A newline (end-of-line) character.*c A carriage return character.*p A newpage (form-feed) character.*s A space

Page 158 - 8.6 Functio ns and Routines

18 CHAPTER 2. THE BCPL LANGUAGElength and bytes of the string are packed. If s is a str i n g t h en s%0 is its lengthand s%1 is its first character, s

Page 159 - A1 A2 An

2.2. EXPRESSIONS 19Here, E1points to the fields of an object, wit h the convention th at its ze-roth field (E1!0) i s a pointer to the methods vector. E

Page 160 - E1 E2 En E

20 CHAPTER 2. THE BCPL LANGUAGEwhen a field is updated. Suppose p!3 holds the value #x12345678, then after theassignment:(SLCT 12:8:3) OF p := 1 + (SLC

Page 161 - 8.9 Discussion

2.2. EXPRESSIONS 212.2.8 VALOF ExpressionsAn expression of the form VALOF C, wh er e C is a command, is evaluated byexecuting the command C. On encoun

Page 162

ContentsPreface v1 The Sy s tem Overview 11.1 A Cintsys Console Sessio n . . . . . . . . . . . . . . . . . . . . . . 11.2 A Cintpos Console Session .

Page 163 - The Design of Cintcode

22 CHAPTER 2. THE BCPL LANGUAGENotice that these precedence values imply that! f x means ! (f x)! @ x means ! (@ x)! v ! i ! j means ! ((v!i)!j)@ v !

Page 164 - 9.1 Designing for Compactness

2.3. COMMANDS 23used, the appropriate 8 bit location is updated by the least significant 8 bits ofE.If the left hand side is of the form S OFE then the

Page 165 - 9.1.1 Global Variables

24 CHAPTER 2. THE BCPL LANGUAGEwhere E denotes an expression and C1and C2denote commands. The symbolsDO and THEN may be omitted whenever they are foll

Page 166 - 9.1.3 Relative Addressing

2.3. COMMANDS 252.3.6 Flow of Co ntrolThe following commands affect the flow of control.RESULTIS ERETURNENDCASELOOPBREAKGOTO EFINISHRESULTIS causes eval

Page 167

26 CHAPTER 2. THE BCPL LANGUAGEIn extended BCPL compilerd by xbcpl a more binding version of the sequenc-ing operator is a allowed. It is the symbol &

Page 168

2.4. DECLARATIONS 272.4.2 Manifest DeclarationsA MANIFEST declaration has the following form:MANIFEST { N1= K1;...; Nn= Kn}where N1,...,Nnare names (s

Page 169 - 9.2.2 Loading Values

28 CHAPTER 2. THE BCPL LANGUAGEwhere N1,...,Nnare names (see Section 2.2.1) and K1,...,Knare manifestconstant express io n s (see Section 2.2.10). Eac

Page 170 - 9.2.4 Expression Operators

2.4. DECLARATIONS 29where N is a name and K is a manifest constant expression. A location isallocated for N and initialized to a vector whose lower bo

Page 171 - 9.2.5 Simple Assignment

30 CHAPTER 2. THE BCPL LANGUAGE(@x)!1, (@x)!2,. . . where x is t he first argument. This feature is useful in thedefinition of functions, such as writef

Page 172 - 9.2.6 Indirect Assignment

2.5. SEPARATE COMPILATION 31restriction is exemplified below.GLOBAL { var:200 }LET f1(...) BE{ LET oldvar = var // Save the current value of varvar :=

Page 173

ii CONTENTS2.4.1 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262.4.2 Manifest Declarati o n s . . . . . . . . . . . . . . . . . .

Page 174 - 9.2.9 Switch Instructions

32 CHAPTER 2. THE BCPL LANGUAGEWhen these sections are l oa d ed , global 200 is initialized to the entry point offunction f defined in demolib.b and s

Page 175 - 9.2.10 Miscellaneous

Chapter 3The LibraryThis manual describes three var i ants of the BCPL system. The simplest is in-voked by the shell command cintsys and provides a si

Page 176

34 CHAPTER 3. THE LIBRARYMost implementations use pack 4 bytes into 32-bit words requiring B2Wsh=2, but on64-bit imple me ntations, such as native cod

Page 177 - 9.2.13 Undefined Instructions

3.1. MANIFEST CONSTANTS 35function name is too long its first and last five character are packed into the stringseparated by a single quote ’. Typically

Page 178 - 9.2.15 Exceptions

36 CHAPTER 3. THE LIBRARYrtn. . . CIN:y, POS:y, NAT:yThe ro ot node is a vector accessible to all running programs to provide access toall global info

Page 179 - The Design of Sial

3.1. MANIFEST CONSTANTS 37rtnclwkq CIN:n, POS:y, NAT:nUnder Cintpos, this field is used to holds the ordered list of packets waiting to bereleased by t

Page 180

38 CHAPTER 3. THE LIBRARYrtnhdrsvar CIN:y, POS:y, NAT:nThis field holds the name of the environment variable givin g the di r ec t or i es holdingBCPL

Page 181 - 10.1 The Sial Specification

3.1. MANIFEST CONSTANTS 39rtnmembase, rtn memsize CIN:y, POS:y, NAT:nThese rootnode fie l ds hold, respectively, the star t of the memory block chain a

Page 182

40 CHAPTER 3. THE LIBRARYrtnvecstatsv CIN:y, POS:y, NAT:nThis points to a vector holding counts of how many blocks of each requested sizehave been all

Page 183

3.1. MANIFEST CONSTANTS 41scbid CIN:y, POS:y, NAT:nThis SCB field holds one of the values idinscb, id outscb or id inoutscb, indi-cating whether the st

Page 184

CONTENTS iii4.4 cli.b and cliinit.b . . . . . . . . . . . . . . . . . . . . . . . . 1285 Console Input and Output 1315.1 Cintsys console streams . . .

Page 185

42 CHAPTER 3. THE LIBRARYscbtnet, scbt file, scbt ram, scbt console or scbt mbx, scbt tcp. The last threehave strictly positive values causing output

Page 186

3.2. GLOBAL VARIABLES 43modules hold the relocatable byte stream interpretive code used by all BCPL interpre-tive systems. Constants with names ending

Page 187

44 CHAPTER 3. THE LIBRARYmaincobusy CIN:n, POS:y, NAT:nThis is a variable used i n the implementation of gomultievent under Cintpos.multicount CIN:n,

Page 188 - 10.2 The sial-386 Translator

3.3. GLOBAL FUNCTIONS 45defined i n the standard re si de nt library. Most of these are defined in BCPL in the files:sysb/klib.b, sysb/blib.b and sysb/dl

Page 189

46 CHAPTER 3. THE LIBRARYch := capitalch(ch) CIN:y, POS:y, NAT:yThis function converts l owercase letters to uppercase, leaving other characters un-ch

Page 190

3.3. GLOBAL FUNCTIONS 47Decimal range GB2312 bytes0 < dd < 127 <dd>128 < xxyy < 9494 <xx+160> <yy+160>res := compch(ch1,

Page 191

48 CHAPTER 3. THE LIBRARYnext resumes execution. The parent link points to the coroutine that called this one,or is zero if the coroutine not active.

Page 192

3.3. GLOBAL FUNCTIONS 49The definition of createco is in blib.b and is as follows.LET createco(fn, size) = VALOF{ LET c = getvec(size+6)UNLESS c RESULT

Page 193 - 10.3 Compaction of Sial

50 CHAPTER 3. THE LIBRARYP2 L2 fn sz c P1 L1 0 cK9G 24 cowait(c)LP3J -7 } REPEATK6 fn( ... )LP5 {PCPThe new coroutinecoroutine ch

Page 194

3.3. GLOBAL FUNCTIONS 51This call causes the time stamp in datv t o be converted to three strings v, v+5 andv+10. The string at v is set to the date i

Page 195 - The MC Package

iv CONTENTS9.2.8 Flow of Control and Relations . . . . . . . . . . . . . . . . 1669.2.9 Switch Instructions . . . . . . . . . . . . . . . . . . . . .

Page 196

52 CHAPTER 3. THE LIBRARYblock (TCB) is unlinked from the priority chain and removed from tasktab. Finallyits segment list and the TCB itself return e

Page 197 - 11.1. MC EXAMPLE 189

3.3. GLOBAL FUNCTIONS 53name is the string "*" then it opens the standard output stream which is normally tothe screen. If the file name is r

Page 198

54 CHAPTER 3. THE LIBRARYcptr := initco(fn, size,a,b,c,d,e,f,g,h,i,j,k) CIN:y, POS:y, NAT:yThis function provides a convenient method of creating and

Page 199 - 11.2 MC L i br a ry Functions

3.3. GLOBAL FUNCTIONS 55within the cur re nt function or routine can be performed using the GOTO command, solevel and longjump are only needed for non

Page 200 - 11.3 The MC La ng ua g e

56 CHAPTER 3. THE LIBRARYnewline() CIN:y, POS:y, NAT:yThis simply outputs the newline character (’*n’) to the currently selected outputstream.newpage(

Page 201 - 11.3. THE MC LANGUAGE 193

3.3. GLOBAL FUNCTIONS 57destination task or device (specified by pktid!pkt). If this fiel d is positive it refer s toa task, if it is -1 it r e fe r s t

Page 202

58 CHAPTER 3. THE LIBRARYwhere the decoded integer is stored. If a /N was not specified, the setti n g will be aBCPL string with its characters packed

Page 203 - 11.3. THE MC LANGUAGE 195

3.3. GLOBAL FUNCTIONS 59ch := rdch() CIN:y, POS:y, NAT:yThis call reads the next character from the currently selected input stream. If thestream is e

Page 204

60 CHAPTER 3. THE LIBRARYres := release(taskid) CIN:n, POS:y, NAT:nThis Cintpos function wi l l clear the HOLD bit in the spe ci fi ed task thus making

Page 205 - 11.3. THE MC LANGUAGE 197

3.3. GLOBAL FUNCTIONS 61selectoutput(scb) CIN:y, POS:y, NAT:yThis r ou ti ne selects scb as the currently selected output stream. It aborts (withcode

Page 206

PrefaceThe concept for BCPL originated in 1966 and was first outlined in my PhDthesis [4]. Its was first implemented early in 1967 when I was working at

Page 207 - 11.3. THE MC LANGUAGE 199

62 CHAPTER 3. THE LIBRARYclireturncode and cli result2 where they can be inspected by commands such asif and why.n := str2numb(str) CIN:y, POS:y, NAT:

Page 208 - 11.4 MC Debugging Aids

3.3. GLOBAL FUNCTIONS 63res := sys(Syscallc, c name2port, a1) CIN:y, POS:y, NAT:yThe name or decimals of a port is given in a1 and the resul t is its

Page 209

64 CHAPTER 3. THE LIBRARYres := sys(Syscallc, c fd select, a1, a2, a3, a4, a5) CIN:y, POS:y, NAT:yThis inspects bit a1 in the bit vector a2. The resul

Page 210

3.3. GLOBAL FUNCTIONS 65time of the last modification of the file given by name returning TRUE if successful.The first element datv!0 holds the number of

Page 211

66 CHAPTER 3. THE LIBRARYthe negated value of a where a is a floating point number. The last four calls performfloating point multi p l i cat i on, divi

Page 212

3.3. GLOBAL FUNCTIONS 67res := sys(Sysflt, fl modf, a)res := sys(Sysflt, fl fmod, x, y) CIN:y, POS:y, NAT:yThe first call returns the fractional part (

Page 213 - Installation

68 CHAPTER 3. THE LIBRARYstr := sys(Sysgetprefix) CIN:y, POS:y, NAT:yThis returns a pointer to prefix st r i ng which is in space allocated when Ci nts

Page 214 - 206 CHAPTER 12. INSTALLATION

3.3. GLOBAL FUNCTIONS 69directory. If a val i d module is not found ther e and name is a relative file name, itsearches through the directories specifie

Page 215 - 12.1. LINUX INSTALLATION 207

70 CHAPTER 3. THE LIBRARYthat needs to be modified by the addition of the base address of the hunk. The codet bhunk is similar to t hunk only the data

Page 216 - 12.2 Command Line Arguments

3.3. GLOBAL FUNCTIONS 71otherwise it returns pollingch (=-3). If the input stream is exhausted it returnsendstreamch (= -1). Unlike sardch, the charac

Page 217

vi CONTENTS• The SIAL intermediate code that allows easy translation o f BCPL in nativecode for most architectures, inclu ding, for instance, the Rasp

Page 218 - 210 CHAPTER 12. INSTALLATION

72 CHAPTER 3. THE LIBRARYoldcount := sys(Syssetcount, newcount) CIN:y, POS:y, NAT:nOne of the Cintcode registers is called count which is inspected ju

Page 219 - 12.7 The Native Code Version

3.3. GLOBAL FUNCTIONS 73-1 Re-enter the interpreter with a new value in the the countregister0 Normal successful completion (by convention)1 Non exist

Page 220 - 212 CHAPTER 12. INSTALLATION

74 CHAPTER 3. THE LIBRARYthe specified value ret ur ni n g it previous setting. Setting it to a negative value disablesthe tracing mechani s m. See Sys

Page 221 - Example Programs

3.3. GLOBAL FUNCTIONS 75res := sys(Syssound, snd waveOutClose, a1) CIN:y, POS:y, NAT:yThis closes sound wave output device a1.res := sys(Syssound, snd

Page 222 - 13.3 Queens

76 CHAPTER 3. THE LIBRARYsys(Systally, val) CIN:y, POS:y, NAT:nThis call provides a profiling facility that uses a globally accessible tall y vector to

Page 223 - 13.4 Fridays

3.3. GLOBAL FUNCTIONS 77res := sys(Sysusleep, usecs) CIN:y, PO S: y, NAT:yUnder ci ntsys, thi s call causes the system to sleep for usecs micro-second

Page 224 - 13.5 Lambda Evaluator

78 CHAPTER 3. THE LIBRARYreturns TRUE if successful, and FALSE otherwise. A call of unrdch will alway s succeedsthe first time after a call of rdch. It

Page 225 - 13.5. LAMBDA EVALUATOR 217

3.3. GLOBAL FUNCTIONS 79Item Substitution%s Write the next argument as a string using writes.%tn Write t h e next argument as a left justified string i

Page 226

80 CHAPTER 3. THE LIBRARYFOR count = 0 TO 2 DOwritef("There %p\ is\are\ %-%n thing%-%ps.*n", count)outputs:There are 0 things.There is 1 thi

Page 227 - 13.5. LAMBDA EVALUATOR 219

3.3. GLOBAL FUNCTIONS 81AND rdch() = VALOF{ LET pos = cis!scb_pos // Position of next byte, if anyUNLESS cis DO abort(186)IF pos<cis!scb_end DO { L

Page 228 - 13.6 Fas t Fourier Transform

Chapter 1The System OverviewThis document contains a full description of an interpretive implementation ofBCPL that supports a command language and lo

Page 229

82 CHAPTER 3. THE LIBRARYAND wrch(ch) = VALOF{ LET pos = cos!scb_posIF pos >= cos!scb_bufend DO{ // The buffer is fullUNLESS deplete(cos) RESULTIS

Page 230

3.4. RANDOM ACCESS 833.4 Random AccessDisk files can be regarded as potentially huge vectors of bytes with the first byte beingat position zero of the fi

Page 231 - Bibliography

84 CHAPTER 3. THE LIBRARYble to commands such as bcpl, c and setroot via the rootnode fiel ds rtnrootvar,rtnpathvar, rtn hdrsvar and rtn scriptsvar.Whe

Page 232 - 224 BIBLIOGRAPHY

3.7. COROUTINE EXAMPLES 853.7.1 A square wave generatorThe following function is the main function of a coroutine that generates square wavesamples.LE

Page 233 - BCPL Syntax Diagrams

86 CHAPTER 3. THE LIBRARYMAINBUF1 TEE1X2 X3 X5MER1 MER2BUF2 TEE2 BUF3w w w w wwwwwwww c c c cwcccc cccc cFigure 3.10: Coroutine data flowThis problem i

Page 234 - Figure A.1: Program, Section

3.7. COROUTINE EXAMPLES 87LET tee(args) BE // Body of TEE1 and TEE2{ LET in, out = args!0, args!1cowait() // End of initialisation.{ LET val = callco(

Page 235 - Figure A.2: Declarations

88 CHAPTER 3. THE LIBRARY3.7.3 A Discrete Event SimulatorThis is a benchmark test for a di sc r e te event simulator using coroutines. It simulatesa n

Page 236 - Figure A.3: Commands

3.7. COROUTINE EXAMPLES 89// ################### Random number generator #######################// The following random number generator is based on o

Page 237 - Figure A.4: Expressions

90 CHAPTER 3. THE LIBRARYAND downheap(event, i) BE{ LET j, min = 2*i, ? // j is left child, if presentIF j > priqn DO{ upheap(event, i)RETURN}min :

Page 238

3.7. COROUTINE EXAMPLES 91AND qitem(node) BE// The message has reached this node// It currently not busy, mark it as busy and return to process// the

Comments to this Manuals

No comments