Created
May 2, 2017 12:17
-
-
Save johnhmj/e44a9c82192b7995c7abf4f9c2a32802 to your computer and use it in GitHub Desktop.
Pseudocode of SICXE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN | |
read first input line | |
IF OPCODE = 'START' THEN | |
BEGIN | |
save #[OPERAND] as starting address | |
initialize LOCCTR to starting address | |
write line to intermediate file | |
read next input line | |
END {if START} | |
ELSE | |
initialize LOCCTR to 0 | |
WHILE OPCODE != 'END' DO | |
BEGIN | |
IF this is not a comment line THEN | |
BEGIN | |
IF there is a symbol in the LABEL field THEN | |
BEGIN | |
search SYMTAB for LABEL | |
IF found THEN | |
set error flag (duplicate symbol) | |
ELSE | |
insert (LABEL, LOCCTR) into SYMTAB | |
END {if symbol} | |
search OPTAB for OPCODE | |
IF found THEN | |
add 3 {instruction length} to LOCCTR | |
ELSE IF OPCODE = 'WORD' THEN | |
add 3 to LOCCTR | |
ELSE IF OPCODE = 'RESW' THEN | |
add 3 * #[OPERAND] to LOCCTR | |
ELSE IF OPCODE = 'RESB' THEN | |
add 3 #[OPERAND] to LOCCTR | |
ELSE IF OPCODE = 'BYTE' THEN | |
BEGIN | |
find length of constant in bytes | |
add length to LOCCTR | |
END {if BYTE} | |
ELSE | |
set error flag (invalid operation code) | |
END {if not a comment} | |
write line to intermediate file | |
read next input line | |
END {while not END} | |
write last line to intermediate file | |
save (LOCCTR - starting address) as program length | |
END {Pass 1} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN | |
read first input line {from intermediate file} | |
IF OPCODE = 'START' THEN | |
BEGIN | |
write listing line | |
read next input line | |
END {if START} | |
write Header record to object program | |
initialize first Text record | |
WHILE OPCODE != 'END' DO | |
BEGIN | |
IF this is not a comment line THEN | |
BEGIN | |
search OPTAB for OPCODE | |
IF found THEN | |
BEGIN | |
IF there is a symbol in OPERAND field THEN | |
BEGIN | |
search SYMTAB for OPERAND | |
IF found THEN | |
store symbol value as operand address | |
ELSE | |
BEGIN | |
store 0 as operand address | |
set error flag (undefined symbol) | |
END | |
END {if symbol} | |
ELSE | |
store 0 as operand address | |
assemble the object code instruction | |
END {if opcode found} | |
ELSE IF OPCODE = 'BYTE' or 'WORD' THEN | |
convert constant to object code | |
IF object code will not fit into the current Text record THEN | |
BEGIN | |
write Text record to object program | |
initialize new Text record | |
END | |
add object code to Text record | |
END {if not comment} | |
write listing line | |
read next input line | |
END {while not END} | |
write last Text record to object program | |
write End record to object program | |
write last listing line | |
END {Pass 2} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment