Problem Statement
Write a subroutine for SIC/XE 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. Use immediate addressing and register-to-register instructions to make the process as efficient as possible.
Solution
| Line Number | Code | Comments |
| 1 | JSUB RDREC | |
| 2 | RDREC LDX #0 | |
| 3 | LDT #100 | |
| 4 | LDS #0 | |
| 5 | RLOOP TD INDEV | |
| 6 | JEQ RLOOP | |
| 7 | RD INDEV | |
| 8 | COMPR A, S | |
| 9 | JEQ EXIT | |
| 10 | STCH BUFFER, X | |
| 11 | TIXR T | |
| 12 | JLT RLOOP | |
| 13 | EXIR STX LENGTH | |
| 14 | RSUB | |
| 15 | INDEV BYTE X ‘F1’ | |
| 16 | LENGTH RESW 1 | |
| 17 | BUFFER RESB 100 |
Leave a Reply