From 7225fec89d7cfbc4516b14778fdceebb90a53699 Mon Sep 17 00:00:00 2001 From: John O'Donnell Date: Fri, 14 Jan 2022 09:09:23 +0000 Subject: [PATCH] main sections for subsets in user guide --- docs/UserGuide/Sigma16UserGuide.html | 1248 +++++++++++++------------- docs/UserGuide/Sigma16UserGuide.org | 70 +- docs/welcome/welcome.html | 30 +- src/base/assembler.mjs | 23 +- src/server/sigserver.mjs | 17 +- 5 files changed, 720 insertions(+), 668 deletions(-) diff --git a/docs/UserGuide/Sigma16UserGuide.html b/docs/UserGuide/Sigma16UserGuide.html index 20a3ebd..0fd9b30 100644 --- a/docs/UserGuide/Sigma16UserGuide.html +++ b/docs/UserGuide/Sigma16UserGuide.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Sigma16 User Guide @@ -243,215 +243,217 @@

Sigma16 User Guide

-Version 3.4.1, December 2021. -Copyright (c) 2021 John T. O'Donnell +Version 3.4.1, January 2022. +Copyright (c) 2022 John T. O'Donnell

Table of Contents

-
-

Introduction

-
+
+

Introduction

+

Sigma16 is a computer architecture designed for research and teaching in computer systems. The architecture is simple yet -powerful. It is organized into subsets to make it easier to use: -the core subset is suitable for beginners, the standard subset -offers flexible programming techniques, and the full system supports -the study of systems programming. +powerful.

@@ -476,23 +478,37 @@

Introduction

-For a quick start, begin with the tutorials, which introduce the -architecture step by step. The tutorials explain the machine, show -how to program it, and demonstrate how to enter and run a program -and how to use the programming environment. +The architecture is organized into subsets to make it easier to use: +

+
    +
  • The Core subset contains a small and simple instruction set which +is a good starting point for learning about computer architecture. +Although it is simple, Core is powerful enough to support realistic +programming.
  • +
  • The Standard subset offers flexible programming techniques, +including flexible manipulation of bits and fields and arithmetic on +natural numbers and arbitrary precision integers.
  • +
  • The full System supports the study of systems programming. It +supports interrupts, concurrent processes, and critical regions.
  • +
+

+Core is a subset of Standard, which is a subset of System. To learn +the architecture, start with Core and then go on to Standard and +System.

-The remainder of the user guide is organised by topic, with chapters -on the architecture, the assembly language, the linker, and -programming techniques. +For a quick start, begin with the Core architecture tutorials, which +introduce the architecture step by step. The tutorials explain the +machine, show how to program it, and demonstrate how to enter and run +a program and how to use the programming environment.

-
-

Tutorials

-
+
+

Core architecture

+

The following short tutorials introduce the system; full details appear in later sections. You can keep the tutorials visible in the @@ -502,13 +518,13 @@

Tutorials

-

Core architecture tutorial

+

Core architecture tutorials

-
-

Hello, world!

-
+
+

Hello, world!

+

Let's begin by running a simple example program. For now, we focus only on how to use the software tools. You don't need to understand @@ -595,9 +611,9 @@

Hello, world!

-
-

A quick tour

-
+
+

A quick tour

+

This tutorial introduces the main components of the architecture as well as the graphical user interface. @@ -685,17 +701,13 @@

A quick tour

-
-

Registers, constants, and arithmetic

-
-

-This tutorial introduces the main components of the app. -

- +
+

Registers, constants, and arithmetic

+

-The architecture has a register file which is an array of 16 -registers, named R0, R1, R2, …, R15. The Register File is displayed -in a box on the Processor page. +Programs do most of their work using the register file, which is +an array of 16 registers named R0, R1, R2, …, R15. The Register +File is displayed in a box on the Processor page.

@@ -719,7 +731,7 @@

Registers, constants, and arithmetic

into a register. For example, to load 42 into register 3, write

-
+
 lea  R3,42[R0]   ; R3 := 42
 
@@ -768,7 +780,7 @@

Registers, constants, and arithmetic

into R4:

-
+
 add   R4,R8,R1  ; R4 := R8 + R1
 
@@ -786,7 +798,7 @@

Registers, constants, and arithmetic

The following program calculates 3+4:

-
+
 lea   R5,3[R0]    ; R5 := 3
 lea   R8,4[R0]    ; R8 := 4
 add   R2,R5,R8    ; R2 := R5 + R8 = 3+4 = 7
@@ -808,7 +820,7 @@ 

Registers, constants, and arithmetic

register):

-
+
 add  R4,R11,R0   ; R4 := R11 + R0
 sub  R5,R2,R13   ; R5 := R2 - R13
 mul  R2,R10,R7   ; R2 := R10 * R7
@@ -838,7 +850,7 @@ 

Registers, constants, and arithmetic

whatever value was previously there. So consider this example:

-
+
 lea   R7,20[R0]  ; R7 := 20
 lea   R8,30[R0]  ; R8 := 30
 add   R7,R7,R8   ; R7 := R7 + R8
@@ -874,7 +886,7 @@ 

Registers, constants, and arithmetic

the number. Thus $00a5 and 0165 both represent the integer 165. -
+
 lea   R1,13[R0]     ; R1 =  13 (hex 000d)
 lea   R2,$002f[R0]  ; R2 := 47 (hex 002f)
 lea   R3,$0012[R0]  ; R3 := 18 (hex 0012)
@@ -918,7 +930,7 @@ 

Registers, constants, and arithmetic

avoid R0 and R15).

-
+
 lea  R1,3[R0]   ; R1 := 3
 lea  R2,4[R0]   ; R2 := 4
 lea  R3,5[R0]   ; R3 := 5
@@ -932,7 +944,7 @@ 

Registers, constants, and arithmetic

There is a special instruction to do this:

-
+
 trap  R0,R0,R0   ; halt
 
@@ -1009,7 +1021,7 @@

