简易计算器的pld实现毕业设计论文(编辑修改稿)内容摘要:

s store and manipulate data using the binary number system, which prises just two digits: 0 and 1. One wire (or register bit/memory element) can be used to represent two distinct binary values: 0 or 1。 two wires can represent four binary values: 00, 01, 10, and 11。 three wires can represent eight binary values: 000, 001, 010, 011, 100, 101, 110, and 111。 and so on. As our virtual puter has an 8bit data bus, this can be used to represent 256 different binary values numbered from 0 to 255 in decimal or %00000000 to %11111111 in binary(where the “%” symbol is used to indicate a binary value). The problem is that humans tend to find it difficult to think in terms of long strings of 0s or 1s. Thus, when working with puters, we tend to prefer the hexadecimal number system, which prises 16 digits: 0 through 9 and A through F as shown in Figure 2. Figure 2. Binary and hexadecimal In this case, we use “$” characters to indicate hexadecimal values. Each hexadecimal digit directly maps onto four binary digits (and vice versa of course). This explains why we noted earlier that our 16 bit address bus could be used to point to 216 = 65,536 different memory locations, which are numbered from $0000 to $FFFF in hexadecimal. The Accumulator (ACC) and Status Register (SR) There are just a couple more things we need to know before we plunge head first into the fray. Amongst other things, our CPU contains two 8bit registers called the accumulator (ACC) and the status register (SR). (In this context, the term “register” refers to a group of memory elements, each of which can store a single binary digit.) As its name implies, the accumulator is where the CPU gathers, or “accumulates”, intermediate results. In the case of the status register, each of its bits is called a status bit, but they are also monly referred to as status flags or condition codes, because they serve to signal (flag) that certain conditions have occurred. We will only concern ourselves with the carry(C) flag for the purposes of our example program. Since we may sometimes wish to load the status register from (or store it to) the memory, it is usual to regard this register as being the same width as the data bus (eight bits in the case of our virtual system). However, our CPU employs only five status flags, which occupy the five leastsignificant bits of the status register. This means that the three mostsignificant bits of the register exist only in our imaginations, so their nonexistent contents are, by definition, undefined. The Program Itself For the purposes of this article, we’re going to create a simple program that first clears the calculator’s main display, and then loops around waiting for us to click one or buttons on the keypad. If any of these buttons are part of the “0” through “9” or “A” through “F” set, we’re going to display these value on the main display. Let’s walk through this code stepbystep. The first thing we do is to declare some constant labels and associated them with certain values using. In the case of this program, the CLRCODE label is associated with a hexadecimal value of $10, which is a special code that will clear the calculator’s main display. By parison, the MAINDISP label is associated with the hexadecimal value $F031, which happens to be the address of the output port that drives the calculator’s main display. Similarly, the KEYPAD label is associated with the hexadecimal value $F011, which is the address of the input port that is connected to the calculator’s keypad. (Note that everything to the right of a “” character is treated as a ment and is therefore ignored by the assembler.) Following the EQU mands we see a ORG (“origin”) statement, which we use to specify $4000 as being the start address in our program. (The reason we use $4000 is that this is the first address in the DIY Calculator’s virtual RAM. When we e to run the program, the DIY Calculator will automatically start at this address.) Next, we use a LDA(“load accumulator”) instruction to load our special clear code into the accumulator, and then we use a STA (“store accumulator”) instruction to copy this value to the main display, thereby clearing it. Now we find ourselves at the LOOP address label, whi。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。