Page 28 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 28

Introduction to Microprocessors


                  Notes          interrupt. An interrupt is used to stop one program and execute another in its place. In our case,
                                 we want interrupt 32, which ends our program and goes back to MS-DOS, or whatever other
                                 program was used to start our program.
                                 2.1.1 Running the Program

                                 Let’s go ahead and run this program. First, be sure to print these instructions out, since you will
                                 need to refer to them as we go on. Next, click on your start menu, and run the program called
                                 MS-DOS Prompt. A black screen with white text should appear. We are now in MS-DOS, the way
                                 computers used to be 20 years ago. MS-DOS was before the days of the mouse, so you must type
                                 commands on the keyboard to make the computer do things.
                                 First, we want you to type the word debug, and press enter. The cursor should move down a line,
                                 and you should see the Debug prompt, which is a simple dash. We are now in a program called
                                 Debug. Debug is a powerful utility that lets you directly access the registers and memory of your
                                 computer for various purposes. In our case, we want to enter our program into memory and run
                                 it, so we’ll use Debug’s a command, for assemble. Go ahead and type a100 now. The cursor will
                                 move down another line, and you will see something like 1073:0100. This is the memory location
                                 we are going to enter assembly language instructions at. The first number is the segment, and the
                                 second number is the memory location within the segment. Your Debug program will probably
                                 pick a different segment for your program than mine did, so don’t worry if it’s different. Another
                                 thing to note is that Debug only understands hexadecimal numbers, which are a sort of computer
                                 shorthand. Hexadecimal numbers sometimes contain letters as well as well as digits.
                                 Let’s go ahead and enter our program now. Type each of the instructions below into Debug
                                 exactly as they appear, and press enter after each one. When you finish entering the last instruction,
                                 press enter twice to tell Debug that we are done entering instructions.
                                 mov ax,B800
                                 mov ds,ax
                                 mov byte[0F9E],24
                                 int 20

                                 As you can see, we have converted all the numbers into hexadecimal, and have made a few other
                                 changes so Debug can understand what’s going on. If you make a mistake while entering the
                                 above program, press enter twice, type a100, and start entering instructions again at the beginning
                                 of the program.
                                 Once you have entered the program, you can go ahead and run it. Simply type g for go and press
                                 enter when you are ready to start the program.
                                 Let’s get back to Windows now. Go ahead and type q to get out of Debug. Now, type exit to get
                                 out of MS-DOS. You should now be back in Windows.

                                 2.1.2 Opcodes and Operands
                                 Two of the parts (OPCODE and OPERANDS) are mandatory. An instruction must have an
                                 OPCODE (the thing the instruction is to do), and the appropriate number of operands (the things
                                 it is supposed to do it to). The OPCODE is a symbolic name for the opcode of the corresponding
                                 LC-3b instruction. The idea is that it is easier to remember an operation by the symbolic name
                                 ADD, AND, or LDW than by the four-bit quantity 0001, 0101, or 0110. The number of operands
                                 depends on the operation being performed. For example, the ADD instruction (line 0E) requires
                                 three operands (two sources to obtain the numbers to be added, and one destination to designate
                                 where the result is to be placed). All three operands must be explicitly identified in the instruction.




        22                               LOVELY PROFESSIONAL UNIVERSITY
   23   24   25   26   27   28   29   30   31   32   33