Bottom
Next
Contents
Advanced Machine Code Techniques for the BBC Micro
Contents
Preface
Chapter One Architecture of the BBC Machine
Background material
von Neumann's influence
The computer generations
The micro processor
16-bit microprocessors
Software development
Hardware of the BBC Micro
Removing the top cover
Locating the components
Sending characters to screen output
The ROM chips
Bank-switching
PROM programmers
The user port
Interrupt requests
Serial and parallel interfaces
The RS423 interface
Analogue to digital conversion
Using the four channels
Floppy disk controller
Memory mapping and page numbers
Sheila addresses
Fred addresses and the 1 MHz Bus
JIM addresses and the 1 MHz bus
Suggestions for 1 MHz bus projects
Address decoding
Sending parallel data externally
Using the R/NW line
Using Jim to access auxiliary memory
Summary
Self test
Chapter Two The 6502 Microprocessor
Useful abbreviations and conventions
The 6502 versus the Z80
6502 architecture
Inside the 6502
Directly programmable internal registers
Accumulator (A)
The X and Y registers
The process status register (P)
The stack pointer (SP)
Registers which are not directly programmable
The Program Counter (PC)
The Instruction Register (IR)
The Data Register (DR)
The Address Register (ARL and ARH)
The microprogram
The decoding matrix
Sub-pulses of the clock
The Arithmetic and Logic Unit
Software Interrupt (BRK)
Summary
Self test
Chapter Three The 6502 Instructions and Addressing Modes
Initial terms and definitions
Factors influencing choice
Operational symbols
Classification of instructions
Finding temporary homes for data
Performing arithmetic
Clearing memory and registers
Up-counting and down-counting
Processing particular bits
One's complement of accumulator
Two's complement of accumulator
Finding the state of a particular bit
Double byte multiplication
Double byte division
Branching techniques
Comparisons
Addressing modes
Implied addressing
Immediate addressing
Absolute addressing
Zero-page addressing
Relative addressing
Indexed addressing
Indirect addressing
Indirect indexed addressing
Indexed indirect addressing
Summary
Self test
Chapter Four Handling the Resident Assembler
The assembler format
Mnemonic op codes
Numerical operands
Operand variables
Branch labels
Remarks
Multi-statements
Storing assembly code
Fixed locations which are potentially free
Operating the assembler code
Controlling the assembler output
The forward branch problem and 2-pass assembly
Using variable names
Macros
Conditional assembly
Passing parameters via registers
Passing parameters with CALL
Passing variables by means of USR
USR or CALL?
Indirection operators
Saving and loading machine code
Summary
Self Test
Chapter Five Multi-byte Loops
Two-byte operations
Incrementing a two-byte number
Decrementing a two-byte number
Adding two single-byte numbers
Adding a single byte number to a double-byte number
Four-byte operations
Simple four byte addition
Simple four-byte subtraction
Multiple byte loop (up-counting)
Multiple-byte loop (down-counting)
Adding an array of integers
Summary
Self Test
Chapter Six Sort Routines
Bubble sort of a BASIC integer array
How integer array variables are stored
Bubble sort of a BASIC string array
How string arrays are stored
Merge sort of BASIC integer array
Merge sort of a BASIC string array.
Merge sort of an unsigned BASIC floating point array
How floating point variables are stored
Machine code sort routines applied to BASIC multifield filing progroms
Merge sort of multifield fixed length records
Merge sort of a two-dimensional string array
Table of sorting times
Summary
Self test
Chapter Seven Using Subroutines, Macros and Look-up Tables
User subroutines
Resident subroutines
Vectors and indirection
Using OSWORD
Using OSWRCH
Relating OSWRCH to VDU codes
The macro approach
The look-up table approach
Summary
Self test
Chapter Eight Direct Screen Addressing and Hardware Scrolling
Direct screen addressing overview
Colour animation by addressing direct screen locations
Multi-colour MOBs
Address coordinates
Moving more than one shape
Hardware scrolling by programming the 6845 CRTC
Sideways scrolling
Vertical scrolling
Summary
Self test
Chapter Nine Interrupt Techniques and the User Port
The anatomy of the user port
The 6522 VIA registers
The VIA internal registers
DDRB (Data Direction Register B)
ORB or IRB (Output Register B or Input Register B)
The two control lines
PCR (Peripheral Control Reigster)
Behaviour of CB2 when it is an output
The IFR (Interrupt Flag Register)
The IER (Interrupt Enable Register)
The timers and counters
Timer T2 details
Timer T1 details
The SR (Shift Register)
Summary of the user port and its functions
Internally generated interrupts
Peripheral initiated interrupts
Summary
Self test
Appendix A Binary and Logic
Binary
Unsigned binary system
Hexadecimal notation (hex}
Hex arithmetic
Signed binary and two's complement
Binary coded decimal (BCD)
Logic
Low levels and TTL
Logic gates
Active levels and negation
Dominance of NAND and INVERTER gates
Use of gates
Flip-flops
Wired OR and tristate outputs
Mechanical switches
Driving lamps and relays
Schmitt triggers
Timer chips
Decoders
Demultiplexers
Multiplexers
Encoders
Counters
Shift registers
Buffer registers
Appendix B Operating System Calls
Appendix C 6502 Complete Instruction Set
Appendix C1 Complete Instruction Set
Appendix C2 6502 Instruction Set: Classification by processor flag
Appendix C3 6502 Instruction Set: Classification by addressing modes
Appendix C4 6502 Instructions in order of common usage
Appendix D Glossary of Terms
Answers to Self Test Questions
Chapter One
Chapter Two
Chapter Three
Chapter Four
Chapter Five
Chapter Six
Chapter Nine
Index
Next
Top