-Gordon
I just missed it myself - by 1977 getting "hands-on" to a computer was a practicality, so it must have been falling out of use by then...Ravenous wrote:Suddenly I feel very old.
"JINEG" is the only thing I remember about it now... apart from having to write my programs on those squared paper coding sheets they gave out.
Code: Select all
BEGIN{
pc=0
dc=0
lc=0
INCODE=1
for(i=0;i<100;i++) validvalue[i]=""
if (DEBUG==1) printf("Running in DEBUG mode.\nParsing program ...\n")
}
{
if ((NF > 0) && (substr($0,1,1) != "*"))
{
if (INCODE == 1)
{
OPERAND = ""
INSTRUCTION = ""
LABEL = ""
HASALABEL=1
INPUTLINE=$0
gsub("\t"," ",INPUTLINE)
if (substr(INPUTLINE,1,1) == " ") HASALABEL = 0
if (HASALABEL == 0)
{
INSTRUCTION = $1
opstart = 2
}
else
{
LABEL = $1
INSTRUCTION = $2
validlabel[LABEL] = LABEL
labellocation[LABEL] = pc
labelname[lc] = LABEL
lc++
opstart = 3
}
if (NF >= opstart)
{
/* need to fix spacing retention */
WORD = $opstart
gsub("\"","",WORD)
OPERAND = WORD
for(word=opstart+1;word<=NF;word++)
{
WORD = $word
gsub("\"","",WORD)
OPERAND = OPERAND " " WORD
}
}
if (INSTRUCTION == "%")
{
INCODE=0
}
else
{
label[pc] = LABEL
instruction[pc] = INSTRUCTION
operand[pc] = OPERAND
LASTINSTRUCTION = INSTRUCTION
pc++
}
}
else
{
data[dc] = $1
for(word=2;word<=NF;word++)
{
data[dc] = data[dc] " " $word
}
dc++
}
}
else
{
if (DEBUG==1) print "cesil: blank line ignored at " NR
}
}
END{
if (DEBUG==1)
{
print "Program:"
TAB = "|"
for(ip=0;ip<pc;ip++)
{
PAD = ""
if (ip < 100) PAD = "0"
if (ip < 10) PAD = "00"
print TAB PAD ip TAB label[ip] TAB instruction[ip] TAB operand[ip] TAB
}
print "Labels:"
for(lp=0;lp<lc;lp++)
{
LABEL = labelname[lp]
print LABEL " = " labellocation[LABEL]
}
printf("Data:");
for(dp=0;dp<dc;dp++)
{
printf(" %s",data[dp])
}
printf("\nRunning program ...\n")
}
RUNNING=1
IP=0
NEXTIP=0
DP=0
ACCUMULATOR=0
for(;RUNNING==1;)
{
IP = NEXTIP
LABEL = label[IP]
INSTRUCTION = instruction[IP]
OPERAND = operand[IP]
NEXTIP=IP+1
if (DEBUG==1)
{
print TAB IP TAB LABEL TAB INSTRUCTION TAB OPERAND TAB
}
if (INSTRUCTION == "STORE")
{
validvalue[OPERAND] = OPERAND
value[OPERAND] = ACCUMULATOR
if (DEBUG==1) print ">>> STORE " OPERAND " = " value[OPERAND]
}
if (INSTRUCTION == "LOAD")
{
VALUE = OPERAND
if (validvalue[OPERAND] == OPERAND) VALUE=value[OPERAND]
ACCUMULATOR = VALUE
if (DEBUG==1) print ">>> LOAD ACCUMULATOR = " ACCUMULATOR
if (VALUE == "")
{
printf("error: no value for OPERAND " OPERAND " at line %d\n",IP);
RUNNING=0;
}
}
if (INSTRUCTION == "IN")
{
if (DP == dc)
{
printf("error: out of data at line %d\n",IP);
RUNNING=0;
}
else
{
ACCUMULATOR = data[DP]
DP++;
}
}
if (INSTRUCTION == "PRINT")
{
printf(OPERAND);
}
if (INSTRUCTION == "OUT")
{
printf("%s",ACCUMULATOR);
}
if (INSTRUCTION == "LINE")
{
printf("\n");
}
if (INSTRUCTION == "ADD")
{
VALUE = OPERAND
if (validvalue[OPERAND] == OPERAND) VALUE= value[OPERAND]
ACCUMULATOR = ACCUMULATOR + VALUE
if (DEBUG==1) print ">>> ACCUMULATOR ADD " VALUE " = " ACCUMULATOR
}
if (INSTRUCTION == "SUBTRACT")
{
VALUE = OPERAND
if (validvalue[OPERAND] == OPERAND) VALUE= value[OPERAND]
ACCUMULATOR = ACCUMULATOR - VALUE
if (DEBUG==1) print ">>> ACCUMULATOR SUBTRACT " VALUE " = " ACCUMULATOR
}
if (INSTRUCTION == "MULTIPLY")
{
VALUE = OPERAND
if (validvalue[OPERAND] == OPERAND) VALUE= value[OPERAND]
ACCUMULATOR = ACCUMULATOR * VALUE
if (DEBUG==1) print ">>> ACCUMULATOR MULTIPLY " VALUE " = " ACCUMULATOR
}
if (INSTRUCTION == "DIVIDE")
{
VALUE = OPERAND
if (validvalue[OPERAND] == OPERAND) VALUE= value[OPERAND]
if (VALUE == 0)
{
printf("error: divide by zero at line %d\n",IP);
RUNNING=0;
}
else
{
ACCUMULATOR = int(ACCUMULATOR / VALUE)
}
if (DEBUG==1) print ">>> ACCUMULATOR DIVIDE " VALUE " = " ACCUMULATOR
}
if (INSTRUCTION == "HALT")
{
RUNNING=0;
if (debug==1) printf("warning: program halted at line %s\n",IP);
}
if (INSTRUCTION == "JUMP")
{
if (validlabel[OPERAND] == OPERAND)
{
NEXTIP = labellocation[OPERAND]
}
else
{
RUNNING=0;
printf("error: undefined label %s line %s\n",OPERAND,IP);
}
}
if (INSTRUCTION == "JIZERO")
{
if (ACCUMULATOR == 0)
{
if (validlabel[OPERAND] == OPERAND)
{
NEXTIP = labellocation[OPERAND]
}
else
{
RUNNING=0;
printf("error: undefined label %s line %s\n",OPERAND,IP);
}
}
}
if (INSTRUCTION == "JINEG")
{
if (ACCUMULATOR < 0)
{
if (validlabel[OPERAND] == OPERAND)
{
NEXTIP = labellocation[OPERAND]
}
else
{
RUNNING=0;
printf("error: undefined label %s line %s\n",OPERAND,IP);
}
}
}
}
if (DEBUG==1) printf("Program finished.\n")
}
Just have a look on thd MagPi site - the pre-release is up ..SN wrote:Don't know whats coming in MAGPI but I'll post it again - written by me earlier in the year a home grown CESIL interpreter written in awk - will run right on your PI with no issue!
Kids today think producing html is programming... and not a dtd to SGML, which they've never heard of.JonB wrote:Oh gawd, CESIL - "Computer Education in Schools Instructional Language"...
You tell that to the kids of today.... and they wouldn't believe a word of it!
Have a look at the MagPi thing then, I'll probably blog the page on my own site in a week or so too, once it's been properly published, but if you want to dive in, you'll need my BASIC intrepreter, and:Wizard wrote:Kids today think producing html is programming... and not a dtd to SGML, which they've never heard of.JonB wrote:Oh gawd, CESIL - "Computer Education in Schools Instructional Language"...
You tell that to the kids of today.... and they wouldn't believe a word of it!
Assembler is unheard of and C is the name of the vitamins they eat since they don't eat enough fruit.![]()
Another thing I find sad is the vast mountain of information available through internet and very few actually tries to solve their problem themselfs and instead just google the solution.
I still remember reading the few books I had on 6502 and 68k every night when I went to bed and the things we couldn't work out ourselfs had to be brought up with the friends who were more or less in the same situation.
I still have my old blue Amiga Hardware Reference Manual and I will never get rid of it! I remember getting it one christmas, soon after I got my first Amiga 500 with Workbench 1.2... Those were the days!
I will have a look at CECIL since it's probably right down my alley