System Software – SIC/XE Program to write a subroutine for SIC that will read a record into a buffer

Problem Statement

Write a subroutine for SIC that will read a record into a buffer. The record may be any length from 1 to 100 bytes. The end of record is marked with a “null” character (ASCII code 00). The subroutine should place the length of the record read into a variable named LENGTH.

Solution

Line NumberCodeComments
1RDREC LDX ZERO 
2RLOOP TD INDEV 
3JEQ RLOOP 
4RD INDEV 
5COMP NULL 
6JEQ EXIT 
7STCH BUFFER, X 
8TIX K100 
9JLT RLOOP 
10EXIT STX LENGTH 
11RSUB 
12ZERO WORD 0 
13NULL WORD 0 
14K100 WORD 1 
15INDEV BYTE X ‘F1’ 
16LENGTH RESW 1 
17BUFFER RESB 100