The Break Routine

The last ISR we will look at is the Break routine. This one is a bit different from the other two. It never returns, like the others do. It is ran as a result of the BREAK/RUN switch being thrown to the BREAK position. It uses INT1, the other interrupt input to the DS5000.

It's purpose is to store the entire contents of the DS5000 registers into external data memory. The reason this is done, is that when the DS5000 is placed in the Load mode, many of the internal RAM locations are used for the communications to the PC, and are destroyed before you get a chance to read them. By storing them in external memory, every last bit of information can be looked at.

There is a strict sequence needed to get everything out of the DS5000, without loosing anything. It stores all the data starting at location 4000h in external memory. The map of what is where is shown in the listing. The first 128 locations hold the contents of the internal RAM. The rest holds the various Special Function Registers that can be read out. There are 18 of these, plus 2 that show the address of the next instruction that would have been executed if the break switch hadn't been thrown. So the total is 148 bytes of data saved in external memory( up through location 4093h).

This is a very usefull routine for troubleshooting problems in the code. The idea is to throw the switch at the time you want to know the state of the DS5000. Then put the LOAD/RUN switch to the LOAD position and run the DUMPI.EXE utility to display the information on the PC.

Starting at the label dumpi, tst is set. Tst is equated to pin 22 of the DS5000, and connects to the test led, so that it lights when this routine is entered. I did this just so I could see that the break had been acknowledged by the DS5000. You can leave this in or take it out to suit your needs.

Next the dptr is pushed onto the stack, so it can be used by this routine to more easily store the rest of the data. Then the dptr is set to the address of dumpx + 80h. If you notice, at the start of the program listing, dumpx is set 4000h with a .set assembler directive. So we have just set dptr to 4080h, the first location after where all the internal RAM contents are to be stored.

Next the accumulator is stored, so it can be used by this routine. I won't say it after this, but the dptr points to the location where the data will be stored, and gets incremented after each store. Also the accumulator holds the data to be stored at the location pointed to by dptr. The accumulator first gets loaded with the data, and then it's stored by dptr. This sequence gets executed repeatedly, untill all the data is save in external memory.

Next the accumulator is popped, which retrieves the high byte of the dptr that was pushed previously, and then is stored. Then the low byte of the dptr is retrieved, by popping the accumulator again, then stored. We have now saved off the contents of the registers we are using to perform the dump.

Next the PSW is stored, then the SP. Next the address of the next instruction that would have been executed had the break not happened, that was pushed as a result of the interrupt, is stored. This is done by popping the accumulator again, which gets the high byte of the address. Then the low byte is popped into the accumulator and stored. This ends the tricky stuff, that needed to be done first.

The rest of the stores are pretty straightforward, with the register being loaded into the accumulator, and then stored at the location pointed to by dptr. Lastly the dptr is loaded with 4000h and the internal RAM locations are stored. I notice a problem with this routine. I need to load the PSW with a 00h, to make sure that we are using bank 0. I'll change that for BEGIN3.ASM. Otherwise, if we were in one of the ISR's, the r0 and r1 that is used wouldn't end up in the proper locatons.

The first to go are r0 and r1, which are then used for the rest of the locations. When all have been dumped, the program goes into a closed loop, and waits there forever. Now the LOAD/RUN can be placed in the LOAD position, and DUMPI.EXE can be ran on the PC to see the data. You can also run DUMPM.EXE to view any external memory. See the docs in kenutils.zip for more info on this.

You'll notice, towards the end of the listing, a sort of template (msg01) and some text that was used by a routine called stmsg. This was to output a startup message in the display. The routine is still in the code, and you can see how the display is arranged. Following that are various lookup tables and at the end is some X-10 information.

THIS IS THE END

That ends this course. I'm sorry I took so long, but at least it's done now. I Hope that I gave you the itch to go further, since what I've given you here is definitly not the last word on micros. It's just a feeble beginning. I may update this course from time to time, to fix problems that I find. I will try to indicate it by changing dates on the various lessons. By the time you read this I will have updated BEGIN3.ASM to reflect the things that I noticed were wrong in BEGIN2.ASM. However begin2.asm is functional and will run perfectly, as written. I will also update the schematic to show the parts connected to the analog inputs of the A/D converter.

Good luck on your pursuits, and God Bless You.

Kenneth Richardson
 

My home page is http://www.hkrmicrop.com/personal/index.html .

Back to the Table of Contents