RCSNUSP/COBOL: Difference between revisions

m
Improved code formatting.
m (Added note on maximum number of threads.)
m (Improved code formatting.)
Line 10:
PROGRAM-ID. snusp-interpreter.
 
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
Line 88 ⟶ 87:
 
01 current-thread-idx USAGE INDEX.
 
01 Tab-Char CONSTANT X"09".
 
PROCEDURE DIVISION.
Line 103 ⟶ 104:
 
000-main SECTION.
001-parse-arguments.
ACCEPT num-args FROM ARGUMENT-NUMBER
IF num-args = 0
Line 140 ⟶ 142:
GOBACK
END-IF
.
010-read-code-file.
*> Store contents of file into memory.
OPEN INPUT code-file
Line 153 ⟶ 156:
 
CLOSE code-file
.
*> Search 020-search-for any -initial charcters.
PERFORM VARYING ip-line (1, 1) FROM 1 BY 1 UNTIL ip-line (1, 1) > num-lines
AFTER ip-char (1, 1) FROM 1 BY 1 UNTIL ip-char (1, 1) > 100
Line 161 ⟶ 164:
END-IF
END-PERFORM
*> Set position to first char if no initial characters were found.
IF ip-line (1, 1) > num-lines
SET ip-line (1, 1), ip-char (1, 1) TO 1
END-IF
.
030-interpret-code.
*> Interpret the code while there are threads left.
SET right-dir (1, 1) TO TRUE
SET stack-idx, thread-idx, row-idx (1), col-idx (1) TO 1
Line 331 ⟶ 335:
"command-line argument."
DISPLAY "This program supports the following flags as arguments:"
DISPLAY X"09"Tab-Char Flag-Indicator Help-Flag-Char ": Displays this help message."
"message."
DISPLAY X"09"Tab-Char Flag-Indicator Write-Num-Flag-Char ": Display memory "
"contents as numbers."
DISPLAY X"09"Tab-Char Flag-Indicator Read-Num-Flag-Char ": Reads a byte to memory "
"memory as a number."
.
399-exit.
Anonymous user