Registers, constants, and arithmetic

  • We wish to compute R5 = (a+b) * (c-d)
  • -
    +
     add   R6,R1,R2     ; R6 := a + b
     sub   R7,R3,R4     ; R7 := c - d
     mul   R5,R6,R7     ; R5 := (a+b) * (c-d)
    @@ -1059,9 +1071,9 @@ 

    Registers, constants, and arithmetic

    -
    -

    Keeping variables in memory

    -
    +
    +

    Keeping variables in memory

    +

    So far we have used registers in the register file to hold variables. However, there are only 16 of these, and two have special purposes (R0 @@ -1149,7 +1161,7 @@

    Keeping variables in memory

    Solution:

    -
    +
     load   R1,a[R0]      ; R1 := a
     load   R2,b[R0]      ; R2 := b
     add    R3,R1,R2      ; R3 := a+b
    @@ -1190,7 +1202,7 @@ 

    Keeping variables in memory

    For example, to define variables x, y, z and give them initial values:

    -
    +
     x    data   34    ; x is a variable with initial value 34
     y    data    9    ; y is initially 9
     z    data    0    ; z is initially 0
    @@ -1223,7 +1235,7 @@ 

    Keeping variables in memory

    and memory are changed. -
    +
     ; Program Add.  See Sigma16/README.md in top folder
     ; A minimal program that adds two integer variables
     
    @@ -1339,7 +1351,7 @@ 

    Keeping variables in memory

    Here are some syntactically valid statements:

    -
    +
     loop   load   R1,count[R0]    ; R1 = count
            add    R1,R1,R2        ; R1 = R1 + 1
     
    @@ -1348,7 +1360,7 @@

    Keeping variables in memory

    Each of the following statements is wrong!

    -
    +
        add   R2, R8, R9    ; spaces in the operand field
     loop1  store x[R0],R5  ; wrong order: should be R5,x[R0]
         addemup            ; invalid mnemonic
    @@ -1369,7 +1381,7 @@ 

    Keeping variables in memory

    fields are what you intended. For example if you meant to say

    -
    +
     add R1,R2,R3  ; x := a + b
     
    @@ -1377,7 +1389,7 @@

    Keeping variables in memory

    but you have a spurious space, like this

    -
    +
     add R1, R2,R3  ; x := a + b
     
    @@ -1405,7 +1417,7 @@

    Keeping variables in memory

    Examples:

    -
    +
        lea   R1,40[R0]      ; R1 = 40
        lea   R2,$ffff[R0]   ; R2 = -1
     
    @@ -1451,7 +1463,7 @@ 

    Keeping variables in memory

    vertically, like this:

    -
    +
     load   R1,three[R0]  ; R1 = 3
     load   R2,x[R0]      ; R2 = x
     mul    R3,R1,R2      ; R3 = 3*x
    @@ -1463,7 +1475,7 @@ 

    Keeping variables in memory

    Not like this:

    -
    +
        load   R1,three[R0]     ; R1 = 3
      load  R2,x[R0] ; R2 = x
           mul R3,R1,R2           ; R3 = 3*x
    @@ -1488,9 +1500,9 @@ 

    Keeping variables in memory

    -
    -

    Files and modules

    -
    +
    +

    Files and modules

    +

    Whatever method you use to edit your programs, be sure to save your work to a file from time to time. If you don't do that, sooner or @@ -1617,16 +1629,16 @@

    Files and modules

    -
    -

    Jumps and conditionals

    -
    +
    +

    Jumps and conditionals

    +

    Conditionals allow a program to decide which statements to execute based on Boolean expressions. One example is the if-then statement, for example:

    -
    +
     if x<y
       then statement 1
     statement 2
    @@ -1636,7 +1648,7 @@ 

    Jumps and conditionals

    A related form is the if-then-else statement:

    -
    +
     if x<y
       then statement 1
       else statement 2
    @@ -1649,7 +1661,7 @@ 

    Jumps and conditionals

    bexp to decide whether to jump to someLabel, or not to jump:

    -
    +
     if bexp then goto someLabel
     
    @@ -1657,7 +1669,7 @@

    Jumps and conditionals

    The commonest case is where bexp is a comparision between two integers:

    -
    +
     if x < y then goto someLabel
     
    @@ -1684,7 +1696,7 @@

    Jumps and conditionals

    is a relation, such as lt, eq, and so on:

    -
    +
     jumplt  someLabel[R0]  ; if <  then goto someLabel
     jumple  someLabel[R0]  ; if <= then goto someLabel
     jumpeq  someLabel[R0]  ; if =  then goto someLabel
    @@ -1719,7 +1731,7 @@ 

    Jumps and conditionals

    address of the sub instruction.

    -
    +
     label1   add  R2,R4,R13
     label2
              sub  R15,R0,R1
    @@ -1730,7 +1742,7 @@ 

    Jumps and conditionals

    similar fixed patterns. Suppose Bexp is a Boolean in any register Rd

    -
    +
     if bexp
       then statement 1
     statement 2
    @@ -1742,7 +1754,7 @@ 

    Jumps and conditionals

    -
    +
          if !bexp then goto L1
          statement 1
     L1:
    @@ -1754,7 +1766,7 @@ 

    Jumps and conditionals

    Her is an example:

    -
    +
     a := 93
     x := 35
     y := 71
    @@ -1766,7 +1778,7 @@ 

    Jumps and conditionals

    The corresponding assembly language is:

    -
    +
     ; a := 93
           lea     R1,93[R0]    ; R1 := 93
           store   R1,a[R0]     ; a := 93
    @@ -1812,7 +1824,7 @@ 

    Jumps and conditionals

    and which doesn't use a Boolean.

    -
    +
     jump   somewhere[R0]    ; go to somewhere
     
    @@ -1820,7 +1832,7 @@

    Jumps and conditionals

    The general form is

    -
    +
     if x < y
       then S1
       else S2
    @@ -1832,7 +1844,7 @@ 

    Jumps and conditionals

    and conditional goto:

    -
    +
         if x >= y then goto L1
         S1
         goto L2
    @@ -1842,15 +1854,15 @@ 

    Jumps and conditionals

    -
    -

    Loops

    -
    +
    +

    Loops

    +

    Loops are implemented using compilation patterns based on comparisons and jumps. The fundamental form is the while loop.

    -
    +
     while Bexp do S1
     S2
     
    @@ -1859,7 +1871,7 @@

    Loops

    The compilation pattern is:

    -
    +
     L1   if not Bexp then goto L2
          S2
          goto L1
    @@ -1871,7 +1883,7 @@ 

    Loops

    expressed as a while loop:

    -
    +
     while true do S1
     
    @@ -1879,7 +1891,7 @@

    Loops

    This doesn't need a Boolean expression; it is simply compiled into:

    -
    +
     loop
        instructions for S1
        jump   loop[R0] 
    @@ -1937,7 +1949,7 @@ 

    Loops

    and the containment may go several levels deep.

    -
    +
     if b1
       then S1
            if b2 then S2 else S3
    @@ -1979,9 +1991,9 @@ 

    Loops

    -
    -

    Machine language

    -
    +
    +

    Machine language

    +

    The actual bits representing an instruction (written in hex) (e.g 0d69) are machine language. The actual hardware runs the machine @@ -2129,7 +2141,7 @@

    Machine language

    Example of RRR:

    -
    +
     add  R13,R6,R9
     
    @@ -2183,7 +2195,7 @@

    Machine language

    Format of RX instruction

    -
    +
     load R1,x[R0]
     
    @@ -2206,7 +2218,7 @@

    Machine language

    machine code for load R1,x[R0] is:

    -
    +
     f101
     0008
     
    @@ -2256,19 +2268,19 @@

    Machine language

    -
    -

    Pseudoinstructions

    -
    -
    +
    +

    Pseudoinstructions

    +
    +
     jumpc0 Rd,disp[Ra]
     
    -
    +
     jumpc1 Rd,disp[Ra]
     
    -
    +
     jumplt  someLabel[R0]  ; if <  then goto someLabel
     jumple  someLabel[R0]  ; if <= then goto someLabel
     jumpeq  someLabel[R0]  ; if =  then goto someLabel
    @@ -2279,9 +2291,9 @@ 

    Pseudoinstructions

    -
    -

    A strange program

    -
    +
    +

    A strange program

    +

    Consider ``Program Strange'' below. This program doesn't compute anything particularly useful. It's rather strange and not a model for @@ -2309,7 +2321,7 @@

    A strange program

  • y data -5424
  • -
    +
     ; Strange: A Sigma16 program that is a bit strange    
             load   R1,y[R0]
             load   R2,x[R0]
    @@ -2483,12 +2495,9 @@ 

    A strange program

    -
    -

    Testing and debugging

    -
    -
    -

    Breakpoints

    -
    +
    +

    Breakpoints

    +

    Quick summary, explanation follows. There are two ways to set a breakpoint: @@ -2549,10 +2558,11 @@

    Breakpoints

    external break is better.

    +
    -
      -
    • Trap break
      -
      +
      +

      Trap break

      +

      You can use a trap instruction to break execution when it executes. The first operand of the instruction is a register that must contain @@ -2564,7 +2574,7 @@

      Breakpoints

      in this code.

      -
      +
       ...
       add    R1,R2,R3
       load   R4,x[R1]
      @@ -2579,7 +2589,7 @@ 

      Breakpoints

      the break.

      -
      +
       ...
       add    R1,R2,R3
       lea    R9,4       ; R9 := trap break code
      @@ -2605,10 +2615,11 @@ 

      Breakpoints

      Examples / Testing / Looper.

      -
    • +
    -
  • External break
    -
    +
    +

    External break

    +

    You can also tell the user interface to perform a breakpoint without modifying the program. You need to know the address of the @@ -2640,14 +2651,13 @@

    Breakpoints

    popup again and click Disable.

    -
  • - +
    -
    -

    Summary of Core Architecture

    -
    +
    +

    Summary of Core Architecture

    +

    The following table summarises the instructions in the Core subset of Sigma16. This is an extract from the table for the full architecture @@ -2852,44 +2862,50 @@

    Summary of Core Architecture

    -
    -

    Standard architecture tutorial

    -
    +
    +

    Standard architecture

    -
    -

    Logic

    + +
    +

    Standard architecture tutorials

    +
    -
    -

    Bit fields and shifting

    +
    +

    Logic

    -
    -

    Stack instructions

    +
    +

    Bit fields and shifting

    -
    -

    Saving registers for procedure call

    +
    +

    Stack instructions

    +
    +
    +

    Saving registers for procedure call

    - -
    -

    Arithmetic on natural numbers

    +
    +

    Arithmetic on natural numbers

    -
    -

    Systems architecture tutorial

    -
    + +
    +

    Systems architecture

    +
    -
    -

    System control registers

    +
    +

    Systems architecture tutorials

    +
    -
    -

    Interrupt handlers

    +
    +

    System control registers

    +
    +

    Interrupt handlers

    -
    -

    S32 architecture tutorial

    +

    Sigma16 Architecture reference

    @@ -2932,9 +2948,9 @@

    Sigma16 Architecture reference

    -
    -

    Words

    -
    +
    +

    Words

    +

    Sigma16 uses the following terminology:

    @@ -3038,13 +3054,13 @@

    Words

    -
    -

    Bits and fields

    -
    +
    +

    Bits and fields

    +
    -
    -

    Indexing bits in a word

    -
    +
    +

    Indexing bits in a word

    +

    Bit positions are numbered from right to left, starting with 0. The rightmost (least significant) bit has index 0, and the leftmost @@ -3131,9 +3147,9 @@

    Indexing bits in a word

    -
    -

    Memory

    -
    +
    +

    Memory

    +

    The memory is a hardware array of words that are accessed by address. A memory address is 16 bits wide, and there is one memory location @@ -3169,13 +3185,13 @@

    Memory

    -
    -

    Registers

    -
    +
    +

    Registers

    +
    -
    -

    Register file

    -
    +
    +

    Register file

    +

    The register file is a set of 16 general registers that hold a 16 bit word. A register is referenced by a 4-bit binary number. In @@ -3251,8 +3267,8 @@

    Register file

      -
    • R0 contains the constant 0
      -
      +
    • R0 contains the constant 0
      +

      One of the registers, R0, has a special property: it always contains the constant 0. It is legal to perform an instruction that attempts @@ -3263,8 +3279,8 @@

      Register file

    • -
    • R15 is the condition code register
      -
      +
    • R15 is the condition code register
      +

      Several instructions produce status information: the result of a comparison, whether there was an overflow, etc. This information is @@ -3456,9 +3472,9 @@

      Register file

    -
    -

    Instruction control registers

    -
    +
    +

    Instruction control registers

    +

    There are several instruction control registers that enable the processor to keep track of the state of the running program. These @@ -3481,9 +3497,9 @@

    Instruction control registers

    -
    -

    System control registers

    -
    +
    +

    System control registers

    +
    @@ -3547,8 +3563,8 @@

    System control registers

      -
    • Status register flags
      -
      +
    • Status register flags
      +

      The processor can be executing in several modes, which are determined by the system control registers. @@ -3556,8 +3572,8 @@

      System control registers

    • -
    • req and mask registers
      -
      +
    • req and mask registers
      +

      Interrupt request and mask bits (req and mask registers)

      @@ -3669,9 +3685,9 @@

      System control registers

    -
    -

    Interrupts and exceptions

    -
    +
    +

    Interrupts and exceptions

    +
    • mask
    • @@ -3686,8 +3702,8 @@

      Interrupts and exceptions

      -
    • Mask and request flags
      -
      +
    • Mask and request flags
      +

      <table> <tr> @@ -3753,9 +3769,9 @@

      Interrupts and exceptions

    -
    -

    Instruction representation

    -
    +
    +

    Instruction representation

    +

    Instructions are represented in the memory of the computer using words, just like all other kinds of data. From the programmer's @@ -3918,9 +3934,9 @@

    Instruction representation

    -
    -

    RRR format

    -
    +
    +

    RRR format

    +

    RRR instructions are represented in one word comprising four 4-bit fields. @@ -3958,9 +3974,9 @@

    RRR format

    -
    -

    RX format

    -
    +
    +

    RX format

    +

    RX instructions specify a memory location as well as a register operand. The machine language representation is two words: @@ -4042,9 +4058,9 @@

    RX format

    -
    -

    EXP format

    -
    +
    +

    EXP format

    +

    An EXP instruction contains 14 (hex e) in the op field, and the a and b fields are combined into a single 8-bit number that contains a @@ -4089,9 +4105,9 @@

    EXP format

    -
    -

    EXP3 format

    -
    +
    +

    EXP3 format

    +

    The EXP3 format uses three words to represent an instruction. The first two words have the same layout as for EXP, and the third word @@ -4109,13 +4125,13 @@

    Instructions

    -
    -

    Arithmetic

    -
    +
    +

    Arithmetic

    +
      -
    • add
      -
      +
    • add
      +

      The instruction add Rd,Ra,Rb has operands Ra and Rb and destination Rd. It fetches the operands Ra and Rb, calculates @@ -4169,7 +4185,7 @@

      Arithmetic

      size 3 consists of the bits x.9 x.8 x.7.

      -
      +
       add R1,R2,R3    ; R1 := R2 + R3
       
      @@ -4270,8 +4286,8 @@

      Arithmetic

    • -
    • sub
      -
      +
    • sub
      +

      Example: sub R1,R2,R3 ; R1 := R2 - R3

      @@ -4320,8 +4336,8 @@

      Arithmetic

    • -
    • mul
      -
      +
    • mul
      +

      Example: mul R1,R2,R3 ; R1 := R2 * R3

      @@ -4354,8 +4370,8 @@

      Arithmetic

    • -
    • div
      -
      +
    • div
      +

      Example: div R1,R2,R3 ; R1 := R2 / R3, R15 := R2 rem R3

      @@ -4388,7 +4404,7 @@

      Arithmetic

      For example:
    -
    +
     div    R1,R2,R3       ; R1 := R2/R3, R15 := R2 rem R3
     cmp    R3,R0       ; Did we divide by 0?
     jumpeq zeroDivide[R0] ; If yes, handle error
    @@ -4403,8 +4419,8 @@ 

    Arithmetic

    -
  • addc
    -
    +
  • addc
    +

    The addc instruction performs a binary addition with carry propagation. It adds the two operand registers and the carry bit in @@ -4416,9 +4432,9 @@

    Arithmetic

  • -
  • muln
    -
    -
    +
  • muln
    +
    +
     muln   Rd,Ra,Rb
     
    @@ -4432,9 +4448,9 @@

    Arithmetic

  • -
  • divn
    -
    -
    +
  • divn
    +
    +
     divn   Rd,Ra,Rb
     
    @@ -4459,9 +4475,9 @@

    Arithmetic

    -
    -

    Logic and bits

    -
    +
    +

    Logic and bits

    +

    The instructions in this section treat a word as a sequence of bits, not as a number. There are instructions that perform logic operations @@ -4504,8 +4520,8 @@

    Logic and bits

      -
    • cmp
      -
      +
    • cmp
      +

      The compare instruction cmp Ra,Rb compares the values in the operand registers Ra and Rb, and then sets flags in the condition code @@ -4536,15 +4552,15 @@

      Logic and bits

      by a jump pseudoinstruction, for example:

      -
      +
       cmp     R4,R9      ; compare R4 with R9
       jumpgt  abc]R0]    ; if R4 > R9 then goto abc
       
    • -
    • logicw
      -
      +
    • logicw
      +

      The logicw instruction performs a bitwise logic operation on two operands: each bit of the result is obtained by performing the logic @@ -4921,8 +4937,8 @@

      Logic and bits

    • -
    • logicb
      -
      +
    • logicb
      +

      The logicb instruction performs an arbitrary Boolean logic function on two operand bits, producing a result bit. All three bits must be @@ -4935,7 +4951,7 @@

      Logic and bits

      This logicb instruction performs R1.3 := R1.9 xor R1.2:

      -
      +
       logicb  R1,3,9,2,6
       logicb  d,e,f,g,h
       
      @@ -4958,7 +4974,7 @@

      Logic and bits

      pseudoinstructions:

      -
      +
       invb    R1,3,9     ; R1.3 := !R1.9
       andb    R1,3,9,2   ; R1.3 := R1.9 & R1.2
       orb     R1,3,9,2   ; R1.3 := R1.9 | R1.2
      @@ -4969,7 +4985,7 @@ 

      Logic and bits

      The instruction format is EXP, with the following fields:

      -
      +
       logicb  Rd,e,f,g,h
       
      @@ -4984,8 +5000,8 @@

      Logic and bits

    • -
    • shiftl, shiftr
      -
      +
    • shiftl, shiftr
      +

      The instruction shiftl Rd,Ra,k shifts the value in the operand register Ra by k bits to the left, and the result is placed in the @@ -4994,7 +5010,7 @@

      Logic and bits

      rightmost k bits become 0.

      -
      +
       shiftl  R2,R3,5
       op = e (EXP format)
       d = 2 (destination register)
      @@ -5027,7 +5043,7 @@ 

      Logic and bits

      changed.

      -
      +
       shiftr  R2,R3,5
       
      @@ -5038,8 +5054,8 @@

      Logic and bits

    • -
    • extract, extracti
      -
      +
    • extract, extracti
      +

      The extract instruction copies an arbitrary field of bits from a source register and inserts those bits into an arbitrary position in @@ -5068,7 +5084,7 @@

      Logic and bits

      statement is:

      -
      +
       extract Rd,f,g,Re,h
       
      @@ -5077,7 +5093,7 @@

      Logic and bits

      the corresponding bit in the source field:

      -
      +
       Rd.i := Rs.k
       Rd.i-1 := Rs.k-1
       ...
      @@ -5087,7 +5103,7 @@ 

      Logic and bits

      Example:

      -
      +
       extract R2,7,4,R3,20
       R2.7 := R3.20
       R2.6 := R3.19
      @@ -5147,7 +5163,7 @@ 

      Logic and bits

    • sindex (0..15) is the starting bit index in the source register
    -
    +
     lea      R1,$ffff[R0]     ; ffff
     add      R2,R0,R0         ; 0000
     extract  R2,R1,11,3,4     ; 0f00  R2.11-8 := R1.3-0
    @@ -5221,7 +5237,7 @@ 

    Logic and bits

    Here is another example:

    -
    +
     add      R3,R0,R0
     extract  R3,R1,13,5,1     ; 2000
     lea      R4,$ffff[R0]
    @@ -5235,9 +5251,9 @@ 

    Logic and bits

    -
    -

    Memory

    -
    +
    +

    Memory

    +

    A memory address is a 16-bit binary number. Instructions don't specify addresses directly; they specify an address with two @@ -5264,8 +5280,8 @@

    Memory

      -
    • lea
      -
      +
    • lea
      +

      The load effective address instruction lea Rd,disp[Rx] calculates the effective address of the operand disp[Rx] and places the result in @@ -5275,8 +5291,8 @@

      Memory

    • -
    • load
      -
      +
    • load
      +

      The load instruction load Rd,disp[Rx] calculates the effective address of the operand disp[Rx] and copies the word in memory at the @@ -5296,7 +5312,7 @@

      Memory

      Examples

      -
      +
       load  R12,count[R0]   ; R12 := count
       load  R6,arrayX[R2]   ; R6 := arrayX[R2]
       load  R3,$2b8e[R5]    ; R3 := mem[2b8e+R5]
      @@ -5304,8 +5320,8 @@ 

      Memory

    • -
    • store
      -
      +
    • store
      +

      The store instruction store Rd,disp[Rx] calculates the effective address of the operand disp[Rx] and the value of the destination @@ -5344,7 +5360,7 @@

      Memory

      Examples

      -
      +
       store  R3,$2b8e[R5]
       store  R12,count[R0]
       store  R6,arrayX[R2]
      @@ -5352,8 +5368,8 @@ 

      Memory

    • -
    • Stack representation
      -
      +
    • Stack representation
      +

      Three instructions (push, pop, top) support operations on a stack represented as an array of contiguous elements, where the stack grows @@ -5406,14 +5422,14 @@

      Memory

    • -
    • push
      -
      +
    • push
      +

      The push instruction pushes an element onto a stack. It is RRR format, and its general form is:

      -
      +
       push   Rd,Ra,Rb
       
      @@ -5435,7 +5451,7 @@

      Memory

      and the stack mask bit is set. The operational semantics is:

      -
      +
       if Ra < Rb
         then Ra := Ra + 1; mem[Ra] := Rd
         else R15.sovfl := 1, req.sovfl := 1
      @@ -5458,14 +5474,14 @@ 

      Memory

    • -
    • pop
      -
      +
    • pop
      +

      The push instruction removes an element onto a stack and returns it. The instruction is RRR format, and its general form is:

      -
      +
       pop    Rd,Ra,Rb
       
      @@ -5488,7 +5504,7 @@

      Memory

      semantics is:

      -
      +
       if Ra >= Rb
         then Rd := mem[Ra]; Ra := Ra - 1
         else R15.suvfl := 1, req.suvfl := 1
      @@ -5496,14 +5512,14 @@ 

      Memory

    • -
    • top
      -
      +
    • top
      +

      The top instruction returns the top element on a stack but does not remove it. The instruction is RRR format, and its general form is:

      -
      +
       top    Rd,Ra,Rb
       
      @@ -5525,7 +5541,7 @@

      Memory

      semantics is:

      -
      +
       if Ra >= Rb
         then Rd := mem[Ra]
         else R15.suvfl := 1, req.suvfl := 1
      @@ -5533,8 +5549,8 @@ 

      Memory

    • -
    • save
      -
      +
    • save
      +

      The save instruction stores a sequence of adjacent registers into a block of contiguous memory locations. The sequence of registers is @@ -5557,7 +5573,7 @@

      Memory

      For example, the following save instruction

      -
      +
       save R2,R9,20[R14]
       
      @@ -5565,7 +5581,7 @@

      Memory

      is equivalent to the following sequence of store instructions:

      -
      +
       store  R2,20[R14]
       store  R3,21[R14]
       store  R4,22[R14]
      @@ -5584,7 +5600,7 @@ 

      Memory

      an EXP format instruction:

      -
      +
       save Rd,Re,gh[Rf]
       
      @@ -5616,14 +5632,14 @@

      Memory

      example,

      -
      +
       save    R11,R3,3[R5]
       

      is equivalent to

      -
      +
       store   R11,3[R5]
       store   R12,4[R5]
       store   R13,5[R5]
      @@ -5637,15 +5653,15 @@ 

      Memory

    • -
    • restore
      -
      +
    • restore
      +

      Restore Rd,disp[Ra] loads R1, …, Rd from consecutive memory locations starting from the effective address. For example,

      -
      +
       restore R5,20[R14]
       
      @@ -5653,7 +5669,7 @@

      Memory

      is equivalent to

      -
      +
       load   R1,20[R14]
       load   R2,21[R14]
       load   R3,22[R14]
      @@ -5692,7 +5708,7 @@ 

      Memory

      For example, consider this instruction:

      -
      +
       restore  R3,R10,4[R14]
       
      @@ -5700,7 +5716,7 @@

      Memory

      The effect is equivalent to

      -
      +
       load  R3,4[R14]
       load  R4,5[R14]
       load  R5,6[R14]
      @@ -5715,32 +5731,32 @@ 

      Memory

    -
    -

    Flow of control

    -
    +
    +

    Flow of control

    +
      -
    • jump
    • -
    • jumpc0, jumpc1
    • -
    • jal
    • -
    • jumpz, jumpnz
    • +
    • jump
    • +
    • jumpc0, jumpc1
    • +
    • jal
    • +
    • jumpz, jumpnz
    -
    -

    System

    -
    +
    +

    System

    +
      -
    • trap
    • -
    • getctl, putctl
    • -
    • resume
    • +
    • trap
    • +
    • getctl, putctl
    • +
    • resume
    -
    -

    Assembly language instruction formats with examples

    -
    +
    +

    Assembly language instruction formats with examples

    +
  • @@ -5836,9 +5852,9 @@

    Assembly language instruction formats with examples

    -
    -

    Instruction set

    -
    +
    +

    Instruction set

    +

    @@ -6594,8 +6610,8 @@

    Instruction set

      -
    • Pseudoinstructions
      -
      +
    • Pseudoinstructions
      +

      save save | RX | RX | f,9 | M[ea] := R1, …, M[ea+d-1] := Rd M[Rb+ofs+(f-e+1)] := Rf | @@ -6608,11 +6624,11 @@

      Instruction set

      -
      -

      Sigma32 Architecture reference

      -
      +
      +

      Sigma32 architecture

      +

      -(Future extension - no currently available) +(Future extension - not currently available)

      @@ -6638,9 +6654,9 @@

      Sigma32 Architecture reference

      -
      -

      Assembly language reference

      -
      +
      +

      Assembly language reference

      +

      :CUSTOMID: sec-assembly-language

      @@ -6697,7 +6713,7 @@

      Assembly language reference

      Assembly language

      -
      +
       add    R3,R5,R1
       sub    R4,R2,R3
       mul    R1,R9,R10   
      @@ -6706,16 +6722,16 @@ 

      Assembly language reference

      Machine language

      -
      +
       0351
       1423
       219a
       
      -
      -

      Assembly language statement formats

      -
      +
      +

      Assembly language statement formats

      +

      Assembly language statements generally correspond to the instruction formats, but there is not an exact correspondence for several reasons: @@ -6889,9 +6905,9 @@

      Assembly language statement formats

      -
      -

      Programs, modules, and files

      -
      +
      +

      Programs, modules, and files

      +

      The assembler inputs a program in assembly language. Its primary output is an object module which contains the machine language code. @@ -6926,9 +6942,9 @@

      Programs, modules, and files

      -
      -

      Values

      -
      +
      +

      Values

      +

      A value is a 16-bit word. An assembly language program uses expressions to denote values, but the actual underlying quantity is a @@ -6951,9 +6967,9 @@

      Values

    -
    -

    Expressions

    -
    +
    +

    Expressions

    +

    An expression is syntax that denotes a value.

    @@ -7149,9 +7165,9 @@

    Expressions

    -
    -

    Location counter

    -
    +
    +

    Location counter

    +

    The assembler maintains a variable called the location counter, which is the address where the next word of object code will be loaded. The @@ -7175,9 +7191,9 @@

    Location counter

    -
    -

    Attributes

    -
    +
    +

    Attributes

    +

    A machine language program consists of words stored in memory at particular addresses. A word is just a collection of 16 bits; it has @@ -7209,9 +7225,9 @@

    Attributes

    -
    -

    Code statements

    -
    +
    +

    Code statements

    +

    Each line of source code is an assembly language statement. Unlike higher level languages, assembly language statements are not nested. @@ -7262,9 +7278,9 @@

    Code statements

    -
    -

    Instructions

    -
    +
    +

    Instructions

    +
    @@ -7333,9 +7349,9 @@

    Instructions

    -
    -

    data

    -
    +
    +

    data

    +

    The data statement specifies a sequence of constants to be placed in consecutive memory locations starting at the location counter, subject @@ -7348,7 +7364,7 @@

    data

    Suppose x1, x2, etc are 4-digit hex constants. Then

    -
    +
     data  x1,x2,x3,x4,x5,x6
     
    @@ -7356,7 +7372,7 @@

    data

    is equivalent to

    -
    +
     data x1,x2,x3
     data x4,x5,x6
     
    @@ -7386,9 +7402,9 @@

    data

    -
    -

    Directives

    -
    +
    +

    Directives

    +

    A directive is an assembly language statement that gives further information about how to translate the program to object code and how @@ -7397,9 +7413,9 @@

    Directives

    -
    -

    module

    -
    +
    +

    module

    +

    A program may be organized as a collection of modules, where each module appears in a separate file. When several modules are present, @@ -7409,7 +7425,7 @@

    module

    code for module named abc:

    -
    +
     abc   module 
     
    @@ -7443,10 +7459,10 @@

    module

    -
    -

    equ

    -
    -
    +
    +

    equ

    +
    +
     codeWrite  equ  2
     codeRead   equ  1
     
    @@ -7455,7 +7471,7 @@

    equ

    The expression in an equ can calculate the size of an object:

    -
    +
     astart     data 5
                data 9
                data 78
    @@ -7465,10 +7481,10 @@ 

    equ

    -
    -

    block

    -
    -
    +
    +

    block

    +
    +
     asize   equ    100
     n       data   asize
     arr     block  asize
    @@ -7476,9 +7492,9 @@ 

    block

    -
    -

    org

    -
    +
    +

    org

    +

    The org statement sets the location counter to a specified address. Subsequent instructions and data will be placed in memory at @@ -7510,9 +7526,9 @@

    org

    -
    -

    import

    -
    +
    +

    import

    +

    The import statement states that the value of an identifier is defined in another module. During the assembly of the module containing the @@ -7520,7 +7536,7 @@

    import

    will be replaced by the actual value by the linker. For example,

    -
    +
     x   import  Mod1,x
     y   import  Mod1,abc
     
    @@ -7533,9 +7549,9 @@

    import

    -
    -

    export

    -
    +
    +

    export

    +

    An export statement says that the module is making the value of a symbol available for use in other modules, which may import it. The @@ -7546,7 +7562,7 @@

    export

    Examples:

    -
    +
     export  haltcode,0
     export  fcn,002c
     
    @@ -7558,7 +7574,7 @@

    export

    it:

    -
    +
     Mod1     module
              export fcn
     
    @@ -7593,9 +7609,9 @@ 

    export

    -
    -

    Summary of assembly language statements

    -
    +
    +

    Summary of assembly language statements

    +
    @@ -7659,13 +7675,13 @@

    Summary of assembly language statements

    -
    -

    User interface

    -
    +
    +

    User interface

    +
    -
    -

    Files and modules

    -
    +
    +

    Files and modules

    +
    • In Modules tab, click Choose Files
        @@ -7677,9 +7693,9 @@

        Files and modules

    -
    -

    Simple standalone programs

    -
    +
    +

    Simple standalone programs

    +

    If a program does not import any names, it is standalone. The text of the program is shown in the editor pane. Go to the Assembler pane @@ -7691,9 +7707,9 @@

    Simple standalone programs

    -
    -

    Programs with multiple modules

    -
    +
    +

    Programs with multiple modules

    +

    A module consists of program text, and it may have an optional file, and an optional module name. @@ -7819,9 +7835,9 @@

    Linker

    -
    -

    Object language

    -
    +
    +

    Object language

    +

    Object code is expressed in a textual language, so the object code readable to a human (at least, for a human who understands machine @@ -7856,20 +7872,20 @@

    Object language

    -
    -

    Statement syntax

    +
    +

    Statement syntax

    -
    -

    module

    +
    +

    module

    -
    -

    org

    +
    +

    org

    -
    -

    data

    -
    +
    +

    data

    +

    data x0,x1,…,xj-1

    @@ -7879,21 +7895,21 @@

    data

    location counter. For each word x, the linker performs:

    -
    +
     mem[llc] := x
     llc := llc + 1
     
    -
    -

    import

    -
    +
    +

    import

    +

    General form

    -
    +
     import  modName,externalName,address,field
     
    @@ -7901,21 +7917,21 @@

    import

    Examples

    -
    +
     import  Mod2,abc,03c4,dist
     import  Mod3,ybit,03be,g
     
    -
    -

    export

    +
    +

    export

    -
    -

    relocate

    -
    +
    +

    relocate

    +

    The relocate statement specifies a list of addresses of words that must be relocated. Suppose the value x is specified in a relocate @@ -7923,7 +7939,7 @@

    relocate

    the linker will set mem[x+y] = obj[x]+y.

    -
    +
     relocate hex4,hex4,...
     
    @@ -7943,7 +7959,7 @@

    relocate

    code[addr] := code[addr] + llc

    -
    +
     relocate  addr,addr,...,addr
     
    @@ -7954,9 +7970,9 @@

    relocate

    -
    -

    Module metadata

    -
    +
    +

    Module metadata

    +

    The assembler and linker create metadata files which enable the emulator to show the assembly language statement corresponding to the @@ -8033,7 +8049,7 @@

    Module metadata

    Here is an example of a metadata file:

    -
    +
     fasmap 17
     14,14,15,15,16,16,17,17,18,19
     19,20,20,21,21,22,24
    @@ -8046,9 +8062,9 @@ 

    Module metadata

    -
    -

    Linker

    -
    +
    +

    Linker

    +
    • GUI: selected module is main program and also receives the executable. All other modules are linked, and their object code is @@ -8061,13 +8077,13 @@

      Linker

    -
    -

    Loader

    -
    +
    +

    Loader

    +
    -
    -

    Executable code

    -
    +
    +

    Executable code

    +

    An executable module is written in the same language as object modules. The only difference is that an executable module must @@ -8100,15 +8116,15 @@

    Programming

    -
    -

    Structure of a program

    -
    +
    +

    Structure of a program

    +

    Simple ("static") variabls need to be declared with a data statement, which also gives an initial value.

    -
    +
     x  data  23
     
    @@ -8120,13 +8136,13 @@

    Structure of a program

    -
    -

    How to perform commmon tasks

    -
    +
    +

    How to perform commmon tasks

    +
    -
    -

    Using extract

    -
    +
    +

    Using extract

    +

    A special case is to move a Boolean from one place to another.

    @@ -8193,7 +8209,7 @@

    Using extract

    Example:

    -
    +
     field   R3,4,  ; R3 := 0fc0
     
    @@ -8209,16 +8225,16 @@

    Using extract

    -
    -

    Copying one register to another

    -
    +
    +

    Copying one register to another

    +

    Sometimes you want to copy a value from one register to another: R3 := R12. There isn't an instruction specifically for this purpose, because there is no need: just use the add instruction:

    -
    +
     add R3,R12,R0 ; R3 := R12
     
    @@ -8232,9 +8248,9 @@

    Copying one register to another

    -
    -

    Compilation

    -
    +
    +

    Compilation

    +

    There are two ways to handle variables:

    @@ -8259,7 +8275,7 @@

    Compilation

    language, using each style:

    -
    +
     x = 50;
     y = 2*z;
     x = x+1+z;
    @@ -8269,7 +8285,7 @@ 

    Compilation

    Statement-by-statement style

    -
    +
     ; x = 50;
          lea    R1,$0032   ; R1 = 50
          store  R1,x[R0]   ; x = 50
    @@ -8293,7 +8309,7 @@ 

    Compilation

    Register-variable style

    -
    +
     ; Usage of registers
     ;   R1 = x
     ;   R2 = y
    @@ -8347,19 +8363,19 @@ 

    Compilation

    -
    -

    Errors: avoiding, finding, and fixing

    -
    +
    +

    Errors: avoiding, finding, and fixing

    +
    -
    -

    Critical regions

    -
    +
    +

    Critical regions

    +

    A testset instruction is not semantically equivalent to a load followed by a store. Consider this example:

    -
    +
     ; (1) testset
          testset   R1,mutex[R0]
     
    @@ -8368,7 +8384,7 @@

    Critical regions

    It is not the same as

    -
    +
     ; (2) sequence of instructions
          load     R1,mutex[R0]
          lea      R2,1[R0]
    @@ -8397,9 +8413,9 @@ 

    Critical regions

    -
    -

    Robust programming

    -
    +
    +

    Robust programming

    +

    *Use a systematic programming process

    @@ -8439,13 +8455,13 @@

    Robust programming

    -
    -

    Error messages

    +
    +

    Error messages

    -
    -

    Runtime debugging

    -
    +
    +

    Runtime debugging

    +

    What if an instruction doesn't do what you expected?

    @@ -8472,9 +8488,9 @@

    Runtime debugging

    -
    -

    Breakpoints

    -
    +
    +

    Breakpoints

    +

    (Note: the breakpoint system is not fully implemented yet; the following describes a temporary breakpoint facility.) @@ -8520,9 +8536,9 @@

    Breakpoints

    -
    -

    Installation

    -
    +
    +

    Installation

    +

    You can run most of Sigma16 in a web browser – there's nothing to download, nothing to install. Visit the [Sigma16 home @@ -8533,9 +8549,9 @@

    Installation

    -
    -

    Command line tools

    -
    +
    +

    Command line tools

    +

    Sigma16 also contains some advanced features that use the command line in a shell. These features include text commands for @@ -8548,13 +8564,13 @@

    Command line tools

    -
    -

    node and npm

    +
    +

    node and npm

    -
    -

    Configuring the shell

    -
    +
    +

    Configuring the shell

    +

    Shell running bash

    @@ -8565,7 +8581,7 @@

    Configuring the shell

    location. In a bash shell running on cygwin, try /Users/yourlogin.

    -
    +
     SIGMA16=/Users/yourlogin/Documents/path/to/SigmaProject/Sigma16
     export SIGMA16
     alias helloworld="node ${SIGMA16}/app/helloworld.js"
    @@ -8573,19 +8589,19 @@ 

    Configuring the shell

    -
    -

    Testing the installation

    -
    -
    +
    +

    Testing the installation

    +
    +
     $ node --version
     v16.5.0
     
    -
    -

    Building Sigma16

    -
    +
    +

    Building Sigma16

    +

    The Web version of Sigma16 contains several files that need to be built from source. Of course, if you launch the app from the Sigma16 @@ -8597,11 +8613,11 @@

    Building Sigma16

    Use emacs to build *.html from source *.org

    -
    +
     ^C ^E h h
     
    -
    +
     $ npm install -g wabt
     $ wat2wasm emcore.wat --enable-threads
     
    @@ -8615,9 +8631,9 @@

    About Sigma16

    -
    -

    Copyright and license

    -
    +
    +

    Copyright and license

    +

    The architecture, software tools, and documentation were designed, implemented, and written by John O'Donnell. Contact email: @@ -8647,9 +8663,9 @@

    Copyright and license

    -
    -

    In case of problems

    -
    +
    +

    In case of problems

    +

    If you encounter a problem with the app, please file a bug report. It is essential in a bug report (for any software, not just Sigma16) to @@ -8677,13 +8693,13 @@

    In case of problems

    -
    -

    Release notes

    -
    +
    +

    Release notes

    +
    -
    -

    Version 3.4.0

    -
    +
    +

    Version 3.4.0

    +
    • Bit indexing is changed to "little end" style. The least significant bit has index 0, and the most significant bit has @@ -8696,9 +8712,9 @@

      Version 3.4.0

    -
    -

    Version 3.3.2, April 2021

    -
    +
    +

    Version 3.3.2, April 2021

    +
    • There is no change in the architecture
    • The software is modified to enable it to continue working when a @@ -8708,12 +8724,12 @@

      Version 3.3.2, April 2021

    -
    -

    Version 3.2.3, development from April 2021

    +
    +

    Version 3.2.3, development from April 2021

    -
    -

    Version 3.2.2, March 2021

    -
    +
    +

    Version 3.2.2, March 2021

    +
    • A bug in breakpoints is fixed
    • In addition, there is a new way to specify breakpoings using trap
    • @@ -8723,9 +8739,9 @@

      Version 3.2.2, March 2021

    -
    -

    Version 3.2.1, February 2021

    -
    +
    +

    Version 3.2.1, February 2021

    +

    Version 3.2 brings several changes that will be visible to users of previous versions of Sigma16: @@ -8742,7 +8758,7 @@

    Version 3.2.1, February 2021

    the conditional jumps.) Here's an example: -
    +
     ; Old style -- these instructions have been removed
          cmplt   R1,R2,R3      ; R1 := R2 < R3
          jumpt   R1,loop[R0]   ; if R2 < R3 then goto loop
    @@ -8826,9 +8842,9 @@ 

    Version 3.2.1, February 2021

    -
    -

    Text of GPL3 License

    -
    +
    +

    Text of GPL3 License

    +

    GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -9262,7 +9278,7 @@

    Text of GPL3 License

    Author: John T. O'Donnell

    -

    Created: 2021-12-20 Mon 15:49

    +

    Created: 2022-01-13 Thu 11:15

    Validate

    diff --git a/docs/UserGuide/Sigma16UserGuide.org b/docs/UserGuide/Sigma16UserGuide.org index 83372b0..75a233a 100644 --- a/docs/UserGuide/Sigma16UserGuide.org +++ b/docs/UserGuide/Sigma16UserGuide.org @@ -38,10 +38,7 @@ Sigma16 is a computer architecture designed for research and teaching in computer systems. The architecture is simple yet -powerful. It is organized into subsets to make it easier to use: -the core subset is suitable for beginners, the standard subset -offers flexible programming techniques, and the full system supports -the study of systems programming. +powerful. This application provides a complete environment for experimenting with the architecture. It includes an editor, assembler, linker, @@ -58,23 +55,35 @@ the Installation section. There is also a digital circuit these tools, machine language programs can run on both the emulator and the circuit. -For a quick start, begin with the tutorials, which introduce the -architecture step by step. The tutorials explain the machine, show -how to program it, and demonstrate how to enter and run a program -and how to use the programming environment. - -The remainder of the user guide is organised by topic, with chapters -on the architecture, the assembly language, the linker, and -programming techniques. - -* Tutorials +The architecture is organized into subsets to make it easier to use: +- The *Core* subset contains a small and simple instruction set which + is a good starting point for learning about computer architecture. + Although it is simple, Core is powerful enough to support realistic + programming. +- The *Standard* subset offers flexible programming techniques, + including manipulation of bits and fields, arithmetic on natural + numbers and arbitrary precision integers, and concise support for + stack frames. +- The full *System* supports the study of systems programming. It + supports interrupts, concurrent processes, and mutual exclusion. +Core is a subset of Standard, which is a subset of System. To learn +the full architecture, start with Core and then go on to Standard and +System. + +For a quick start, begin with the Core architecture tutorials, which +introduce the architecture step by step. The tutorials explain the +machine, show how to program it, and demonstrate how to enter and run +a program and how to use the programming environment. A reference +section follows the tutorials. + +* Core architecture The following short tutorials introduce the system; full details appear in later sections. You can keep the tutorials visible in the right panel while following along with the exercises in the main panel. -** Core architecture tutorial +** Core architecture tutorials :PROPERTIES: :CUSTOM_ID: sec-core-tutorial :END: @@ -1562,7 +1571,6 @@ commercial computers that achieve success in the marketplace eventually become encrusted with complications that help support backward compatibility; this can lead to great complexity. -*** Testing and debugging *** Breakpoints Quick summary, explanation follows. There are two ways to set a @@ -1609,7 +1617,7 @@ to modify the program or reassemble it, or if you realise that you want a breakpoint after execution has already started, then an external break is better. -**** Trap break +*** Trap break You can use a trap instruction to break execution when it executes. The first operand of the instruction is a register that must contain @@ -1651,7 +1659,7 @@ to resume full speed execution. For an example of a long running program with a trap break, see Examples / Testing / Looper. -**** External break +*** External break You can also tell the user interface to perform a breakpoint without modifying the program. You need to know the address of the @@ -1677,7 +1685,7 @@ that location is encountered. To prevent this, open the breakpoint popup again and click Disable. -*** Summary of Core Architecture +** Summary of Core Architecture The following table summarises the instructions in the Core subset of Sigma16. This is an extract from the table for the full architecture @@ -1719,18 +1727,22 @@ Assembly directives - data -** Standard architecture tutorial -*** Logic -*** Bit fields and shifting -*** Stack instructions -*** Saving registers for procedure call +* Standard architecture + +* Standard architecture tutorials +** Logic +** Bit fields and shifting +** Stack instructions +** Saving registers for procedure call +** Arithmetic on natural numbers -*** Arithmetic on natural numbers -** Systems architecture tutorial +* Systems architecture + +** Systems architecture tutorials *** System control registers *** Interrupt handlers -** S32 architecture tutorial + * Sigma16 Architecture reference :PROPERTIES: @@ -3462,9 +3474,9 @@ Instructions marked x are not are not implemented in this version. restore | | RX | RX | f,a | R1 := M[ea], ..., Rd := M[ea+d-1] | -* Sigma32 Architecture reference +* Sigma32 architecture -(Future extension - no currently available) +(Future extension - not currently available) Sigma16 consists of a 16-bit architecture (S16) and a 32 bit extended architecture (S32). This section discusses diff --git a/docs/welcome/welcome.html b/docs/welcome/welcome.html index b43d9d4..b92c477 100644 --- a/docs/welcome/welcome.html +++ b/docs/welcome/welcome.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -220,11 +220,11 @@

    Sigma16

    -Version 3.4.1, November 2021. +Version 3.4.1, January 2022. -
    -

    Overview

    -
    +
    +

    Overview

    +

    Sigma16 is a computer architecture designed for research and teaching in computer systems. This application provides a complete environment @@ -243,9 +243,9 @@

    Overview

    -
    -

    Getting started

    -
    +
    +

    Getting started

    +

    The User Guide begins with a set of tutorials that introduce the system. The best place to start is with the Hello, World! tutorial. @@ -261,9 +261,9 @@

    Getting started

    -
    -

    Updates and further information

    -
    +
    +

    Updates and further information

    +
    The Sigma16 Home Page contains a link to run the latest version as well as up-to-date information on the system. It's @@ -277,9 +277,9 @@

    Updates and further information

    -
    -

    License

    -
    +
    +

    License

    +

    License: GNU GPL Version 3 or later.

    @@ -306,7 +306,7 @@

    License

    -

    Created: 2021-11-14 Sun 15:35

    +

    Created: 2022-01-10 Mon 20:22

    Validate

    diff --git a/src/base/assembler.mjs b/src/base/assembler.mjs index 9e0f380..3f95ba6 100644 --- a/src/base/assembler.mjs +++ b/src/base/assembler.mjs @@ -43,7 +43,7 @@ export class AsmInfo { this.modName = "anonymous"; // defined in optional module statement this.text = ""; // raw source text this.asmSrcLines = []; // list of lines of source text - this.asmStmt = []; // statements correspond to lines of source + this.asmStmt = []; // statements correspond to source lines this.symbols = []; // symbols used in the source this.symbolTable = new Map (); // symbol table this.locationCounter = 0; // next code address @@ -539,10 +539,10 @@ comments field contains any characters */ -const identParser = /^[a-zA-Z][a-zA-Z0-9_]*$/; -const nameParser = /^[a-zA-Z][a-zA-Z0-9_]*$/; -const intParser = /^-?[0-9]+$/; -export const hexParser = /^\$([0-9a-f]{4})$/; +const identParser = /^[a-zA-Z][a-zA-Z0-9_]*$/ +const nameParser = /^[a-zA-Z][a-zA-Z0-9_]*$/ +const intParser = /^-?[0-9]+$/ +export const hexParser = /^\$([0-9a-f]{4})$/ const rcParser = /^R([0-9a-f]|(?:1[0-5])),([a-zA-Z][a-zA-Z0-9]*)$/; @@ -623,9 +623,7 @@ const parseSplitFields = new RegExp(regexpSplitFields); // const xParser = /^([-a-zA-Z0-9_\$]+)\[(R|r)([0-9a-f]|(?:1[0-5]))\]/; - function requireX (ma, s, field) { - console.log (`requireX <${field}>`) const xrParser = /^([^\[]+)\[(.*)\]$/ let disp = "0" let index = 0 @@ -635,6 +633,9 @@ function requireX (ma, s, field) { const regsrc = xr[2] index = requireReg (ma, s, regsrc) // disp = field console.log (`requireX parse failed`) + } else { // allow [R0] to be omitted + disp = field + index = 0 } const result = {disp, index} console.log (`requireX field=${field} disp=<${disp}> index=${index}`) @@ -684,6 +685,14 @@ function requireNoperands (ma, s, n) { // k4 is always fixed, never relocatable +function requireK16 (ma, s, field, xs) { + com.mode.devlog (`requireK4 <${xs}>`); + const a = s.address.word; + const v = evaluate (ma, s, a, xs); + const result = v.word; + return result; +} + function requireK4 (ma, s, field, xs) { com.mode.devlog (`requireK4 <${xs}>`); const a = s.address.word; diff --git a/src/server/sigserver.mjs b/src/server/sigserver.mjs index a55aa4a..7c6d193 100644 --- a/src/server/sigserver.mjs +++ b/src/server/sigserver.mjs @@ -155,7 +155,22 @@ express.static.mime.define({'text/html': ['html']}); app.get ('/', (req,res) => { console.log (`responding-/`) - res.sendFile (path.join (S16_BUILD_DIR, 'index.html')) + res.sendFile (path.join ('/app', 'topindex.html')) +}) + +app.get ('/index.html', (req,res) => { + console.log (`responding-/-index.html`) + res.sendFile (path.join ('/app', 'topindex.html')) +}) + +app.get ('/default.html', (req,res) => { + console.log (`responding-/-default.html`) + res.sendFile (path.join ('/app', 'topindex.html')) +}) + +app.get ('/docstyle.css', (req,res) => { + console.log (`responding-/`) + res.sendFile (path.join ('/app', 'docstyle.css')) }) //-----------------------------------------------------------------------