visualqub

The visualqub shows how a stack machine works. You can write a program and watch the execution step by step.

Contents

  1. Screen layout
  2. Numeric panel
  3. Control panel
  4. Program panel
  5. Source code

 


1. Screen layout

1.1. Display

Top: program text.

Bottom left: output stack, data stack.

1.2. Controls

Bottom right: numeric panel / control panel.

Left: program panel.

 


2. Numeric panel

2.1. General

[.] dotn — 
{ output = n }
[<] backspace 
{ erase }

2.2. Numbers

buttoneffectdescription
0..9 
{ buffer += digit }
[ ] space—  n
{ n = int(buffer) }

2.3. Arithmetic

buttoneffectdescription
+x y  —  n
{ n = x + y }
-x y  —  n
{ n = x - y }
*x y  —  n
{ n = x * y }
/x y  —  r q
{ (quotient, remainder) = x / y }

2.4. Memory

buttoneffectdescription
X!x  —
{ X = n }
X?—  x
{ n = X }
Y!x  —
{ Y = n }
Y?—  x
{ n = Y }

 


3. Control panel

3.1. Logical operators

operatoreffectdescription
ANDx y  —  n
if (x==0 || y==0) { n = 0 } else { n = -1 }
ORx y  —  n
if (x<>0 && y<>0) { n = 0 } else { n = -1 }
NOTx  —  n
if (x==0) { n = -1 } else { n = 0 }

3.2. Relational operators

operatoreffectdescription
<x y  —  b
if (x<y) { b = -1 } else { b= 0 }
>x y  —  b
if (x>y) { b = -1 } else { b = 0 }
=x y  —  b
if (x==y) { b = -1 } else { b = 0 }

3.3. Control flow

operatoreffectdescription
BEGIN ... WHILEx —
do { ... } while (x<>0)
IF ... THENx —
if (x<>0) { ... }

3.4. Stack operators

operatoreffectdescription
DUPx y  —  x y y
duplicate top of data stack
OVERx y  —  x y x
duplicate second of data stack
DROPx y  —  x
remove top of data stack
SWAPx y  —  y x
{ x, y = y, x }

 


4. Program panel

buttoneffectdescription
CLEAR
clear the program text
EMPTY xxx  — 
empty the data and output stacks
ABORT
abort execution, rewind the cursor, clear variables and messages
STEP
execute the word under the cursor
RUN
step every second

 


5. Source code

5.1. Graphical interface

Image. ImageList

Button. Image, Hit test, Handler.

Panel.

Font.

String. stralign

5.2. Virtual machine

Stack. Data, Output, Control

Word.

Exception.

Message.

Automation.