Telechargé par Hamza Zaiker

lesson 1

publicité PROGRAMMING IN ASSEMBLY
BY STEVE BJORK
LESSON 1 – FOUNDATION – IT’S ALL ABOUT THE MATH
HOW MATH WORKS ON THE 6809 CPU
• Digital Electronics has only two states.
• Zero or off
• One or on
• The more states a digit has the more likely to create an error
• With digital, it’s hard to make an error.
• Digital or Binary is also easier for the CPU to do the math.
HOW MATH WORKS ON THE 6809 CPU
• How to do larger numbers
• Our normal math, Decimal or Base-Ten has 10 states per digit.
• 0-1-2-3-4-5-6-7-8-9
• Binary or Base-Two has only two states per digit.
• 0-1
• In Base-Ten math, we can add more Digits to work with numbers
greater than 9.
• The same is true with Base-Two math.
HOW MATH WORKS ON THE 6809 CPU
Using extra digits for larger number like 245 in Base Ten.
1,000
0
100
2
10
4
1
5
0*(1000) + 2*(100) + 4*(10) + 5*(1) = 245
Using extra digits for larger numbers like 245 in Base Two.
128
1
64
1
32
1
16
1
8
0
4
1
2
0
1
1
1*(128) + 1*(64) + 1*(32) + 1*(16) + 0*(8) + 1*(4) + 0*(2) + 1*(1) = 245
HOW MATH WORKS ON THE 6809 CPU
• With so many digits in binary, sometimes we use Base-Sixteen.
• Hexadecimal – Think 6 + 10 or 16 digits.
• The numbers are 0-1-2-3-4-5-6-7-8-9-A-B-C-D-E-F.
• A=10, B=11, C=12, D=13, E=14 and F=15.
• Using extra digits for larger numbers like 245 in Base-Sixteen.
256
16
1
15
5
0*(256) + 15*(16) + 5*(1) = 245 or (\$F5 in Hexadecimal)
HOW MATH WORKS ON THE 6809 CPU
• 8-Bit and 16-Bit numbers are used by the 6809.
• Hexadecimal digit represents 4-bits (Nibble) in Binary.
• 8-Bit Hexadecimal is from \$00 to \$FF or 0 - 255 in decimal.
• 16-Bit Hexadecimal is from \$00 to \$FFFF or 0 - 65535 in decimal.
HOW MATH WORKS ON THE 6809 CPU
• Inside the 6809 CPU there are 8-Bit and 16-Bit registers.
• The A and B registers are 8-Bit each and use as accumulators.
• 6809 does most of its math in the A and B registers.
• The A and B Registers can be combined to make the D (16-Bit)
Register.
• The A Register is the top half and the B is the bottom half of
the D Register.
HOW MATH WORKS ON THE 6809 CPU
• The X, Y, U, S, PC Registers are the 16-Bit memory pointers.
• They are used to address any byte of the 64Kof memory.
• From 0-65535 or \$0 to \$FFFF.
• This is why the CoCo can NOT access more than 64K of Ram
without extra Hardware like the Memory Management Unit.
• Limited Math can also be done with the X, Y, U, S Registers.
HOW MATH
WORKS ON
THE 6809 CPU
• All of the 6809
Registers.