Exercise · Volume 1 · 1.3.1-26
Exercise 1.3.1-26
not stated yet in Lean solution written
| Rating | 32 |
|---|---|
| Kind | K6, write a program: write a MIX or MMIX program from the written solution |
| Section | Section 1.3.1 of Volume 1. Companion chapter: Description of MIX |
The task
Design a two-card loading routine for MIX that reads data cards and a transfer card under the stated character restrictions.
The exact wording is in your copy of the book.
Hints
Open one hint at a time. Try the exercise again after each.
Hint 1
Write the plan as a MIXAL program first, and then convert it to a card. The restriction says that every byte of every instruction word is a character code below , not and not .
Hint 2
With these limits the address of every instruction is less than (the high byte must be ), the fields must not be or or above , and the constants must be made by arithmetic or loaded as parts of the card.
Hint 3
Use the instruction NUM to convert the digits: it takes each byte mod , so both and the over-punched give the digit.
Solution
Show the solution
This exercise is only sketched here. The plan is below, and the coding of the program into 32 words under the restrictions is left to the reader.
Plan. The GO button reads one card into the cells and jumps to cell 0. The first card holds a short program that reads the second card into the cells by IN 16(16) and waits with JBUS *(16). The two cards together hold the loader and its constants, at most words in the cells . Every address in the loader has a high byte , so that it does not depend on . The buffer for a data card is the cells , so that the buffer addresses are less than as well.
The main loop reads a card into the buffer, then looks at column 6. A zero means the transfer card TRANS0nnnn: the loader converts columns 7 to 10 to a number, as below, and jumps to the cell . A digit means a data card with words. The loader takes the word that holds the columns to and drops column 6 by a shift. The field cannot be used for this, because is not a legal character. Then NUM gives the location. The loader stores it by STA with the field into the address field of an instruction below. Then, for each of the words, LDA and LDX take the two buffer words of columns , NUM turns them into a number, and the sign is decided from the character in column 20 (its code is less than when the digit is over-punched). The word is stored by an instruction whose address was set from the location and the count. The loop counts the words down by DEC and J..P.
The three difficulties are listed here. First, ENT, INC and CMP are not allowed, so constants come from words on the cards and counters are made with SUB and with JAP, JAN. Second, a constant like the byte value cannot be punched, so it has to be made as a sum or a product of allowed bytes. Third, all instructions have to be placed so that the self-modified fields stay below . The proof that all of this fits in two cards is the part that is not given here.
Check
The plan was not run. A check of the sizes: a card has columns, that is words, so two cards give words. A data card has columns: the five ignored columns, the count with the location, and seven words of ten digits.
Remarks
The problem is the same as the problem of the first loader of any real machine. Exercise 1.3.1-21 mentions the GO button that starts it.
This solution is drafted, and a person has not reviewed it yet. The source.
In Lean
not stated yet The exercise is not stated in Lean yet.
The status is computed from the Lean build. The node of the map.
Something is wrong? Report it.