Example A Program to Add TwoByte Numbers
Object Add the two-byte number stored at 00FC and 00FD to the two-byte number stored at 00FE and 00FF. Store the two-byte result in locations 0002 and 0003. For all numbers, the least-significant byte is stored in the location with the smallest address. 11 START CLC CLEAR CARRY BEFORE FIRST ADD. CO00 18 12 LDA NUM1LO GET LSB OF FIRST NUMBER. C001 A5 FB 13 ADC NUM2LO ADD LSB OF SECOND NUMBER. C003 65 FD 14 STA SUMLSB STORE IN LSB OF SUM. C005 85 02 15 LDA NUM1HI GET MSB OF FIRST NUMBER. C007 A5...
X The JSR and RTS Instructions
The concept of a subroutine is probably familiar to you from your work with the BASIC programming language. We will postpone a detailed discussion of subroutines until Chapter 9. The exercises at the end of this chapter will make use of subroutines, however, so it is useful to introduce the calling and return instructions at this point. You have already been introduced to the RTS instruction. It is analogous to the RETURN command in BASIC. We have used the RTS instruction at the end of our...
Example A Program to add two numbers
Object Add the numbers stored in locations 00FC and 00FD. Store the sum in location 00FE. CLEAR THE CARRY FLAG BEFORE ADDING. FIND THE FIRST ADDEND IN NUM1. ADD IT TO THE SECOND ADDEND. STORE THE ANSWER IN SUM. The exercises at the end of the chapter will provide you with additional practice in adding binary numbers. A computer-assisted instruction CAI program will allow you to input numbers in hexadecimal, display them in binary, find and display their sum in binary, and display the contents...
Example A Program to Demonstrate the EOR Instruction
Object EOR the numbers in locations 00FB and 00FC. 10 BEGIN LDA NUM1 GET THE FIRST NUMBER. C000 A5 FB 11 EOR NUM2 EXCLUSIVE OR IT WITH THE SECOND. C002 45 FC 12 STA RESULT STORE THE RESULT. CO04 85 FD How do the logic instructions modify the flags in the processor status register Recall that the ADC and SBC instructions made extensive use of and modified the carry flag. Also remember that when doing signed-number arithmetic, the V flag was of considerable importance. The logic instructions AND,...
III Microcomputer System Buses
We turn next to an explanation of how the components of a microcomputer system are interconnected. Refer once again to Figure 1-1. Consider, first, a read operation in which a byte eight bits of information is copied from a memory location or I O device into the microprocessor. The 6510 must first identify the memory location that it wishes to read. Like your house, a memory location is identified by a number called its address. The microprocessor signals the memory location it wishes to read...
Character ROM
If the VIC fetches character patterns from R W memory, then the character patterns are lost each time the power is removed. Since the operating system requires characters to display on the screen when power is first supplied to the Commodore 64, it is desirable to have ch racter patterns stored in ROM rather than R W memory. With some hardware tricks, the Commodore 64 system does just that. When either bank zero or bank two is selected for the VIC and character memory is selected to be at 1000,...
Example Use of the LDA Instruction in Three Addressing Modes
Illustrate an LDA instruction for each of the three addressing modes just described. Solution Assume the operand is in location 1234. Then the complete LDA instruction in the absolute addressing mode is, in order, AD 34 12. If the operand is in page zero of memory, then the zero-page addressing mode can be used. In this case, the LDA instruction consists of two bytes. Assume the operand is in location 003F. Then the LDA instruction is, in order, A5 3F. In the immediate addressing mode, the...
IV The Microcomputer in Action
You now know how information is moved around inside the microcomputer. Although read and write operations are of the greatest importance to the operation of a microcomputer, very little is accomplished by simply moving eight-bit codes back and forth between the 6510 microprocessor and memory. Information must eventually be processed. We turn next to a brief description of some of the processes or operations that can be achieved by the 6510 and an explanation of how they are accomplished. Figure...
