___________________________________________________________________________________________________________________ Heathkit 3400 Trainer Manual - Pages 46 To 104 ___________________________________________________________________________________________________________________ Page 47 H E A T H K I T (R) _______________________________________________________________________________________________ OPERATIONAL TESTS PC . . . . . . . . . . . . . . . . Program Counter This section of the Manual checks the basic Trainer INDEX . . . . . . . . . . . . . . . Index Register functions to make sure they are operating properly. The entries that you will make on the keyboard are not CC . . . . . . . . . . . . Condition Codes Register necessarily related to your actual use of the unit. Refer to the "Operation" section of this manual to learn SP . . . . . . . . . . . . . . . . . Stack Pointer how to actually use each function. RTI . . . . . . . . . . . . Return From Interrupt Refer to Pictorial 6-3 (Illustration Booklet, Page 8) to identify the function of each keyboard key. SS . . . . . . . . . . . . . . . . . . Single Step NOTE: If you encounter any trouble as you perform BR . . . . . . . . . . . . . . . . . . Break Point the following steps, push the POWER switch to STANDBY and unplug the line cord. Then refer to the AUTO . . . . . . . . . . . . . . . . Automatic Load "In Case of Difficulty" section of this manual. BACK . . . . . . . . . . . . . . . . . . . . . Back The following abbreviations are used on the Trainer CHAN . . . . . . . . . . . . . . . . . . . . Change keyboard: DO . . . . . . . . . . . . . . . . . . . . . . . Do ACCA . . . . . . . . . . . . . . . Accumulator "A" EXAM . . . . . . . . . . . . . . . . . . . Examine ACCB . . . . . . . . . . . . . . . Accumulator "B" FWD . . . . . . . . . . . . . . . . . . . Forward Page 48 _______________________________________________________________________________________________ H E A T H K I T (R) NOTES: 3. When you make two-digit entries, the indicated Readout display will appear after you release 1. Each numbered step in the following charts the second key. shows which number or letter key to push, and what the resultant readout should be. Always ( ) Perform the tests in "Test Chart #1". push the keys in the sequence shown. If you make an incorrect entry, return to step 1. 2. In the following charts, the symbol "*" indicates a blank readout indication. The symbol "x" in- dicates a random figure. TEST CHART #1 ____ _________ _________________________________________ ____________________________ | | | | | | | FIRST | | | |STEP| | THEN PRESS | READOUT** | | | PRESS: | | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | | | | | | |_| | | \|/ | | |_| | | 1 | |RESET| | | |_ | |_| /|\ |_| | . | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | _____ | | _ | | | |EXAM | | | |_| _| | | 2 | | E | | | __ __ __ __ | | |_|. | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ _____ _____ | _ _ _ | | | | | | |ACCA | |ACCB | | PC | | | | | _| _| \/ \/ | | 3 | | | 0 | | 1 | | 2 | | 3 | | |_| | |_ _| /\ /\ | | | | |_____| |_____| |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | |CHAN | | | | | | _| _| | | 4 | | C | | | |_| | |_ _| __ __ | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ | | | | |INDEX| | CC | | | | | _| _| |_| |_ | | 5 | | | 4 | | 5 | | |_| | |_ _| | _| | | | | |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ | | | |EXAM | | | |_| _| | | 6 | | E | | | __ __ __ __ | | |_|. | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ _____ _____ | _ _ _ _ | | | | | SP | | RTI | | SS | | BR | | |_ | |_| |_| \/ \/ | | 7 | | | 6 | | 7 | | 8 | | 9 | | |_| | |_| _| /\ /\ | | | | |_____| |_____| |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ _ | | | |CHAN | | | |_ | |_| |_| | | 8 | | C | | | |_| | |_| _| __ __ | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ _ | | | | |AUTO | |BACK | | |_ | |_| |_| |_| |_ | | 9 | | | A | | B | | |_| | |_| _| | | |_| | | | | |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ | | | |EXAM | | | |_| _| | | 10 | | E | | | __ __ __ __ | | |_|. | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ _____ _____ | _ _ _ | | | | |CHAN | | DO | |EXAM | | FWD | | | _| |_ |_ \/ \/ | | 11 | | | C | | D | | E | | F | | |_ |_| |_ | /\ /\ | | | | |_____| |_____| |_____| |_____| | | |____|_________|_________________________________________|____________________________| ** Shows the readout as presented on the LED's after you release the key. Page 49 H E A T H K I T (R) _______________________________________________________________________________________________ If all the tests in "Test Chart #1" produced the proper results, the Trainer keys are operating properly. Per- form the steps in "Test Chart #2" to check the mem- ory circuits in the Trainer. TEST CHART #2 ____ _________ _________________________________________ ____________________________ | | | | | | | FIRST | | | |STEP| | THEN PRESS | READOUT | | | PRESS: | | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | | | | | | |_| | | \|/ | | |_| | | 1 | |RESET| | | |_ | |_| /|\ |_| | . | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | _____ | | _ | | | |AUTO | | | |_| _| | | 2 | | A | | | __ __ __ __ | | |_|. | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ _____ _____ | _ _ _ _ | | | | | | | | | | | | (Memory | | | | | | | | | | | 3 | | | 0 | | 0 | | 0 | | 0 | address)| |_| |_| |_| |_| __ __ | | | | |_____| |_____| |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ | | | | | SS | | SP | (Load Accumulator A | | | | | | | | | | 4 | | | 8 | | 6 | w/following two | |_| |_| |_| | __ __ | | | | |_____| |_____| characters) | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ | | | | | | |ACCA | | | | | | | | _| | | 5 | | | 0 | | 1 | (Data for first step) | |_| |_| |_| |_ __ __ | | | | |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ | | | | |BACK | | RTI | (Store Accumulator A | | | | | | | _| | | 6 | | | B | | 7 | at extended address of | |_| |_| |_| _| __ __ | | | | |_____| |_____|following four characters| | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ | | | | |CHAN | |ACCA | | | | | | | | |_| | | 7 | | | C | | 1 | | |_| |_| |_| | __ __ | | | | |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ | | | | | SP | | FWD | | | | | | | | |_ | | 8 | | | 6 | | F | | |_| |_| |_| _| __ __ | | | | |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ | | | | | RTI | |EXAM | (Jump to extended | | | | | | | |_ | | 9 | | | 7 | | E |address of following four| |_| |_| |_| |_| __ __ | | | | |_____| |_____| bytes of information | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ | | | | | | | | | | | | | | | | | | 10 | | | 0 | | 0 | | |_| |_| |_| | __ __ | | | | |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ | | | | | | | | | | | | | | | |_| | | 11 | | | 0 | | 0 | | |_| |_| |_| |_| __ __ | | | | |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | | | | (To terminate AUTO addressing | | |_| | | \|/ | | |_| | | 12 | |RESET| | sequence) | |_ | |_| /|\ |_| | . | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | _____ | | | | | | DO | | | _| _ | | 13 | | D | | | __ __ __ __ |_| |_|. | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ _____ _____ | | | | | | | | | | | | | | \|/ \|/ \|/ \|/ \|/ | | 14 | | | 0 | | 0 | | 0 | | 0 | | . /|\ /|\ /|\ /|\ /|\ | | | | |_____| |_____| |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | | | | | | |_| | | \|/ | | |_| | | 15 | |RESET| | | |_ | |_| /|\ |_| | . | | | |_____| | | | |____|_________|_________________________________________|____________________________| Page 50 _______________________________________________________________________________________________ H E A T H K I T (R) __________________ The simple program that you entered in "Test Chart | | #2" stored specific information in the Trainer's in- | | ternal memory. This information directed the micro- | ____E___ | processor circuit to turn on the decimal point in the | / / | "H" LED (V1). Steps 13 and 14 proved the program. | 9 / / D | | /___8___/ | Note the characters "6F" in step 8. This is the infor- | / / | mation that told the microprocessor that you wanted | A / / C | to address the "H" LED, and in particular, the decimal | /_______/ o | point (the "6" addressed the LED and the "F" addres- | B F | sed the decimal point). You can similarly address any | | segment of an LED as shown in Detail 6-3A. Thus, to |__________________| turn on each segment of the "H" (or "6") LED in turn, 7 - S E G M E N T you must change the terminal character to agree with L E D the segment address. Detail 6-3 A ( ) Perform the steps in "Test Chart #3." NOTE: This program addresses and examines the top bar of the "H" LED. TEST CHART #3 ____ _________ _________________________________________ ____________________________ | | | | | | | FIRST | | | |STEP| | THEN PRESS | READOUT** | | | PRESS: | | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | | | | | | |_| | | \|/ | | |_| | | 1 | |RESET| | | |_ | |_| /|\ |_| | . | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | _____ | | _ | | | |EXAM | | | |_| _| | | 2 | | E | | | __ __ __ __ | | |_|. | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ _____ _____ | _ _ _ _ _ | | | | | | | | | | |INDEX| | | | | | | | |_| |_ |_ | | 3 | | | 0 | | 0 | | 0 | | 4 | | |_| |_| |_| | |_| | | | | | |_____| |_____| |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | |CHAN | | | | | | | | | |_| | | 4 | | C | | | |_| |_| |_| | __ __ | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ | _ _ _ _ _ | | | | | SP | |EXAM | . | | | | | | | |_| |_ |_ | | 5 | | | 6 | | E | . "H" LED. TOP BAR | |_| |_| |_| | |_| |_ | | | | |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | | | | | | |_| | | \|/ | | |_| | | 6 | |RESET| | | |_ | |_| /|\ |_| | . | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | _____ | | | | | | DO | | | _| _ | | 7 | | D | | | __ __ __ __ |_| |_|. | | | |_____| | | | |____|_________|_________________________________________|____________________________| | | | _____ _____ _____ _____ | __ | | | | | | | | | | | | | \|/ \|/ \|/ \|/ \|/ | | 8 | | | 0 | | 0 | | 0 | | 0 | | /|\ /|\ /|\ /|\ /|\ | | | | |_____| |_____| |_____| |_____| | | |____|_________|_________________________________________|____________________________| | | _____ | | _ _ _ | | | | | | | | |_| | | \|/ | | |_| | | 9 | |RESET| | | |_ | |_| /|\ |_| | . | | | |_____| | | | |____|_________|_________________________________________|____________________________| Page 51 H E A T H K I T (R) _______________________________________________________________________________________________ As you observed in step 8, only the top bar segment of LED lights. Then, at step 5, one at a time, enter "5E, the "H" LED lit up. You may further address and call 5D, 5C, 5B, 5A, 59, and 58." You can call up the up the remaining segments, in turn, of the same LED segments of the remaining four LED's in the same way as follows: Repeat all nine steps in "Test Chart #3," by using "4F, 3F, 2F, 1F" at step 5 to light the with one exception. After you push the "CHAN/C" respective decimal segments. key in step 4, enter "6D;" then proceed with the steps 6 through 8. Next time, at step 5, enter "6C", and ( ) Push the POWER switch to STANDBY and un- proceed. Similarly, at step 5 of each repetition, enter plug the line cord. "6B, 6A, 69, and 68." Refer to Detail 6-3A to deter- mine which LED segments should be lit. This completes the "Operational Tests" of your Microprocessor Trainer. Proceed to "Final Assem- To address the individual segments of the "I" LED, bly." use the preceding chart and perform steps 1 through 4 as before. At step 5, enter "5F," and proceed with steps 6 through 8. Note that the decimal on the "I" Page 52 _______________________________________________________________________________________________ H E A T H K I T (R) FINAL ASSEMBLY SYSTEM EXPANSION Molex 22-04-2201 (2 strips required) The curcuit board has provision for you to install a 40-pin connector for system expansion. If you do not wish to install a connector at this time, proceed di- rectly to "Cabinet Completion" below. AMP 2-87215-0 You can obtain these 40-pin connectors from the fol- 2-87543-0 lowing manufacturers. NOTE: The connectors must have .025" square pins on .100" centers. Some of the Install your 40-pin connector* on the circuit board connectors are actually single strips of connectors between integrated circuits U2 and U3. Then connect that you must cut to length. eight wires from the eight circuit board holes that connect the connector data pins to the eight data Heath Company holes near integrated circuits U9 and U10. (Refer to 432-1062 the "Schematic" and the "Circuit Board X-Ray View.") These wires connect the eight data lines (D0 AP Products - D7). Be sure you connect these wires properly so 929834-01 (2 strips required) that data D0 goes to data line D0, etc. 929836-01 Page 53 H E A T H K I T (R) _______________________________________________________________________________________________ CABINET COMPLETION Refer to Pictorial 7-1 for the following steps. ( ) Carefully peel the backing paper from the "Heathkit" label. Then press the label in place on the upper portion of the cabinet top as shown. ( ) Press an LED grommet into the small round hole in the cabinet top. PICTORIAL 7-1 Page 54 _______________________________________________________________________________________________ H E A T H K I T (R) PICTORIAL 7-2 Refer to Pictorial 7-2 for the following steps. ( ) Unplug the line cord, if this has not already been done. ( ) Turn the cabinet top upside down and position it near the cabinet bottom as shown in the Picto- rial. As you lower the main circuit board down onto the inverted cabinet top, be sure that LED D3, next to the POWER switch, fits straight down into the LED grommet as shown in Detail 7-2A. NOTE: If the LED protrudes through the cabinet top too far, resolder the LED's leads so the LED is closer to the circuit board. ( ) Secure the main circuit board to the cabinet top with eight #6 x 3/8" hex head screws. Detail 7-2A Page 55 H E A T H K I T (R) _______________________________________________________________________________________________ PICTORIAL 7-3 Refer to Pictorial 7-3 for the following steps. cabinet bottom in the area shown. NOTE: Be sure to refer to the numbers on the blue and ( ) Turn the cabinet top and the main circuit board white label in any correspondence you have assembly right side up and fit the assembly into with the Heath Company about your kit. This the cabinet bottom. assures you that you will receive the most com- plete and up-to-date information in return. ( ) Turn both cabinet halves bottom-side-up as shown in the Pictorial. Then secure the bottom ( ) Carefully peel the backing paper from the to the top with eight #6 x 5/8" self-tapping power label. Then press the label onto the back screws. of the cabinet bottom in the area shown. ( ) Carefully peel the backing paper from the four ( ) Read, sign and date the FCC label. Carefully feet. Then press the feet in place on the cabinet peel the backing paper from the label and press bottom in the smooth areas near the four corners the FCC label onto the cabinet bottom in the as shown. area shown. ( ) Carefully peel the backing paper from the blue This completes the "Final Assembly" of your kit. Pro- and white label. Then press the label onto the ceed to "Operation." Page 56 _______________________________________________________________________________________________ H E A T H K I T (R) OPERATION This section of the Manual describes the operation of In the following example, the contents of ac- your Trainer, explains the keyboard commands, de- cumulator A is 4A 16 (or binary 01001010). scribes how to enter programs, has several sample programs, contains the monitor listing and several Example: Acca.4A subroutine flowcharts, shows the memory map, and lists the entire 6800 instruction set. Now you may change the contents of accumulator A if you wish. To do this, press the [ C ] key. The dis- Pictorial 8-1 (Illustration Booklet, Page 9) gives a brief play will now be: description of the switches, LED's, and connectors. Acca._ _ Keyboard With two key strokes, enter the new hexadecimal number you want in accumulator A. The keyboard allows you to quickly enter commands and data to the microprocessor. After you press the Display Accumulator B RESET key, the display will show CPU UP, and the next keyboard entry will be interpreted as a com- [ 2 ] Press this key and the contents of ac- mand. The following paragraphs discuss the various cumulator B will be displayed. A typical display is: commands. Accb.5F Display Accumulator A In this example, accumulator B contains 5F 16 (binary [ 1 ] Press this key and the contents of ac- 01011111). cumulator A will be displayed. The first four digits and decimal point identify the display, and the next The contents of accumulator B can be changed in the two digits show the contents of the accumulator. same way that accumulator A is changed. Page 57 H E A T H K I T (R) _______________________________________________________________________________________________ Display Program Counter Display Condition Codes Register [ 3 ] Press this key and the contents of the mi- [ 5 ] Press this key and the contents of the condition croprocessor's program counter will be displayed. codes register (1's and 0's) will be displayed. The The first two digits and decimal point identify the display letters (H, I, N, Z, V, and C) correspond to the display, and the next four digits show the contents of letters assigned to the six condition codes. (See the the program counter. "Instruction Set" on Page 103.) Example: Pc.0040 Example: 001001 In this example, the program counter contains 0040 16. This register cannot be changed by pressing You may change the program counter by pressing the [ C ] key. the [ C ] key and then entering the new hexadecimal number. Display Index Register Display Stack Pointer Register [ 4 ] Press this key and the contents of the index [ 6 ] Press this key and the contents of the stack register will be displayed. pointer register will be displayed. Example: In.FDF4. Example: SP.00d2 You can change the register by pressing the [ C ] key This register cannot be changed by pressing and then entering a new hexadecimal number. the [ C ] key. Page 58 _______________________________________________________________________________________________ H E A T H K I T (R) Resume User's Program Do not press the RESET key. This clears all the break- points. [ 7 ] Press this key and your program will start at the location contained in the program counter. This key If you make an incorrect entry, and the entry is still is used to return to normal user program operation displayed, press the Q key as many times as from breakpoints or single stepping. necessary for the display to return to br. Then enter the correct address. Single Step User's Program Auto Load Of Memory [ 8 ] Press this key and the microprocessor will [ A ] Press this key and _ _ _ _ Ad will de dis- perform only one step of your program. The instruc- played. tion to be performed is taken from the address con- tained in the program counter. After the step, the next Enter the address you want to start at. Example: Enter instruction and its address are displayed. The dis- 0, 0, A, and 4. The display is now: played instruction may be changed by pressing the [ C ] key and then entering the new data. Also 00A4 _ _ . at this time, you may examine registers, memory, or use any of the other monitor functions. Enter the 2-digit hexadecimal value you want entered at that address. Set Breakpoint The display will now advance to the next address. You can continue changing memory data until you [ 9 ] Press this key and you can then make an press the RESET key. entry into the monitor breakpoint table. A breakpoint is a point where you want to stop the program to Display Previous Address examine the microprocessor registers, memory, etc. [ B ] Press this key when an address and its data The display is _ _ _ _ br. are displayed (you are examining memory with the E function, your program has come to a breakpoint, or Enter the four digits of a hexadecimal address for the you are single stepping your program), and the previ- breakpoint. The address must be the address of an ous address and its data will be displayed. You may operational code in your program and that code must change this data by pressing the [ C ] key and then be in RAM. No breakpoints are possible in ROM. You entering the new data. may have up to four breakpoints in your program at any one time. Page 59 H E A T H K I T (R) _______________________________________________________________________________________________ Change Displayed Value Examine Memory [ C ] Press this key when an address and its data [ E ] Press this key and the display will become: are displayed, and the data will be replaced with "_ _". Then enter the new hexadecimal value you want _ _ _ _ Ad. at this address. Enter a new address. The display will now indicate You may use this function to correct a value you the data at this new address. You may now change the entered by mistake. However, if the monitor is expect- displayed value by using the [ C ] key or you can ing a command and the change function is not valid, step backwards or forwards through memory using the change command will be ignored. the [ B ] and [ F ] keys. DO User Program Display Next Address [ D ] Press this key and the display will become: [ F ] Press this key when an address and its data are displayed, and the next address and its data will _ _ _ _ do. by displayed. You may change this data by pressing the [ C ] key and then entering the new data. Enter the beginning address of your program. Your program will now start at the new address instead of where the program counter was pointing. The display will become blank and the program will run until a display is called for, until it comes to a breakpoint, or until you press the reset key. This key function combines several other functions. You could get the same result by displaying and changing the program counter and then pressing the [ 7 ] key. Page 60 _______________________________________________________________________________________________ H E A T H K I T (R) Entering Programs Operand: This is additional hexadecimal information required to perform the operation. It may be zero, one, Pictorial 8-2 shows the first two instructions of Sam- or two bytes as determined by the addressing mode. ple Program 1 (in the following section) and indicates the various information they contain. This informa- Label: This is usually a name applied to a subroutine tion is further described in the following paragraphs. in the program used more than once. In the sample programs, the address to be entered to begin execu- Instruction Address: This is usually called the Pro- tion is labeled "Start." gram Counter. In order to perform an instruction, the Program Counter must contain the address that is in Mnemonic: This is a three-letter indication of the this column. RTI and SS require the Program Counter source instruction. A fourth letter, A or B, is added to to contain the address that is in this column for proper indicate which of two accumulators if the instruction execution. The address entered after DO is pressed applied to either one. must be an instruction address. Breakpoints are not recognized except at instruction addresses. Mnemonic operand: Again, this is additional infor- mation that is required for the operation. It may be a Instruction: This is one, two, or three bytes of data as label, address, or data. The $ sign indicates the infor- required by the addressing mode used. mation is a hex value. The # sign indicates the im- mediate addressing op code is to be used. Op code: This is a "byte of information referred to as machine code, it indicates in hexadecimal the opera- Comments: This is a brief description of what is hap- tion to be performed. pening in the program. Instruction address | Mnemonic | Instruction | Mnemonic Comments | | Label | operand | _^_ __^__ | | | | / \ / \ v v v v 0000 BD FCBC START JSR REDIS SET UP FIRST DISPLAY ADDRESS 0003 86 01 LDA A # $01 FIRST SEGMENT ADDRESS ^ \_ _/ ^ ^ | v | | | Operand | \__ Indicates | | hex value. Machine or Indicates op code immediate addressing mode. PICTORIAL 8-2 Page 61 H E A T H K I T (R) _______________________________________________________________________________________________ When you load a program into the Trainer, only the one, two, or three bytes of each instruction are en- tered. You may use either of two modes to enter the instructions: "Auto", or the more laborious "Examine and Change." Forward, Back, and Change are valid commands in the Examine, and Change mode and may be used to correct entry errors. However, they are not valid in Auto. If you make an error in the Auto mode, press the Reset and Auto keys. Then enter the address where the error was made and continue from there; or, remember where the error was made and then examine and change that memory location after you finish entering the entire program. The following charts show the sequence of events to enter the first two instructions of sample program 1. The first chart shows the Examine and Change mode while the second chart shows the Auto mode. Examine and Change Press the EXAM key and then enter the first instruction address, 0000, by pressing the 0 key four times. Then check the display and continue to enter the program as shown below. Display -> Press -> Enter -> Display -> Press is is 0000XX CHAN BD 0000BD FWD 0001XX CHAN FC 0001FC FWD 0002XX CHAN BC 0002BC FWD 0003XX CHAN 86 000386 FWD 0004XX CHAN 01 000401 FWD 0005XX CHAN etc. Auto Press the AUTO key and then enter the first instruction address, 0000, by pressing the 0 key four times. Display -> Enter is 0000-- BD 0001-- FC 0002-- BC 0003-- 86 0004-- 01 0005-- etc. Press RESET after last entry to exit the AUTO mode. Page 62 _______________________________________________________________________________________________ H E A T H K I T (R) If Examine and Change is used, the last entry in sam- Examine accumulator A by pressing the ACCA key. ple program 1 (Page 67) results in the display 0025 DA, and this display remains until a new command is Accumulator A has been loaded with the software entered through the keyboard. interrupt instruction 3F that was temporarily placed at 0004 by the breakpoint at that address. If Auto is used, the last display will be the address of Watch the "H" display and press RTI. The 3F in the next continuous memory location which is the accumulator A caused the first display to be incorrect. last program instruction address plus the number of The program will stop again at 0005. bytes in the instruction. In this program, 0024 plus two; 0026 The dash (or "prompt" characters) are Insert a breakpoint at 0002 and then press RTI to displayed in the data locations. resume execution. The program will run until it comes to 0002 which is changed by the breakpoint to After you enter a program, by either method, check 3F. The program will "crash" because of the wrong the ending address to be sure that you have not omit- instruction and one of three things will happen: The ted or double entered data. display will be blank; all eights will be displayed; or all eights will appear, followed by CPU UP. In any Enter sample program 1 (on Page 67) into your case, press Reset to return control to the monitor pro- Trainer. Use either of the two entry methods. gram. Press EXAM and enter 0000. Use FWD and CHAN to If you used the Examine and Change mode to enter the examine and correct errors introduced when the program, the program can be run by pressing DO and program crashed. You will always find the data at the entering the address of the instruction labeled breakpoint addresses has been changed. More often "Start," 0000. If you used the Auto mode, first press than not, the data at the breakpoint addresses will the RESET key to exit the Auto mode. Then press DO become 3F, although this may also change because and enter the address of the instruction labeled the program crashed. Before you proceed, run the "Start," 0000. program to be sure all errors have been corrected. In order to properly execute SS or RTI, the program counter must contain the instruction address where Using Breakpoints you wish to start. If single step begins at an incorrect address, the single step routine will not execute an We will now use sample program 1 to show how invalid instruction and the display will not change. If programs can be inadvertently changed and even the instruction at the PC address is a valid opcode, SS "crash" when breakpoints are inserted at improper will execute the instruction using the following bytes locations (at addresses other than the instruction ad- as necessary and will continue unless it comes to an dress). invalid instruction. RTI will try to execute the in- struction in the same manner; except in the case of an Press RESET and insert breakpoints at 0004 and 0005. invalid instruction, the program will probably crash. We will use SS to illustrate what happens. Press BR 0004. Push RESET. Examine the Program Counter by push- Press BR 0005. ing PC. Then change it to 0016 by pushing CHAN and 0016. Start the program by pressing DO 0000. Press SS. The instruction at 0016 is not a valid in- Notice that the CPU has ignored the breakpoint at struction. In the single step mode, the machine will 0004 and stopped at 0005. reject the instruction and 0016 FD will continue to be displayed and nothing happens. If RTI is pressed, the Examine 0003 and 0004 by pressing EXAM, 0003, and program will crash as it would when an invalid in- FWD. The instructions there are correct (86 and 01). struction is encountered. Probably only the first in- Page 63 H E A T H K I T (R) _______________________________________________________________________________________________ struction will be changed, if any, in this particular these memory locations, 00F0 and 00F1, you will circumstance. If you press RTI to see what happens, always find C12F, "V" display address, there because examine the program afterwards and correct any er- the examine command puts it there before it outputs rors introduced; then run the program to be sure it is the data. Secondly; DIGADD is always loaded with correct before proceeding. C16F, "H" display address, when DO or RTI are used. Examine and change the program counter to 000F by Single step uses RMB TEMP, T1 and T0 in common pressing PC, CHAN, and 000F. Press SS. In this case with many of the monitor routines. Single step will FE is a valid instruction, LDX extended, and X is replace information stored at these locations by the loaded from non-existent memory locations 3ACE monitor routines. As a result, the routine may return and 3ACF. with incorrect information or it may not be able to return at all and the program will crash. Press SS. Here again 2F is a valid instruction (a condi- tional branch BLE). A branch may occur to 0015 or the When the program stops, at a breakpoint or after a program may fall through to 0014. In either case, two single step, the address of the next instruction (con- incorrect instructions have been performed in place tained in the program counter) and the instruction of two or three correct instructions introducing error will be displayed. You may examine and make in the program. This is of no great consequence in this changes to any register (except stack pointer) or ad- program but may be in another. Since an invalid in- dress provided you DO NOT change the program struction was not encountered, placing the program counter. The instruction displayed when the program counter at 000F and pressing RTI would do exactly stopped will be the next one executed when SS or RTI the same thing. is pressed, regardless of what is being displayed. Now sample program 1 will be used to illustrate a The following procedure gives instructions. The six procedure using breakpoints and single step to go characters on the right, on the same line, indicate through a program. what the display should be after you perform the instruction. You will be instructed to examine regis- There are two important considerations pertaining to ters affected by the instruction that has been exe- reserved memory bytes to keep in mind. First; DI- cuted. GADD is used by all monitor routines. If you examine Page 64 _______________________________________________________________________________________________ H E A T H K I T (R) You may examine any other registers or memory loca- tions if you wish. The comment after an instruction is explanatory information. INSTRUCTION DISPLAY Press RESET. CPU UP. Press PC, CHAN, and enter 0000. The program counter now Pc 0000 contains the start address. Press SP. This is the next location available on the stack. SP 00d2 The JSR instruction should store the address for return from the REDIS subroutine (0003) at this location. Press SS, Jump to REDIS. FCbC dF Press EXAM and 00D1. 00d1 00 Press FWD. Return address is on stack. 00d2 03 Press BR and enter 0003. To get past monitor routine. 0003 br Press RTI. Might normally use examine to check result of routine. 0003 86 In this case, DIGADD RMB is loaded with C16F. Examine will just change what is there. Press SS. 0005 20 Press ACCA. (A) loaded with correct value. Acca.01 Press SS. Branch to OUT-offset correct. 000E bd Press SS. Jump to OUTCH. FE3A dF Press BR and enter 0011. To get past monitor routine. 0011 br Could check stack here if desired. Press RTI. Exit OUTCH address of next display in DIGADD; 0011 CE Do not check. Press SS. 0014 09 Press INDEX. Is (X) loaded? In.2F00 Press SS. 0015 26 Press INDEX. Is (X) decremented? IN.2EFF Press CC. Z bit clear if (X) not 0000 yet. XXX0 XX (X = don't care) Press SS. Branches to WAIT if Z was clear. 0014 09 Press INDEX, CHAN, and enter 0001. In.0001 Press SS. 0015 26 Page 65 H E A T H K I T (R) _______________________________________________________________________________________________ Press CC. (X) decremented to 0000 sets Z bit. Should drop XXX1 XX through branch now. Press SS. It did. 0017 16 Press ACCA. Acca.01 Press SS. 0018 5d Press ACCB. What was in (A) should be in (B). Accb.01 Press SS. 0019 26 Press CC. Z bit clear if (B) not 00. XXX0 XX Press SS. Branches to SAME if Z is clear. 0007 d6 Press SS. 0009 Cb Press ACCB. When the program runs normally, (B) at this Accb.0F point would be 5F because exit from OUTCH would be with the next display address, C15F, in DIGADD. Single step has caused DIGADD to be C10F. Press SS. 000b d7 Press ACCB. Hex 10 has been added to (B). Accb.1F Press SS. (B) has been stored at DIGADD. No reason to examine 000d 48 00F1 since EXAM and SS will change what is there anyway. Press ACCA. Acca.01 Press SS. 000E bd Press ACCA. ACCA was 0000 0001 binary (01 hex). It has been Acca.02 shifted left and is now 0000 0010 binary (02 hex). The program is back to jump to OUTCH again. The same method as used before would get you back 0019 again. The program has proven good to that point so we will use a different method. Press Reset. This clears the previous breakpoints. CPU UP Press BR and enter 0018. 0018 br. Press DO and enter 0000. You may have noticed the program ran 0018 5d up to the breakpoint and the counter segment in "H" was momentarily lit. Now you are in another loop. You could press RTI seven times and go back through the loop until (B) is 00. Again, since the branch is operating properly it is easier to change (B) to 00 and continue. Press ACCB, CHAN, and enter 00. Accb.00 Page 66 _______________________________________________________________________________________________ H E A T H K I T (R) Press SS. 0019 26 Press CC. The Z bit is set and the program should fall XXX1 XX through the branch. Press SS. It did. 001b 86 Press SS. 001d de Press ACCA. (A) is loaded correctly. Acca.01 Press SS. 001F 8C Press Index. This is DIGADD again. Although the program has In.C10F just finished with the "H" display, single step has placed C10F in DIGADD. This happens to be the address that will be in DIGADD after DP goes out in the "C" display and should result in a branch back to START. Press SS. Same conditional BRANCH. 0022 26 Press CC. Z is set and the program should fall through. XXX1 XX Press SS. It did. 0024 20 Press SS. Every instruction in the program has been 0000 bd run except for the conditional branch at 0022. Press Reset. Clears the breakpoint at 0018 CPU UP Press BR and enter 001F. 001F br Press DO and enter 0000. 001F 8C Press Index. This time the program runs straight through until after In.C15F (X) is loaded from DIGADD (at 001D) without an intervening single step or breakpoint. All segments were turned on and off in the "H" display and "I" display address C15F is in the index register as it should be. Press SS. Conditional branch. 0022 26 Press CC. Z is clear and a branch to out should take place. XXX0 XX Press SS. It did. 000E bd The entire program has now been run. Page 67 H E A T H K I T (R) _______________________________________________________________________________________________ Sample Programs These sample programs will give you practice enter- ing programs and show the use of Monitor sub- routines. SAMPLE 1 TURN ON AND OFF EACH SEGMENT IN SEQUENCE BEGINNING AT H DISPLAY USES MONITOR SUBROUTINES REDIS AND OUTCH NOTE: ONE DP IN EACH DISPLAY IS ACTIVE 0000 BD FCBC START JSR REDIS SET UP FIRST DISPLAY ADDRESS 0003 86 01 LDA A #$01 FIRST SEGMENT CODE 0005 20 07 BRA OUT 0007 D6 F1 SAME LDA B DIGADD+1 FIX DISPLAY ADDRESS 0009 CB 10 ADD B #$10 FOR NEXT SEGMENT 000B D7 F1 STA B DIGADD+1 000D 48 ASL A NEXT SEGMENT CODE 000E BD FE3A OUT JSR OUTCH OUTPUT SEGMENT 0011 CE 2F00 LDX #$2F00 TIME TO WAIT 0014 09 WAIT DEX 0015 26 FD BNE WAIT TIME OUT YET? 0017 16 TAB 0018 5D TST B LAST SEGMENT THIS DISPLAY? 0019 26 EC BNE SAME NEXT SEGMENT 001B 86 01 LDA A #$01 RESET SEGMENT CODE 001D DE F0 LDX DIGADD NEXT DISPLAY 001F 8C C10F CPX #$C10F LAST DISPLAY YET? 0022 26 EA BNE OUT 0024 20 DA BRA START DO AGAIN Page 68 _______________________________________________________________________________________________ H E A T H K I T (R) SAMPLE 2 TURNS ALL DISPLAYS OFF AND ON DISPLAYS HEX VALUE AT 0044 USES MONITOR SUBROUTINES REDIS, OUTCH AND OUTHEX 0030 BD FCBC START JSR REDIS FIRST DISPLAY ADDRESS 0033 4F CLEAR CLR A 0034 BD FE3A JSR OUTCH TURN ALL SEGMENTS OFF 0037 DE F0 LDX DIGADD NEXT DISPLAY 0039 8C C10F CPX #$C10F LAST DISPLAY YET? 003C 26 F5 BNE CLEAR 003E 8D 13 BSR HOLD 0040 BD FCBC JSR REDIS FIRST DISPLAY ADDRESS 0043 86 08 LDA A #$08 HEX VALUE TO CHARACTER 0045 BD FE28 OUT JSR OUTHEX OUTPUT CHARACTER 0048 DE F0 LDX DIGADD NEXT DISPLAY 004A 8C C10F CPX #$C10F LAST DISPLAY YET? 004D 26 F6 BNE OUT 004F 8D 02 BSR HOLD 0051 20 DD BRA START DO AGAIN 0053 CE FF00 HOLD LDX #$FF00 TIME TO WAIT 0056 09 WAIT DEX 0057 26 FD BNE WAIT TIME OUT YET? 0059 39 RTS Page 69 H E A T H K I T (R) _______________________________________________________________________________________________ SAMPLE 3 OUTPUTS MESSAGE BY DISPLAYING UP TO SIX CHARACTER WORD ONE WORD AT A TIME USES MONITOR SUB ROUTINE OUTSTO NOTE: DP MUST BE LIT TO INDICATE END OF STRING TO EXIT OUTSTR. DP IS PLACED IN THE SEVENTH DISPLAY POSITION TO FULFILL THIS REQUIREMENT WITHOUT ACTUALLY BEING DISPLAYED. 0060 BD FD8D START JSR OUTSTO LEFT DISPLAY OUT WORD 0063 00 FCB $00,$3B,$7E,$3E,$05,$00,$80 YOUR 0064 3B 0065 7E 0066 3E 0067 05 0068 00 0069 80 006A 8D 3F BSR HOLD HOLD DISPLAY 006C BD FD8D JSR OUTSTO LEFT DISPLAY OUT WORD 006F 00 FCB $00,$79,$33,$7E,$7E,$00,$80 3400 0070 79 0071 33 0072 7E 0073 7E 0074 00 0075 80 0076 8D 33 BSR HOLD HOLD DISPLAY 0078 BD FD8D JSR OUTSTO LEFT DISPLAY OUT WORD 007B 00 FCB $00,$00,$30,$5B,$00,$00,$80 IS 007C 00 007D 30 007E 5B 007F 00 0080 00 0081 80 0082 8D 27 BSR HOLD HOLD DISPLAY 0084 BD FD8D JSR OUTSTO LEFT DISPLAY OUT WORD 0087 00 FCB $00,$00,$3E,$67,$00,$00,$80 UP 0088 00 0089 3E 008A 67 008B 00 008C 00 008D 80 008E 8D 1B BSR HOLD HOLD DISPLAY 0090 BD FD8D JSR OUTSTO LEFT DISPLAY OUT WORD 0093 00 FCB $00,$00,$7D,$15,$3D,$00,$80 AND 0094 00 0095 7D 0096 15 0097 3D 0098 00 0099 80 Page 70 _______________________________________________________________________________________________ H E A T H K I T (R) 009A 8D 0F BSR HOLD HOLD DISPLAY 009C BD FD8D JSR OUTSTO LEFT DISPLAY OUT WORD 009F 05 FCB $05,$1C,$15,$15,$10,$15,$80 RUNNIN 00A0 1C 00A1 15 00A2 15 00A3 10 00A4 15 00A5 80 00A6 8D 03 BSR HOLD HOLD DISPLAY 00A8 7E 0060 JMP START DO AGAIN 00AB CE FF00 HOLD LDX #$FF00 TIME TO WAIT 00AE 09 WAIT DEX 00AF 26 FD BNE WAIT TIME OUT YET? 00B1 39 RTS Page 71 H E A T H K I T (R) _______________________________________________________________________________________________ SAMPLE 4 OUTPUTS SAME MESSAGE AS PROGRAM 3 IN TICKER TAPE FASHION USES MONITOR SUB ROUTINES REDIS AND OUTSTR 0000 7F 0007 START CLR MORE+1 CLEAR POINTER 0003 CE 002A NEXT LDX #MESSA MESSAGE ADDRESS 0006 A6 00 MORE LDA A #$00,X GET CHARACTER 0008 A7 2D STA A OUT+3-MESSA,X STORE CHAR. AT OUT PLUS 000A 08 INX NEXT CHARACTER 000B 8C 0030 CPX #$30 FULL STRING YET? 000E 26 F6 BNE MORE 0010 8D 11 BSR HOLD HOLD DISPLAY 0012 BD FCBC JSR REDIS FIRST CHAR. TO "H" DISPLAY 0015 BD 0054 JSR OUT 0018 96 07 LDA A MORE+1 FIRST CHARACTER NUMBER 001A 4C INC A MOVE STRING UP ONE CHARACTER 001B 97 07 STA A MORE+1 NEW FIRST CHARACTER 001D 81 25 CMP A #$25 LAST CHARACTER TO "H" YET? 001F 26 E2 BNE NEXT BUILD NEXT STRING 0021 20 DD BRA START DO AGAIN 0023 CE 6000 HOLD LDX #$6000 TIME TO WAIT 0026 09 WAIT DEX 0027 26 FD BNE WAIT TIME OUT YET? 0029 39 RTS 002A 08 MESSA FCB $08,$08,$08,$08,$08,$08 ------ 002B 08 002C 08 002D 08 002E 08 002F 08 0030 3B FCB $3B,$7E,$3E,$05,$00,$00 YOUR 0031 7E 0032 3E 0033 05 0034 00 0035 00 0036 79 FCB $79,$33,$7E,$7E,$00,$00 3400 0037 33 0038 7E 0039 7E 003A 00 003B 00 003C 30 FCB $30,$5B,$00,$00,$3E,$67 IS UP 003D 5B 003E 00 003F 00 0040 3E 0041 67 0042 00 FCB $00,$00,$7D,$15,$3D,$00,$00 AND 0043 00 0044 7D 0045 15 Page 72 _______________________________________________________________________________________________ H E A T H K I T (R) 0046 3D 0047 00 0048 00 0049 05 FCB $05,$1C,$15,$15,$10,$15 RUNNIN 004A 1C 004B 15 004C 15 004D 10 004E 15 004F 08 FCB $08,$08,$08,$08,$08 ----- 0050 08 0051 08 0052 08 0053 08 0054 BD FE52 OUT JSR OUTSTR OUTPUT CHARACTER STRING OUTPUT STRING STORED HERE 0057 00 FCB $00,$00,$00,$00,$00,$00,$80 0058 00 0059 00 005A 00 005B 00 005C 00 005D 80 005E 39 RTS Page 73 H E A T H K I T (R) _______________________________________________________________________________________________ SAMPLE 5 THIS PROGRAM CONTINUOUSLY CHANGES THE HEX VALUE STORED AT KEY+1 UNTIL ANY HEX KEY IS DEPRESSED. THE RIGHT DP IS LIT TO INDICATE A VALUE HAS BEEN SET. THE USER THEN DEPRESSES THE VARIOUS HEX KEYS TO LOOK FOR THE SELECTED VALUE. THE RELATIONSHIP OF DEPRESSED TO CORRECT KEY IS MOMENTARILY DISPLAYED AS HI OR LO. DP AGAIN LIGHTS INDICATING TRY AGAIN. DEPRESSING THE CORRECT KEY DISPLAYS YES! WHICH REMAINS UNTIL ANY KEY IS DEPRESSED SETTING A NEW VALUE TO FIND. USES MONITOR SUB ROUTINES ENCODE,OUTSTO,INCH 0060 7F 0086 START CLR KEY+1 CLEAR KEY POINTER 0063 C6 20 ILL LDA B #$20 VIOLATION COUNT 0065 BD FDBB ILL1 JSR ENCODE WAIT FOR ILLEGAL INTERVAL 0068 25 F9 BCS ILL STILL LEGAL? 006A 5A DEC B 006B 26 F8 BNE ILL1 NOT A FELONY 006D C6 20 LEGAL LDA B #$20 TIME UNTIL PAROLE 006F 8D 38 BSR CODE CHANGE KEY TO FIND 0071 BD FDBB LEGAL1 JSR ENCODE SET KEY TO FIND 0074 24 F7 BCC LEGAL KEY TO FIND SET? 0076 5A DEC B 0077 26 F8 BNE LEGAL1 GOOD KEY? 0079 BD FD8D JSR OUTST0 OUTPUT STRING 007C 00 FCB $00,$00,$00,$00,$00,$80 DP TO "C" 007D 00 007E 00 007F 00 0080 00 0081 80 * DP LIT FIND SELECTED KEY 0082 BD FDF4 JSR INCH LOOK FOR KEY 0085 C6 86 KEY LDA B #KEY+1 GET KEY VALUE 0087 11 CBA IS IT RIGHT KEY? 0088 27 14 BEQ YES IF CORRECT 008A 22 2A BHI HIGH IF GREATER THAN KEY+1 VALUE 008C BD FD8D JSR OUTST0 OUTPUT STRING 008F 00 FCB $00,$00,$00,$00,$0E,$7E,$80 LO 0090 00 0091 00 0092 00 0093 0E 0094 7E 0095 80 0096 CE 6000 HOLD LDX #$6000 TIME TO HOLD DISPLAY 0099 09 DEX 009A 26 FD BNE WAIT LONG ENOUGH YET? 009C 20 DB BRA OUTDP TRY AGAIN 009E BD FD8D JSR OUTST0 OUTPUT STRING Page 74 _______________________________________________________________________________________________ H E A T H K I T (R) 00A1 00 FCB $00,$00,$3B,$4F,$5B,$A0 YES! 00A2 00 00A3 3B 00A4 4F 00A5 5B 00A6 A0 00A7 20 B7 BRA START DO AGAIN 00A9 96 86 LDA A KEY+1 CURRENT KEY VALUE 00AB 4C INC A NEXT KEY 00AC 97 86 STA A KEY+1 KEY TO FIND 00AE 81 10 CMP A #$10 CAN'T BE GREATER THAN F 00B0 26 03 BNE GOOD 00B2 7F 0086 CLR KEY+1 MAKE IT 0 00B5 39 RTS 00B6 BD FD8D JSR OUTST0 OUTPUT STRING 00B9 37 FCB $37,$30,$00,$00,$00,$00,$80 HI 00BA 30 00BB 00 00BC 00 00BD 00 00BE 00 00BF 80 00C0 7E 0096 JMP HOLD Page 75 H E A T H K I T (R) _______________________________________________________________________________________________ SAMPLE 6 THIS IS A TWELVE-HOUR CLOCK PROGRAM THE ACCURACY DEPENDS ON THE MPU CLOCK FREQUENCY AND THE TIMING LOOP AT START. CHANGING THE VALUE AT 0006 CHANGES THE ACCURACY. HOURS, MINUTE, SECOND RMB 0001/2/3 ARE LOADED WITH THE STARTING TIME. THE FIRST DISPLAY IS ONE SECOND AFTER START OF THE PROGRAM. SECONDS WILL BE CONTENT OF SECOND RMB+1. USES MONITOR SUBROUTINES REDIS,DISPLAY. NOTE:START THE PROGRAM AT 0004. 0001 00 HOURS RMB 1 0002 00 MINUTE RMB 1 0003 00 SECOND RMB 1 0004 CE CEB3 START LDX #$CEB3 ADJUST FOR ACCURACY 0007 09 DELAY DEX 0008 26 FD BNE DELAY WAIT ONE SECOND 000A CE FFFF LDX #$FFFF SET FIXED DELAY 000D 09 SETDEL DEX 000E 26 FD BNE SETDEL 0010 C6 60 LDA B #$60 SIXTY SECONDS, SIXTY MINUTES 0012 0D SEC ALWAYS INCREMENT SECONDS 0013 8D 0F BSR INCS INCREMENT SECONDS 0015 8D 10 BSR INCMH INCREMENT MINUTES IF NEEDED 0017 C6 13 LDA B #$13 TWELVE HOUR CLOCK 0019 8D 0C BSR INCMH INCREMENT HOURS IF NEEDED 001B BD FCBC JSR REDIS RESET DISPLAY ADDRESS 001E C6 03 LDA B #$03 NUMBER OF BYTES TO DISPLAY 0020 8D 16 BSR PRINT DISPLAY HOURS, MINUTES, SECONDS 0022 20 E0 BRA START DO IT AGAIN 0024 CE 0003 INCS LDX #SECOND POINT X AT TIME RMB 0027 A6 00 INCMH LDA A $00,X GET CURRENT TIME 0029 89 00 ADC A #$00 INCREMENT IF NECESSARY 002B 19 DAA FIX TO DECIMAL 002C 11 CBA TIME TO CLEAR? 002D 25 01 BCS STORE NO 002F 4F CLR A 0030 A7 00 STORE STA A $00,X STORE NEW TIME 0032 09 DEX NEXT TIME RMB 0033 07 TPA 0034 88 01 EOR A #$01 COMPLEMENT CARRY BIT 0036 06 TAP 0037 39 RTS 0038 96 01 PRINT LDA A $01 WHAT'S IN HOURS? 003A 26 03 BNE CONTIN IF NOT ZERO 003C 7C 0001 INC HOURS MAKE HOURS ONE 003F 08 CONTIN INX POINT X AT HOURS 0040 7E FD7B JMP DISPLAY OUTPUT TO DISPLAYS Page 76 _______________________________________________________________________________________________ H E A T H K I T (R) SAMPLE 7 THIS PROGRAM CALCULATES THE OP CODE VALUE FOR BRANCH INSTRUCTIONS USING THE LAST TWO DIGITS OF THE BRANCH AND DESTINATION ADDRESSES. THE BRANCH ADDRESS IS ENTERED FIRST AND DISPLAYED AT "H" AND "I". THE DESTINATION ADDRESS IS THEN ENTERED AND DISPLAYED AT "N" AND "Z". THE OP CODE IS THEN CALCULATED AND DISPLAYED AT "V" AND"C". THE DISPLAY IS HELD UNTIL NEW INFORMATION IS ENTERED. SINCE ONLY TWO DIGITS ARE ENTERED, IT IS NECESSARY TO MAKE AN ADJUSTMENT IF THE HUNDREDS DIGIT IN THE TWO ADDRESSES IS NOT THE SAME. FOR EXAMPLE TO CALCULATE THE OFFSET OF A BRANCH FROM 00CD TO 011B. SUBTRACT A NUMBER FROM BOTH ADDRESSES THAT WILL MAKE THE GREATER ADDRESS LESS THAN 100. FOR EASE OF CALCULATION IN THIS CASE, SUBTRACT C0 FROM BOTH ADDRESSES AND ENTER THE RESULTS 0D AND 5B IN THE PROGRAM. SINCE THE DIFFERENCE BETWEEN THE ADDRESSES IS UNCHANGED THE CORRECT OP CODE (4C) WILL BE DISPLAYED. IF THE DISTANCE IS TOO GREAT FOR BRANCHING NO. WILL APPEAR AT "V" AND "C". USES MONITOR SUB ROUTINES REDIS IHB OUTBYT OUTSTR 0000 BD FCBC START JSR REDIS FIRST DISPLAY AT "H" 0003 BD FE09 JSR IHB INPUT BRANCH ADDRESS 0006 16 TAB PUT IT IN B 0007 BD FE09 JSR IHB INPUT DESTINATION ADDRESS 000A 11 CBA FORWARD OR BACK? 000B 25 0C BCS BACK IF BACK 000D CB 02 FRWD ADD B #$02 ADJUST TWO BYTES 000F 10 SBA FIND DISTANCE 0010 81 80 CMP A #$80 IS IT LEGAL? 0012 24 12 BCC NO IF NOT 0014 BD FE20 OUT JSR OUTBYT OUTPUT BRANCH OP CODE 0017 20 E7 BRA START LOOK FOR NEW ENTRY 0019 40 BACK NEG A MAKE A MINUS 001A 1B ABA ADD A AND B 001B 8B 02 ADD A #$02 ADJUST 2 BYTES 001D 43 COM A GET COMPLIMENT 001E 8B 01 ADD A #$01 MAKE IT TWO'S 0020 81 80 CMP A #$80 IS IT LEGAL? 0022 25 02 BCS NO IF NOT 0024 20 EE BRA OUT OUTPUT BRANCH OP CODE 0026 BD FE52 NO JSR OUTSTR OUTPUT STRING 0029 15 FCB $15,$19 NO. 002A 19 002B 20 D3 BRA START LOOK FOR NEW ENTRY Page 77 H E A T H K I T (R) _______________________________________________________________________________________________ Subroutine Flow Charts Following, are flow charts of several subroutines. These are helpful when you write your own pro- grams. The entry requirements necessary to call these subroutines and their exit conditions are also shown. RESET/MAIN Routine When the Reset key is released, the CPU outputs FFFE and FFFF to get a starting address. This is the address of the top two locations in the monitor ROM which in turn outputs FC00, the beginning address of the reset routine. Reset first initializes the stack pointer to 00EB and outputs CPU UP, to the displays. The index register is set to 00CB (the start of the user's stack) and this value is stored in the user's stack pointer at location 00F2. Breakpoints are cleared by placing FF in the eight RAM locations, 00E4-00EB. The program then goes into the main monitor loop. The contents of ac- cumulator A, which is FF at this point, is stored at T1 and the address to return from command handler subroutines (FC19) is placed on the stack. The program next calls INCH to scan and encode the keyboard. The program stays in INCH until a key is found closed. The FORWARD and BACK commands are legal only after execution of the EXAM or SINGLE STEP com- mands. RAM location 00EE (T1) is cleared if FOR- WARD and BACK are legal commands. When INCH returns a key closure, T1 is tested to see if FORWARD and BACK are legal. If they are legal, a branch is made to MAIN2 to obtain the subroutine address to handle the command and then goes to that handler. If FOR- WARD and BACK are not legal commands, tests are made to see that they are not the key closed before going to MAIN2. If FORWARD or BACK is found to be the key closed, a branch back to MAIN1 occurs and INCH is again called to look for a legal key closure. RESET/MAIN ROUTINE <<< RESET FLOWCHART TEXT >>> RESET FC00 INITIALIZE STACK POINTER OUTPUT CPU UP. TO DISPLAYS SET UP USER STACK CLEAR BREAKPOINTS MAIN STORE (A) at T1 SET UP RETURN ADDRESS INCH CHECK FOR KEY CLOSURE LEGAL KEY CLOSURE? NO YES YES ARE FORWARD AND BACK LEGAL COMMANDS? NO IS CLOSED KEY FORWARD OR BACK? YES NO FIND HANDLER ADDRESS AND GO TO COMMAND ROUTINE. RTS Page 78 _______________________________________________________________________________________________ H E A T H K I T (R) INCH Routine INCH guards against the entry of a false output from the keyboard due to contact bounce or pressing more than one key. ACCB is loaded with hex 20 and EN- CODE is called to scan the keyboard. If C is set (key closed), a branch occurs back to the beginning. If C is clear (no closure), ACCB is decremented and EN- CODE is called again. ENCODE must return C clear 32 consecutive times (approx. 9 ms) to exit this loop. The second half of the routine is then entered. This half is identical to that described above, except C must be set 32 consecutive times before exit wiih the hex value of the key closed in ACCA. INCH ROUTINE ENTRY: None. EXIT: (A) contains hex value of closed key. <<< INCH FLOWCHART TEXT >>> INCH FDF4 LOAD (B) HEX 20 ENCODE SCAN KEYBOARD IS KEY CLOSED? YES NO DECREMENT (B) NO IS (B) ZERO? YES LOAD (B) HEX 20 ENCODE SCAN KEYBOARD NO IS KEY CLOSED? YES DECREMENT (B) IS (B) ZERO? NO YES RTS Page 79 H E A T H K I T (R) _______________________________________________________________________________________________ ENCODE Routine ENCODE is the keyboard scanning routine. If a key is ENTRY: None. closed, the value is found in the hex table and loaded in ACCA. The C bit in the condition code register is EXIT: (A) contains hex value of key set to indicate a valid key. If no key is closed or if the closed. value is not in HEX-TAB, the C bit is cleared. "C" set for valid condition. ENCODE ROUTINE <<< ENCODE FLOWCHART TEXT >>> ENCODE FDBB Page 80 _______________________________________________________________________________________________ H E A T H K I T (R) OUTCH Routine OUTCH ROUTINE OUTCH outputs a character to the display whose ad- ENTRY: ACCA contains segment code. DIGADD con- dress is contained at memory location DIGADD tains address of desired digit. Entry at OUT0 (00F0-00F1). This routine may be entered at OUT0 if if index register is to be saved. the index register does not need to be saved. The code for the character to be displayed must be in ac- EXIT: DIGADD contains address of next digit to cumulator A when the routine is entered. The follow- right. ing drawing shows the segment identification and the corresponding positions in the eight bits of ac- cumulator A. A logic one in a bit will cause that segment to light, whereas a logic zero will keep it off. The hex and corresponding bit codes are shown for two characters used in the monitor program. The most significant bit is DP and the least significant bit is segment g. Segment codes used by the monitor program are shown at the end of the monitor listing. D7 D6 D5 D4 D3 D2 D1 D0 SEGMENT DP a b c d e f g HEX C 4E 0 1 0 0 1 1 1 0 LTR c 0D 0 0 0 0 1 1 0 1 a ________ / / f / / b /_______/ / g / e / / c /_______/ DP d o <<< OUTCH FLOWCHART TEXT >>> OUTCH FE3A Page 81 H E A T H K I T (R) _______________________________________________________________________________________________ OUTHEX Routine OUTBYT Routine OUTHEX determines the segment code for a hex OUTBYT outputs two hex values contained in ac- value contained in the four least-significant bits (LSB) cumulator A to two adjacent displays. The value con- of accumulator A. Subroutine OUT0 is then called to tained in the four most-significant bits (MSB) are output the hex value to the display whose address is moved to the LSB positions. OUTHEX is called to obtained from DIGADD. determine the segment code and in turn calls OUT0 to output the character to the display addressed at OUTHEX ROUTINE DIGADD. Accumulator A is restored, and OUTHEX and OUT0 are called again to output the LSB to the ENTRY: ACCA contains hex value. next display to the right. EXIT: Address of next digit to right contained in DIGADD. OUTBYT ROUTINE <<< OUTHEX FLOWCHART TEXT >>> ENTRY: ACCA contains two hex values. OUTHEX EXIT: Digit address for next digit to right con- FE28 tained in DIGADD. <<< OUTBYT FLOWCHART TEXT >>> OUTBYT FE20 Page 82 _______________________________________________________________________________________________ H E A T H K I T (R) OUTST1 Routine OUTST1 outputs a string of characters from left to The routine may be entered at OUTSTJ or at OUTST0 right on the displays. The first character is output to (with the first character appearing in the left-most the display whose address is contained in the index display) or at OUTSTA (with the first character ap- register upon entry to the routine. The last character pearing in the V display). Entry at OUTSTR requires must have the decimal point lit to indicate the end of the address for the first character to be in DIGADD. the string. Adding hex 80 to the desired segment code Exit from the routine is to the next instruction, which causes the decimal point to be lit. For example, if the is one plus the address of the last character. last character is to be LTRP, hex 67 (the last character code) would be hex 67 plus hex 80, or hex E7. OUTST1 ROUTINE <<< OUTST1 FLOWCHART TEXT >>> OUTSTJ OUTST1 OUTSTA FD8C FE50 FC86 ENTRY: Calling convention must be JSR to entry point.Segment codes for output characters from left to right at consecutive addresses immediately following jump instruction. Entry at OUTSTJ or OUTSTA set up for left-most character a H or V display re- spectively. Entry at OUTST1 requires (X) contain left-most digit address. Entry at OUTSTR requires left-most digit address at DIGADD. Decimal point must be lit on last character. EXIT: To next instruction at 1 + address of last character. ACCA is clear. DIGADD contains address of display to right of last digit lit. Page 83 H E A T H K I T (R) _______________________________________________________________________________________________ DSPLAY Routine Accumulator A is loaded with a byte value from an address contained in the index register and OUTBYT DSPLAY is called to output two or three bytes to the is called to output the byte to the displays. Then the displays. The number of bytes to output is indicated index register is incremented to get the next byte, by the contents of accumulator B. This routine could accumulator B is decremented, and OUTBYT is call- be called to output one byte, although OUTBYT ed again. When accumulator B is zero, all bytes have would normally be called for this purpose. been output and the index register and accumulator B are restored before returning from the routine. DSPLAY ROUTINE ENTRY: (X) contains address of first byte. (B) contains number of byte to output. DIGADD contains address of digit. EXIT: (X) and (B) unchanged. Address of next digit to right contained in DIGADD. <<< DSPLAY FLOWCHART TEXT >>> DISPLAY FD7B Page 84 _______________________________________________________________________________________________ H E A T H K I T (R) IHB Routine IHB ROUTINE IHB outputs two hex characters to the displays cor- ENTRY: None. responding to two consecutive key closures and re- EXIT: ACCA contains byte value. turns to the calling routine with the byte value of the Digit address for next digit to right con- two closures in accumulator A. tained in DIGADD. INCH is called to get the value of the first key closure. <<< IHB FLOWCHART TEXT >>> OUTHEX is called to display the value on the display whose address is contained at DIGADD. The value IHB contained in the four LSB of accumulator A is moved FE09 to the four MSB of accumulator A and then saved in accumulator B. INCH is called again to get the value of the second key closure. OUTHEX is then called again and this value is displayed on the next display to the right. The contents of accumulators A and B are combined and placed in accumualtor A. Accumulator A now contains the byte value of the two closures. The MSB contains the first closure value and the LSB contains the second value. Accumulator B is restored, ac- cumulator A is pushed onto the stack, and ENCODE is called to wait for the release of the second key. When the key is released, the byte is pulled from the stack and the program returns to the calling routine with the byte contained in accumulator A. REDIS Routine REDIS is a short routine to reset the address at DI- GADD to the left-most display digit. REDIS ROUTINE ENTRY: None. EXIT: DIGADD contains address of left-most di- git. <<< REDIS FLOWCHART TEXT >>> REDIS FCBC Page 85 H E A T H K I T (R) _______________________________________________________________________________________________ Monitor Listings Tables at the end of the listing show labels used in the program, keyboard and display addresses, segment Your Trainer is controlled by IC12, the "read only codes for characters displayed by the program, and memory" (ROM). The following is a listing of the addresses in RAM that are reserved for use by the program stored in this IC. monitor program. FC00 ORG $FC00 ** RESET - CLEAR BREAKPOINT TABLE AND INITIALIZE STACK FC00 8E 00 EB RESET LDS #2*NBR+BKTBL-1 FC03 BD FD 8D JSR OUTST0 FC06 4E 67 3E FCC HEXC,LTRP,LTRU,0,LTRU,LTRP+$80 ; FC09 00 3E E7 FC0C CE 00 CB LDX #USRSTK FC0F DF F2 STX USERS SET UP FOR USER FC11 86 FF LDA A #$FF FC13 C6 08 LDA B #2*NBR FC15 36 RESE1 PSH A FC16 5A DEC B FC17 26 FC BNE RESE1 ** MAIN - MAIN MONITOR LOOP * * HANDLERS RETURN: * (B) = NUMBER BYTES SUBJECT TO 'CHANGE' * (X) = ADDRESS BYTES SUBJECT TO 'CHANGE' * (A) = 0 ENABLES 'FORWARD' AND 'BACK' FC19 97 EE MAIN STA A T1 FC1B 86 19 LDA A #-MAIN/256*256+MAIN LO ORDER RET.ADDR FC1D 36 PSH A FC1E 86 FC LDA A #MAIN/256 HI ORDER BYTE RET. ADDR. FC20 36 PSH A RETURN ONTO STACK FC21 BD FD F4 MAIN1 JSR INCH GET COMMAND FC24 7D 00 EE TST T1 FC27 27 08 BEQ MAIN2 FORWARD OR BACK OK FC29 81 0F CMP A #$0F FC2B 27 F4 BEQ MAIN1 ILLEGAL NOW FC2D 81 0B CMP A #$0B FC2F 27 F0 BEQ MAIN1 ALSO ILLEGAL NOW FC31 DF EC MAIN2 STX T0 FC33 CE FF B4 LDX #CMDTAB-2 FC36 08 MAIN3 INX FC37 08 INX GET HANDLER ADDRESS FC38 4A DEC A FC39 2A FB BPL MAIN3 FC3B A6 01 LDA A $01,X TARGET ADDRESS ONTO STACK FC3D 36 PSH A FC3E A6 00 LDA A $00,X FC40 36 PSH A FC41 DE EC LDX T0 RESTORE X FC43 96 EE LDA A T1 FC45 39 ZERO RTS JUMP TO HANDLER Page 86 _______________________________________________________________________________________________ H E A T H K I T (R) ** BKSET - ENTRY FOR BREAKPOINT TABLE * * ENTRY: NONE * EXIT (B) = 2 * (X) = ADDRESS IN TABLE * USES: ALL,T0,T1 FC46 CE 00 E2 BKSET LDX #BKTBL-2 * F2 IN LISTING IS MISTAKE FC49 86 FF LDA A #$FF FC4B C6 04 LDA B #$NBR FIND SPOT IN TABLE * FC43 AND ODR IN LISTING ARE MISTAKES FC4D 08 BKSE1 INX FC4E 08 INX FC4F A1 00 CMP A $00,X FC51 26 04 BNE BKSE2 FC53 A1 01 CMP A $01,X FC55 27 0E BEQ BKSE3 EMPTY SLOT * REC IN LISTING IS MISTAKE FC57 5A BKSE2 DEC B FC58 26 F3 BNE BKSE1 STILL HOPE * FULL UP FC5A BD FD 8D JSR OUTST0 FC5D 00 47 3E 0E FCB 0,LTRF,LTRU,LTRL,LTRL,$A0 ; FC61 0E A0 FC63 4C INC A FC64 39 RTS FC65 DF EE BKSE3 STX T1 FC67 8D 1D BSR OUTSTA FC69 1F 85 FCC LTRB,LTRR+$80 * LIBB SHOULD BE LTRB FC6B 8D 08 BSR DOPM1 FC6D 4C INC A (A) = 1 FC6E 39 RTS Page 87 H E A T H K I T (R) _______________________________________________________________________________________________ ** DOPMT - ACCEPT ADDRESS VALUE WITH 'DO' PROMPT * * ENTRY: (X) = ADDRESS TO STORE INPUTTED VALUE * EXIT (B) = 2 * (X) UNCHANGED * USES: ALL,T0,T1 FC6F DF EE DOPMT STX T1 FC71 8D 13 BSR OUTSTA OUTPUT PROMPT 'DO' FC73 3D 9D FCC LTRD,LTRO+$80 * 90 IN LISTING IS MISTAKE FC75 8D 45 DOPM1 BSR REDIS RESET DISPLAY FC77 DE EE LDX T1 RESTORE X FC79 C6 02 LDA B #$02 FC7B 7E FD 25 JMP PROMPT INPUT NEW VALUE ** ADDR - ACCEPT ADDRESS VALUE WITH `AD` PROMPT * * ENTRY, EXIT -- SEE `DOPMT` FC7E DF EE ADDR STX T1 FC80 8D 04 BSR OUTSTA FC82 77 BD FCC HEXA,LTRD+$80 FC84 20 EF BRA DOPM1 ** OUTSTA - OUTPUT STRING FOR ADDRESS PROMPT * FC86 CE C1 2F OUTSTA LDX #DG2ADD FC89 7E FE 50 JMP OUTST1 ** DO - RESET USER PC AND RESUME * * ENTRY: NONE * EXIT TO `RESUME` * USES: ALL FC8C DE F2 DO LDX USERS FC8E 08 INX FC8F 08 INX FC90 08 INX FC91 08 INX FC92 08 INX FC93 08 INX X TO USER PC FC94 8D D9 BSR DOPMT Page 88 _______________________________________________________________________________________________ H E A T H K I T (R) ** RESUME - RESUME USER PROGRAM * * 1) BLANKS ALL DISPLAYS * 2) INITIALIZES (DIGADD) * 3) STEPS USER CODE PAST BREAKPOINT * 4) INSERTS BREAKPOINTS * 5) PRINTS INSTRUCTION UPON RETURN * ENTRY:NONE * EXIT: (B) = 1 * (X) = USERPC * USES ALL,T0,T1 FC96 8D 24 RESUME BSR REDIS RESET DISPLAY FC98 4F CLR A FC99 C6 06 LDA B #$06 FC9B BD FE 3A RES1 JSR OUTCH CLEAR DISPLAYS FC9E 5A DEC B FC9F 26 FA BNE RES1 FCA1 8D 19 BSR REDIS RESET DISPLAY FCA3 BD FE 6B RES2 JSR SSTEP STEP PAST BREAKPOINT FCA6 C6 04 LDA B #NBR SET BREAKPOINTS FCA8 30 RES3 TSX FCA9 EE 08 LDX 2*NBR,X GET BREAKPOINT ADDRESS FCAB A6 00 LDA A $00,X FCAD 36 PSH A FCAE 36 PSH A FCAF 86 3F LDA A #$3F REPLACE WITH SWI FCB1 A7 00 STA A $00,X FCB3 5A DEC B FCB4 26 F2 BNE RES3 FCB6 CE FC CE LDX #BKPT FCB9 7E FE FC JMP SWIVE1 GO TO USER CODE ** REDIS - RESET DISPLAYS * * ENTRY: NONE * EXIT: DIGADD SET TO LEFTMOST DIGIT * USES: T0 FCBC DF EC REDIS STX T0 FCBE CE C1 6F LDX #DG6ADD FCC1 DF F0 STX DIGADD FCC3 DE EC LDX T0 FCC5 39 RTS Page 89 H E A T H K I T (R) _______________________________________________________________________________________________ ** BADDR - BUILD ADDRESS * * ENTRY: NONE * EXIT (X) = ADDRESS FCC6 CE 00 EE BADDR LDX #T1 FCC9 8D B3 BSR ADDR FCCB DE EE LDX T1 FCCD 39 RTS ** BKPT - BREAK POINT RETURN * 1) REMOVE BKPTS FROM USER CODE * 2) CHECK FOR BREAKPOINT HIT AND EITHER * SPELT AS EETHER IN LISTING * A) RESUME IF NO HIT * B) PRINT INSTRUCTION AND RETURN IF HIT FCCE 30 BKPT TSX FCCF 9F F2 STS USERS FCD1 A6 06 LDA A $06,X FCD3 26 02 BNE BKP1 DECREMENT PC ON USERS STACK FCD5 6A 05 DEC $05,X FCD7 4A BKP1 DEC A FCD8 A7 06 STA A $06,X FCDA E6 05 LDA B $05,X FCDC D7 EC STA B T0 SAVE FOR COMPARE FCDE 97 ED STA A T0+1 ** NOW CLEAR BREAKPOINTS FCE0 0C CLC `C` IS HIT FLAG FCE1 8E 00 D9 BKP2 LDS #BKTBL-3-NBR-NBR FCE4 C6 04 LDA B #NBR FCE6 32 BKP3 PUL A FCE7 32 PUL A OLD OP CODE INTO A FCE8 30 TSX FCE9 EE 08 LDX 2*NBR,X FCEB 9C EC CPX T0 DO WE HAVE A HIT? FCED 26 01 BNE BKP4 NO WE DO NOT FCEF 0D SEC YES WE DO - SET FLAG FCF0 BKP4 EQU * FCF0 A7 00 STA A $00,X FIX USER CODE FCF2 5A DEC B FCF3 26 F1 BNE BKP3 FCF5 24 AC BCC RES2 BREAKPOINT NOT HIT FCF7 DE EC LDX T0 (X) = USER PC ** MEM - DISPLAY ADDRESS AND DAT * * ENTRY: (X) = ADDRESS * EXIT: (B) = 1 * USES: A,B,C,T0,T1 FCF9 8D C1 MEM BSR REDIS RESET DISPLAY FCFB DF EE STX T1 FCFD CE 00 EE LDX #T1 FD00 C6 02 LDA B #$02 FD02 8D 03 BSR MEM2 DISPLAY ADDRESS FD04 EE 00 LDX $00,X FD06 5A DEC B FD07 7E FD 7B MEM2 JMP DISPLAY OUTPUT DATA ** AUTO - AUTO LOAD OF MEMORY * * ENTRY: NONE * EXIT: NO EXIT POSSIBLE * USES: ALL,T0,T1 Page 90 _______________________________________________________________________________________________ H E A T H K I T (R) FD0A 8D BA AUTO BSR BADDR BUILD ADDRESS FD0C 8D EB AUT1 BSR MEM FD0E 8D 0B BSR REPLAC FD10 08 INX FD11 20 F9 BRA AUT1 NO EXIT ** EXAM - EXAMINE MEMORY * * ENTRY: NONE * EXIT: (X) = ADDRESS * (B) = 0 * (A) = 0 * USES: ALL,T0 FD13 8D B1 EXAM BSR BADDR BUILD ADDRESS FD15 09 DEX ** FOWD - DISPLAY NEXT BYTE * * ENTRY: (X) = OLD ADDRESS * EXIT: (X) = (XOLD) +1 * (B) = 1 * (A) = 0 * USES: ALL,T0 FD16 08 FOWD INX FD17 08 INX ** BACK - DISPLAY PREVIOUS BYTE * * ENTRY: (X) = ADDRESS * EXIT: (X) = (XOLD) + 1 * (B) = 1 * (A) = 0 * USES: ALL,T0 FD18 09 BACK DEX FD19 20 DE BRA MEM DISPLAY ADDRESS AND DATA ** REPLAC - REPLACE DISPLAYED VALUE * * `REPLAC` 1) BACKSPACES DISPLAY TO CANCEL DISPLAYED VALUE * 2) SENDS PROMPT FOR REPLACEMENT VALUE * 3) ACCEPTS AND REPLACES DESIGNATED BYTES * ENTRY: (X) = ADDRESS OF BYTE(S) TO REPLACE * (B) = NUMBER OF BYTES * (DIGADD) = ADDRESS OF DIGIT TO RIGHT OF DISPLAYED * EXIT: B,X,DIGADD UNCHANGED * USES: T0,A,C FD1B 5D REPLAC TST B FD1C 27 06 BEQ REPL1 NO BYTES FD1E 36 PSH A FD1F 8D 22 BSR BKSP BACKSPACE DISPLAYS FD21 8D 02 BSR PROMPT FD23 32 PUL A FD24 39 REPL1 RTS ** PROMPT - PROMPT AND INPUT BYTES * * ENTRY: (X) = ADDRESS TO STORE VALUE * (B) = NUMBER OF BYTES * (DIGADD) = ADDRESS OF FIRST ECHO CHARACTER * EXIT: B,X UNCHANGED * DIGADD UPDATED * USES: T0, DIGADD Page 91 H E A T H K I T (R) _______________________________________________________________________________________________ FD25 37 PROMPT PSH B FD26 86 08 LDA A #DASH PROMPT CHARACTER FD28 58 ASL B FD29 BD FE 3A PROM1 JSR OUTCH FD2C 5A DEC B FD2D 26 FA BNE PROM1 FD2F 33 PUL B FD30 8D 11 BSR BKSP BACKSPACE DISPLAYS FD32 37 PSH B **ALTERNATE ENTRY** FD33 BD FE 09 PROM2 JSR IHB GET BYTE VALUE FD36 A7 00 STA A $00,X PLACE INTO MEMORY FD38 08 INX BUMP POINTER FD39 5A DEC B FD3A 26 F7 BNE PROM2 MORE TO GO FD3C 33 PUL B FD3D 17 TBA DUPLICATE FD3E 09 PROM3 DEX FIX X FD3F 4A DEC A FD40 26 FC BNE PROM3 FD42 39 RTS EXIT ** BKSP - BACKSPACE DISPLAYS * * ENTRY: (B) = NUMBER DIGIT PAIRS TO BACKSPACE * EXIT: (DIGADD) = (DIGADD) + 20 * (B) * USES: A,C FD43 37 BKSP PSH B FD44 96 F1 LDA A DIGADD+1 L.S. BYTE FD46 8B 20 BKSP1 ADD A #$20 BACKSPACE TWO PLACES FD48 5A DEC B FD49 26 FB BNE BKSP1 FD4B 97 F1 STA A DIGADD+1 FD4D 33 PUL B FD4E 39 RTS ** REGISTER DISPLAY FUNCTIONS * * ENTRY: NONE * EXIT: (B) = NUMBER BYTES THIS REGISTER * (X) = REGISTER ADDRESS ON STACK * (DIGADD) INITIALIZED TO DIGIT 6 * USES: ALL,T0 FD4F 8D 3B REGX BSR OUTSTJ PRINT `REGX` FD51 30 95 FCC LTRI,LTRN+$80 FD53 20 16 BRA REGX1 FD55 8D 35 REGA BSR OUTSTJ PRINT `ACCA` FD57 77 0D 0D FCC HEXA,LTRC,LTRC,LTRA+$80 ; FD5A FD FD5B 20 10 BRA REGA1 FD5D 8D 2D REGB BSR OUTSTJ PRINT `ACCB` FD5F 77 0D 0D FCC HEXA,LTRC,LTRC,LTRB+$80 ; FD62 9F FD63 20 09 BRA REGB1 FD65 8D 25 REGP BSR OUTSTJ PRINT `PC` FD67 67 8D FCC LTRP,LTRC+$80 FD69 4C INC A (A) = OFFSET INTO STACK FD6A 4C INC A (B) = #BYTES THIS REGISTER FD6B 5C REGX1 INC B FD6C 4C INC A FD6D 4C REGA1 INC A FD6E 5C REGB1 INC B FD6F 8B 02 ADD A #$02 Page 92 _______________________________________________________________________________________________ H E A T H K I T (R) FD71 DE F2 LDX USERS FD73 08 REG1 INX POINT X TO REGISTER FD74 4A DEC A FD75 26 FC BNE REG1 FD77 8D 02 BSR DISPLAY FD79 4C INC A FD7A 39 RTS ** DISPLAY - DISPLAY INDEXED BYTES * * ENTRY: (X) = ADDRESS OF BYTES TO OUTPUT * (B) = NUMBER OF BYTES TO DISPLAY * EXIT: X,B UNCHANGED * (DIGADD) UPDATED * USES: ALL, T0 FD7B 37 DISPLAY PSH B FD7C A6 00 DIS1 LDA A $00,X GET BYTE FD7E BD FE 20 JSR OUTBYT DISPLAY BYTE FD81 08 INX FD82 5A DEC B FD83 26 F7 BNE DIS1 FD85 33 PUL B FD86 17 TBA DUPLICATE BYTE COUNT FD87 09 DIS2 DEX RESTORE X FD88 4A DEC A FD89 26 FC BNE DIS2 FD8B 39 RTS * CLEAR B AND JUMP TO OUTSTR FD8C 5F OUTSTJ CLR B FD8D CE C1 6F OUTST0 LDX #DG6ADD FD90 7E FE 50 JMP OUTST1 ** CONDX - DISPLAY CONDITION CODES * * ENTRY: DIGADD INITIALIZED * EXIT: (B) = 0 * USES: ALL,T0 FD93 BD FC BC CONDX JSR REDIS RESET DISPLAYS FD96 DE F2 LDX USERS FD98 C6 20 LDA B #$20 FD9A 4F COND0 CLR A FD9B E5 01 BIT B $01,X MASK DESIRED BIT FD9D 27 01 BEQ COND1 IS A ZERO FD9F 4C INC A IS A ONE FDA0 BD FE 28 COND1 JSR OUTHEX FDA3 56 ROR B FDA4 26 F4 BNE COND0 MORE TO GO FDA6 4C INC A FDA7 39 RTS ** REGS - OUTPUT USER STACK POINTER * * ENTRY: (DIGADD) INITIALIZED * EXIT: (B) = 0 * USES: ALL, T0 FDA8 REGS EQU * FDA8 8D E2 STKPTR BSR OUTSTJ FDAA 5B E7 FCC LTRS,LTRP+$80 FDAC D6 F3 LDA B USERS+1 FDAE CB 07 ADD B #$07 Page 93 H E A T H K I T (R) _______________________________________________________________________________________________ FDB0 99 F2 ADC A USERS CLEAN UP FOR USER FDB2 8D 6C BSR OUTBYT FDB4 17 TBA FDB5 5F CLR B FDB6 8D 68 BSR OUTBYT FDB8 86 01 LDA A #$01 FDBA 39 RTS ** ENCODE - SCAN AND ENCODE KEYBOARD * * ENTRY: NONE * EXIT: (A) = HEX VALUE OF KEY PRESSED * `C` SET FOR VALID CONDITION * USES: A,C,T0 FDBB 37 ENCODE PSH B FDBC F6 C0 03 LDA B COL1 GET KEYBOARD DATA FDBF B6 C0 06 LDA A COL3 FDC2 48 ASL A LEFT JUSTIFY DATA FDC3 48 ASL A FDC4 48 ASL A FDC5 59 ROL B FDC6 48 ASL A FDC7 59 ROL B FDC8 48 ASL A FDC9 59 ROL B FDCA 37 PSH B FDCB F6 C0 05 LDA B COL2 GET LAST DATA FDCE C4 1F AND B #$1F MASK ANY GARBAGE FDD0 1B ABA FDD1 33 PUL B FDD2 43 COM A FDD3 53 COM B * (BA) IS NOW KEYBOARD PATTERN FDD4 DF EC STX T0 FDD6 CE FF A5 LDX #HEXTAB-1 TABLE OF POSSIBLE OUTPUTS FDD9 11 CBA FIND ACTIVE ACCUMULATOR FDDA 27 11 BEQ ENC3 ILLEGAL OR NO KEY FDDC 24 06 BCC ENC1 A ACTIVE FDDE 36 PSH A B ACTIVE FDDF 17 TBA INTERCHANGE B,A FDE0 33 PUL B FDE1 CE FF AD LDX #HEXTAB+7 FDE4 5D ENC1 TST B B SHOULD BE ZERO FDE5 26 06 BNE ENC3 ILLEGAL FDE7 08 ENC2 INX SCAN FOR ACTIVE BIT FDE8 48 ASL A FDE9 22 FC BHI ENC2 NOT ACTIVE BIT FDEB 27 01 BEQ ENC4 LEGAL CHARACTER FDED 0C ENC3 CLC ILLEGAL RETURNS `C` CLEAR FDEE A6 00 ENC4 LDA A $00,X GET HEX FROM TABLE FDF0 DE EC LDX T0 FDF2 33 PUL B CLEAN UP FDF3 39 RTS AND RETURN ** INCH - INPUT CHARACTER FROM KEYBOARD * * `INCH` WAITS FOR A TRANSITION BETWEEN ILLEGAL AND * LEGAL KEYBOARD CONDITIONS, AND RETURNS HEX VALUE * OF KEY PRESSED * * ENTRY: NONE * EXIT: (A) = HEX VALUE * USES: A,C,T0 FDF4 37 INCH PSH B FDF5 C6 20 INC1 LDA B #TIME VIOLATION COUNT * 7F (TIME) IN LISTING SHOULD BE 20 Page 94 _______________________________________________________________________________________________ H E A T H K I T (R) FDF7 8D C2 INC2 BSR ENCODE WAIT FOR ILLEGAL INTERVAL FDF9 25 FA BCS INC1 STILL LEGAL FDFB 5A DEC B FDFC 26 F9 BNE INC2 NOT A FELONY * NOW WE`RE SURE WE HAVE AN ILLEGAL CONDITION AND * NOT JUST A RELEASE CONTACT BOUNCE FDFE C6 20 INC3 LDA B #TIME TIME UNTIL PAROLE * 7F (TIME) IN LISTING SHOULD BE 20 FE00 8D B9 INC4 BSR ENCODE FE02 24 FA BCC INC3 BAD BEHAVIOUR FE04 5A DEC B FE05 26 F9 BNE INC4 BACK IN THE SLAMMER FE07 33 PUL B FE08 39 RTS ** IHB - INPUT HEX BYTE AND DISPLAY ON LEDS * * ENTRY: NONE * EXIT: (A) = BYTE VALUE * (DIGADD) UPDATED * USES: A,C,T0 FE09 8D E9 IHB BSR INCH GET FIRST HALF FE0B 8D 1B BSR OUTHEX ECHO TO DISPLAYS FE0D 48 ASL A FE0E 48 ASL A FE0F 48 ASL A FE10 48 ASL A FE11 37 PSH B FE12 16 TAB FE13 8D DF BSR INCH GET NEXT HALF FE15 8D 11 BSR OUTHEX ECHO FE17 1B ABA FE18 33 PUL B FE19 36 PSH A FE1A 8D 9F IHB1 BSR ENCODE WAIT FOR KEY RELEASE FE1C 25 FC BCS IHB1 FE1E 32 PUL A RESTORE LEGAL ENTRY FE1F 39 RTS ** OUTBYT - OUTPUT TWO HEX DIGITS * * ENTRY: (A) = BYTE VALUE TO OUTPUT * EXIT: (DIGADD) UPDATED * USES: C,T0 FE20 36 OUTBYT PSH A FE21 44 LSR A FE22 44 LSR A FE23 44 LSR A FE24 44 LSR A FE25 8D 01 BSR OUTHEX OUTPUT M.S. FOUR BITS FE27 32 PUL A ** OUTHEX - OUTPUT HEX DIGIT * * ENTRY: (A) = HEX VALUE * EXIT: (DIGADD) UPDATED * USES: C,T0 FE28 36 OUTHEX PSH A FE29 84 0F AND A #$0F MASK GARBAGE FE2B DF EC STX T0 FE2D CE FF 95 LDX #DISTAB-1 DISPLAY CODE TABLE FE30 08 OUTH1 INX FE31 4A DEC A FE32 2A FC BPL OUTH1 FE34 A6 00 LDA A $00,X DISPLAY CODE FOR HEX FE36 8D 04 BSR OUT0 ALTERNATE ENTRY FOR `OUTCH` Page 95 H E A T H K I T (R) _______________________________________________________________________________________________ FE38 32 PUL A FE39 39 RTS ** OUTCH - OUTPUT CHARACTER TO DISPLAY * * ENTRY: (A) = SEGMENT CODE * (DIGADD) = ADDRESS OF DIGIT TO OUTPUT * EXIT: (DIGADD) UPDATED * USES: C,T0 FE3A DF EC OUTCH STX T0 FE3C DE F0 OUT0 LDX DIGADD **ALTERNATE ENTRY FOR `OUTHEX` FE3E 37 PSH B FE3F 49 ROL A FE40 49 ROL A PRE-ROTATE A FE41 C6 10 LDA B #$10 TO GET TO NEXT DIGIT FE43 49 OUT1 ROL A HERE WE MAKE TWO PASSES AT FE44 A7 00 STA A $00,X LIGHTING DIGITS-- FE46 09 DEX KING`S X ON FIRST PASS!! FE47 5A DEC B FE48 26 F9 BNE OUT1 FE4A DF F0 STX DIGADD UPDATE `DIGADD` FE4C DE EC LDX T0 RESTORES X FE4E 33 PUL B FE4F 39 RTS ** OUTSTR--OUTPUT IMBEDDED CHARACTER STRING * CALLING CONVENTION: * JSR OUTSTR * FIRST CHARACTER * * * * * LAST CHARACTER (HAS D.P. LIT) * NEXT INSTRUCTION * * ENTRY: NONE * EXIT: TO `NEXT INSTRUCTION` * (A) = 0 * USES: A,X,T0 FE50 DF F0 OUTST1 STX DIGADD **ALTERNATE ENTRY** SETS UP DIGADD FE52 30 OUTSTR TSX POINT `X` AT STRING FE53 EE 00 LDX $00,X FE55 31 INS FE56 31 INS FE57 A6 00 OUTST3 LDA A $00,X GET CHARACTER FE59 8D DF BSR OUTCH FE5B 08 INX FE5C 4D TST A LAST CHARACTER IS NEGATIVE FE5D 2A F8 BPL OUTST3 FE5F 4F CLR A FE60 6E 00 JMP $00,X RETURN TO `NEXT INST.` ** STEP - STEP USER CODE * * ENTRY: NONE * EXIT: (B) = 1 * (X) = USER P.C. * (A) = 0 * USES: ALL,T0,T1 FE62 8D 07 STEP BSR SSTEP FE64 DE F2 LDX USERS FE66 EE 06 LDX $06,X FE68 7E FC F9 JMP MEM ** SSTEP - PERFORM SINGLE STEP. * Page 96 _______________________________________________________________________________________________ H E A T H K I T (R) FE6B 9F EE SSTEP STS TEMP WE`LL USE THIS WHEN WE RETURN FE6D DE F2 LDX USERS FE6F A6 07 LDA A $07,X PUSHING USER PC ONTO MONITOR FE71 36 PSH A STACK FE72 A6 06 LDA A $06,X FE74 36 PSH A FE75 EE 06 LDX $06,X NOW GET USER PC INTO X FE77 86 3F LDA A #$3F SWI`S ARE NORMAL EXIT FROM FE79 36 PSH A SCRATCHPAD EXECUTION FE7A 36 PSH A FE7B A6 02 LDA A $02,X NOW WE ARE COPYING THREE BYTES FE7D 36 PSH A OF INSTRUCTION FE7E A6 01 LDA A $01,X FE80 36 PSH A FE81 A6 00 LDA A $00,X THIS IS THE OP CODE SO FE83 36 BYTCNT PSH A SCRUTINIZE CAREFULLY FE84 16 TAB FE85 CE FF 75 LDX #OPTAB-1 FE88 08 BYT1 INX FE89 C0 08 SUB B #$08 FE8B 24 FB BCC BYT1 FE8D A6 00 LDA A $00,X FE8F 46 BYT2 ROR A FE90 5C INC B FE91 26 FC BNE BYT2 FE93 32 PUL A FE94 36 PSH A FE95 25 1E BCS BYT7 FE97 81 30 CMP A #$30 CHECK FOR BRANCH FE99 24 04 BCC BYT3 FE9B 81 20 CMP A #$20 FE9D 24 14 BCC BYT5 IS IT A BRANCH FE9F 81 60 BYT3 CMP A #$60 FEA1 25 11 BCS BYT6 IT IS ONE BYTE FEA3 81 8D CMP A #$8D FEA5 27 0C BEQ BYT5 IT IS BSR FEA7 84 BD AND A #$BD FEA9 81 8C CMP A #$8C FEAB 27 04 BEQ BYT4 IS X OR SP IMMEDIATE FEAD 84 30 AND A #$30 CHECK FOR THREE BYTES FEAF 81 30 CMP A #$30 FEB1 C2 FF BYT4 SBC B #$FF FEB3 5C BYT5 INC B FEB4 5C BYT6 INC B FEB5 27 70 BYT7 BEQ BSTRD FEB7 30 TSX FEB8 25 02 BCS STEP1 FEBA E7 01 STA B $01,X BRANCH OFFSET TO 2 FEBC 86 01 STEP1 LDA A #$01 FEBE C1 02 CMP B #$02 FEC0 2E 06 BGT STEP3 FEC2 27 02 BEQ STEP2 TWO BYTES FEC4 A7 01 STA A $01,X FOR ONE BYTES FEC6 A7 02 STEP2 STA A $02,X NOT FOR THREE BYTES FEC8 4F STEP3 CLR A NOW ADD BYTE COUNT TO PC FEC9 EB 06 ADD B $06,X FECB A9 05 ADC A $05,X FECD A7 05 STA A $05,X FECF E7 06 STA B $06,X * DOES THE INSTRUCTION INVOLVE THE PC? IF SO THEN IT * MUST BE INTERPRETED FED1 DE F2 SRCHOP LDX USERS FED3 A7 06 STA A $06,X FED5 E7 07 STA B $07,X UPDATE PC ON USER STACK FED7 C6 06 LDA B #$06 FED9 32 PUL A FEDA 36 PSH A GET COPY OF OPCODE Page 97 H E A T H K I T (R) _______________________________________________________________________________________________ FEDB 84 CF AND A #$CF IS THIS A SUBROUTINE CALL? FEDD 81 8D CMP A #$8D FEDF 32 PUL A FEE0 27 48 BEQ BSRH FEE2 81 6E CMP A #$6E FEE4 27 5B BEQ JPXH IT IS INDEXED JUMP FEE6 81 7E CMP A #$7E FEE8 27 5E BEQ JMPH IT IS EXTENDED JUMP FEEA 81 39 CMP A #$39 FEEC 27 62 BEQ RTSH IT IS RTS FEEE 81 3B CMP A #$3B FEF0 27 6C BEQ RTIH IT IS RTI FEF2 81 3F CMP A #$3F FEF4 27 6E BEQ SWIH IT IS SWI FEF6 AF 06 STS $06,X AIM USER PC AT SCRATCH AREA FEF8 36 PSH A REPLACE OPCODE FEF9 CE FF 05 LDX #SSRET ** SWIVE1 - STEP UP BREAKPOINT RETURN AND JUMP TO USER CODE * * ENTRY: (X) = SWI VECTOR * EXIT: TO USER PROGRAM FEFC 86 7E SWIVE1 LDA A #$7E JUMP OP CODE FEFE 97 F4 STA A SYSSWI FF00 DF F5 STX SYSSWI+1 FF02 9E F2 LDS USERS FF04 3B RTI * THE FOLLOWING CODE IS EXECUTED AFTER A SINGLE STEP * OF AN OUT-OF-PLACE INSTRUCTION. NOW CHECK TO SEE * IF BRANCH OCCURRED, MODIFY THE USER PC ACCORDINGLY FF05 30 SSRET TSX GET SWI HIT LOCATION INTO X FF06 EE 05 LDX $05,X FF08 08 INX FF09 4F CLR A FF0A 5F CLR B FF0B 9C EE CPX TEMP FF0D 26 0C BNE BCHNTK * ADD THE BRANCH OFFSET TO THE USER PC FF0F 09 DEX X WILL NOW POINT AT USERPC FF10 EE 00 LDX $00,X SAVED VALUE OF PC INTO X FF12 09 DEX PREPARE TO FETCH BRANCH OFFSET FF13 E6 00 LDA B $00,X FF15 2A 01 BPL PLUS FF17 43 COM A A IS SIGN EXTENSION OF B FF18 30 PLUS TSX LO COST WAY TO POINT TO USERPC FF19 EE 05 LDX $05,X FF1B EB 01 BCHNTK ADD B $01,X ADD BRANCH OFFSET OR ZERO TO PC FF1D A9 00 ADC A $00,X FF1F 30 TSX PLACE NEW USERPC ONTO STACK FF20 A7 05 STA A $05,X FF22 E7 06 STA B $06,X FF24 09 DEX NOW X AND SP ARE EQUAL FF25 DF F2 STOX STX USERS FF27 9E EE BSTRD LDS TEMP FF29 39 RTS ** SPECIAL HANDLERS ** BSR HANDLER FF2A 81 8D BSRH CMP A #$8D IS IT BSR FF2C 26 02 BNE JSRH FF2E 86 5F LDA A #$5F THIS CONVERTS BSR`S TO BRA`S Page 98 _______________________________________________________________________________________________ H E A T H K I T (R) ** JSR HANDLER FF30 80 3F JSRH SUB A #$3F JSR`S TO JUMPS FF32 36 PSH A CORRECTED OPCODE ONTO STACK FF33 09 DEX FF34 09 DEX FF35 DF F2 STX USERS FF37 A6 03 JSRH1 LDA A $03,X FF39 A7 01 STA A $01,X MOVE USER REGISTERS FF3B 08 INX FF3C 5A DEC B FF3D 2A F8 BPL JSRH1 FF3F 20 90 BRA SRCHOP NOW EXECUTE JUMP INSTRUCT ** JPXH - INDEXED JUMP HANDLER. FF41 33 JPXH PUL B GET OFFSET FF42 4F CLR A FF43 EB 05 ADD B $05,X FF45 A9 04 ADC A $04,X FF47 8C FCB $8C CPX#: ONE BYTE BRA NEWPC ** JMP HANDLER FF48 32 JMPH PUL A FF49 33 PUL B FF4A A7 06 NEWPC STA A $06,X FF4C E7 07 STA B $07,X FF4E 20 D5 BRA STOX RETURN TO CALLER ** RTS HANDLER FF50 08 RTSH INX FF51 08 INX FF52 DF F2 STX USERS NET PULL OF TWO BYTES FF54 A6 03 RTS1 LDA A $03,X MOVE FIVE BYTES FF56 A7 05 STA A $05,X FF58 09 DEX FF59 5A DEC B FF5A 2E F8 BGT RTS1 FF5C 20 C9 BRA BSTRD ** RTI HANDLER FF5E 08 RTIH INX FF5F 5A DEC B FF60 2A FC BPL RTIH FF62 20 C1 BRA STOX ** SWI HANDLER FF64 A6 07 SWIH LDA A $07,X FF66 A7 00 STA A $00,X FF68 09 DEX FF69 5A DEC B FF6A 2A F8 BPL SWIH FF6C 8A 10 ORA A #^00010000 SET INTERUPT MASK FF6E A7 01 STA A $01,X FF70 C6 FA LDA B #-USWI/256*256+USWI USWI LO ORDER FF72 86 00 LDA A #USWI/256 FF74 20 D4 BRA NEWPC PATCH IN UIRQ Page 99 H E A T H K I T (R) _______________________________________________________________________________________________ ** OPTAB - LEGAL OP-CODE LOOKUP TABLE FF76 9C 00 3C OPTAB FDB $9C00,$3CAF,$4000,$00AC,$6412,$6412,$6410,$6410 ; FF79 AF 40 00 00 AC 64 12 ; FF80 64 12 64 10 64 10 FF86 11 01 10 FDB $1101,$1004,$1000,$1000,$110D,$100C,$100C,$100C ; FF89 04 10 00 10 00 11 0D ; FF90 10 0C 10 0C 10 0C ** HEX DISPLAY CODE TABLE FF96 7E 30 6D DISTAB FCC HEX0,HEXl,HEX2,HEX3,HEX4,HEX5,HEX6,HEX7 ; FF99 79 33 5B 5F 70 FF9E 7F 7B 77 FCC HEX8,HEX9,HEXA,HEXB,HEXC,HEXD,HEXE,HEXF ; FFA1 1F 4E 3D 4F 47 ** KEY VALUE TABLE FFA6 07 0A 0D HEXTAB FCC 7,10,13,2,5,8,11,14 ; FFA9 02 05 08 0B 0E FFAE 03 06 09 FCC 3,6,9,12,15,0,1,4 ; FFB1 0C 0F 00 01 04 ** COMMAND HANDLER ENTRY POINT TABLE FFB6 FC 45 FD CMDTAB FDB ZERO,REGA,REGB,REGP,REGX,CONDX,REGS,RESUME,STEP ; FFB9 55 FD 5D FD 65 FD 4F ; FFC0 FD 93 FD A8 FC 96 FE 62 FFC8 FC 46 FD FDB BKSET,AUTO,BACK,REPLAC,DO,EXAM,FOWD ; FFCB 0A FD 18 FD 1B ; FFD0 FC 8C FD 13 FD 16 ; FFD6 FF FF ; FFD8 FF FF FF FF FF FF FF FF ; FFE0 FF FF FF FF FF FF FF FF ; FFE8 FF FF FF FF FF FF FF FF ; FFF0 FF FF FF FF FF FF FF FF FFF8 ORG $FFF8 ** INTERRUPT VECTORS. FFF8 00 F7 FDB UIRQ USER IRQ HANDLER FFFA 00 F4 FDB SYSSWI SYSTEM SWI HANDLER FFFC 00 FD FDB UNMI USER NMI HANDLER FFFE FC 00 FDB RESET 0000 END STATEMENTS =970 FREE BYTES =24298 NO ERRORS DETECTED Page 100 _______________________________________________________________________________________________ H E A T H K I T (R) SYMBOLIC REFERENCE TABLE ADDR FC7E DIGADD 00F0 MEM FCF9 REG1 FD73 AUTO FD0A DISTAB FF96 MEM2 FD07 REPLAC FD1B AUT1 FD0C DIS1 FD7C MONSTK 00E3 REPL1 FD24 BACK FD18 DIS2 FD87 NEWPC FF4A RESET FC00 BADDR FCC6 DO FC8C OPTAB FF76 RESE1 FC15 BCHNTK FF1B DOPMT FC6F OUTBYT FE20 RESUME FC96 BKPT FCCE DOPM1 FC75 OUTCH FE3A RES1 FC9B BKP1 FCD7 DISPLAY FD7B OUTHEX FE28 RES2 FCA3 BKP2 FCE1 ENCODE FDBB OUTH1 FE30 RES3 FCA8 BKP3 FCE6 ENC1 FDE4 OUTSTA FC86 RTIH FF5E BKP4 FCF0 ENC2 FDE7 OUTSTJ FD8C RTSH FF50 BKSET FC46 ENC3 FDED OUTSTR FE52 RTS1 FF54 BKSE1 FC4D ENC4 FDEE OUTST0 FD8D SRCHOP FED1 BKSE2 FC57 EXAM FD13 OUTST1 FE50 SSRET FF05 BKSE3 FC65 FOWD FD16 OUTST3 FE57 SSTEP FE6B BKSP FD43 HEXTAB FFA6 OUT0 FE3C STEP FE62 BKSP1 FD46 IHB FE09 OUT1 FE43 STEP1 FEBC BSRH FF2A IHB1 FE1A PLUS FF18 STEP2 FEC6 BSTRD FF27 INCH FDF4 PROMPT FD25 STEP3 FEC8 BYTCNT FE83 INC1 FDF5 PROM1 FD29 STKPTR FDA8 BYT1 FE88 INC2 FDF7 PROM2 FD33 STOX FF25 BYT2 FE8F INC3 FDFE PROM3 FD3E SWIH FF64 BYT3 FE9F INC4 FE00 REDIS FCBC SWIVE1 FEFC BYT4 FEB1 JMPH FF48 REGA FD55 SYSSWI 00F4 BYT5 FEB3 JPXH FF41 REGA1 FD6D ZERO FC45 BYT6 FEB4 JSRH FF30 REGB FD5D BYT7 FEB5 JSRH1 FF37 REGB1 FD6E CMDTAB FFB6 MAIN FC19 REGP FD65 CONDX FD93 MAIN1 FC21 REGS FDA8 COND0 FD9A MAIN2 FC31 REGX FD4F COND1 FDA0 MAIN3 FC36 REGX1 FD6B ASSEMBLY CONSTANT TABLE * KEYBOARD LOCATIONS * DISPLAY ADDRESSES DG6ADD EQU $C16F LEFTMOST DIGIT COL1 EQU $0003 RIGHTMOST COLUMN DG5ADD EQU $C15F COL2 EQU $0005 DG4ADD EQU $C14F COL3 EQU $0006 LEFTMOST COLUMN DG3ADD EQU $C13F DG2ADD EQU $C12F MISC. CONSTANTS DG1ADD EQU $C11F RIGHTMOST DIGIT TIME EQU 32 NBR EQU 4 NUMBER BREAKPOINTS * DISPLAYED CHARACTER SEGMENT CODES * LTRH EQU $37 HEX0 EQU $7E HEX8 EQU $7F LTRA EQU $7D LTRD EQU $3D HEX1 EQU $30 HEX9 EQU $7B LTRB EQU $1F LTRG EQU $5E HEX2 EQU $6D HEXA EQU $77 LTRC EQU $0D LTRO EQU $1D HEX3 EQU $79 HEXB EQU $1F LTRF EQU $47 LTRR EQU $05 HEX4 EQU $33 HEXC EQU $4E LTRN EQU $15 LTRU EQU $3E HEX5 EQU $5B HEXD EQU $3D LTRI EQU $30 LTRY EQU $3B HEX6 EQU $5F HEXE EQU $4F LTRP EQU $67 LTRS EQU $5B HEX7 EQU $70 HEXF EQU $47 LTRL EQU $0E DASH EQU $0B Reserved Memory Bytes in RAM 00CB USRSTK EQU *-6 00D1 RMB 19 00E3 MONSTK EQU *-1 00E4 BKTBL RMB 2*NBR 00EC T0 RMB 2 TEMPORARY 00EE TEMP RMB 2 USED BY SINGLE STEPPER 00F0 DIGADD RMB 2 DISPLAY POINTER 00F2 USERS RMB 2 USER STACK POINTER 00EF T1 EQU TEMP 00F4 SYSSWI RMB 3 SYSTEM SWI VECTOR 00F7 UIRQ RMB 3 USER IRQ VECTOR 00FA USWI RMB 3 USER SWI VECTOR 00FD UNMI RMB 3 USER NMI VECTOR Page 101 H E A T H K I T (R) _______________________________________________________________________________________________ Memory Memory Map The memory is organized as shown below. Monitor ROM FFFF FC00 Not usable C1FF C170 Displays C16F * C110 Not usable C10F C00F Keyboard C00E * C003 Not usable C002 C000 256 01FF bytes of user RAM 0100 59 bytes RAM 00FF (reserved for monitor) 00C5 197 bytes of 00C4 user RAM 0000 Memory Decoding A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 ROM FFXX IC12 FCXX 1 1 1 1 1 1 X X X X X X X X X X RAM 01XX (Optional) IC16, IC17 0 0 0 0 0 0 0 1 X X X X X X X X RAM 00XX IC14, IC15 0 0 0 0 0 0 0 0 X X X X X X X X KEYBOARD C0-X 1 1 0 0 0 0 0 0 - - - - - X X X DISPLAYS C1XX 1 1 0 0 0 0 0 1 - X X X - X X X 1 = LOGIC 1, 0 = LOGIC 0, - = DOES NOT CARE, X = FUNCTIONING ADDRESS * Not fully decoded. Page 102 _______________________________________________________________________________________________ H E A T H K I T (R) Keyboard And Display Functioning Addresses KEYBOARD BINARY Keys A3 A2 A1 A0 HEX 3, 6, 9, C, F - 0 1 1 3 2, 5, 8, B, E - 1 0 1 5 0, 1, 4, 7, A, D - 1 1 0 6 DISPLAY BINARY LED A6 A5 A4 HEX LED SEGMENTS H 1 1 0 6 a ________ I 1 0 1 5 / / f / / b N 1 0 0 4 /_______/ / g / Z 0 1 1 3 e / / c /_______/ DP V 0 1 0 2 d o C 0 0 1 1 LED BINARY SEGMENT A3 A2 A1 A0 HEX a - 1 1 0 E or 6 b - 1 0 1 D or 5 c - 1 0 0 C or 4 d - 0 1 1 B or 3 e - 0 1 0 A or 2 f - 0 0 1 9 or 1 g - 0 0 0 8 or 0 DP - 1 1 1 F or 7 - = DOES NOT CARE Page 103 H E A T H K I T (R) _______________________________________________________________________________________________ Instruction Set* <<< M6800 INSTRUCTION SET - PAGE ONE >>> Page 104 _______________________________________________________________________________________________ H E A T H K I T (R) <<< M6800 INSTRUCTION SET - PAGE TWO >>> ___________________________________________________________________________________________________________________ TO DO: * Tidy up this version and correct known mistakes * Restore known mistakes to make version "as per scan" / as original. Check this for differences to original * Make assemblable versions of sample programs and main monitor program. Run and test them on Trainer * Make Microsoft Word version of this document including scans * Make web page from Microsoft Word version and publish it ___________________________________________________________________________________________________________________