Programming examples of 6800


Now, in this section, we will see how we can use the Motorola M6800 Microprocessor to add multi-Byte numbers.

  • AddingMulti-Byte Number

In this example, we are using 4-Byte numbers (56 2F 7A 89)16 and (21 FB A9 AF)16

In the memory, at first, we are storing the Byte counts, and then the numbers (from least significant Bytes to Most significant Bytes) in different segments. So after storing the data, the memory structure will be looking like this

Address
Value
5000H
04H


.
.
.
5050H
89H
5051H
7AH
5052H
2FH
5053H
56H


.
.
.
5070H
AFH
5071H
A9H
5072H
FBH
5073H
21H


.
.
.


Now, we are writing a program to add these two 4-Byte number and store the result at location 5090H onwards.

Program

      CLC
      LDX#$5050

LOOP: LDAA $0, X
      ADCA $20, X
      STAA $40, X


      INX
      DEC$5000
      BNELOOP

      CLR$40, X
      BCCDONE
      INC$40, X
DONE: WAI

Output

Address
Value
5000H
04H


.
.
.
5050H
89H
5051H
7AH
5052H
2FH
5053H
56H


.
.
.
5070H
AFH
5071H
A9H
5072H
FBH
5073H
21H


.
.
.
5090H
38H
5091H
24H
5092H
2BH
5093H
78H
5094H
00H


  • BlockExchange Program

Now we will see how we can use the M6800 Microprocessor to Exchange the contents of each element from two different blocks.

The number of items in each block is given at location 5000H, and the blocks are at position 5050H and 5070H.

So before swapping the items in the memory is looking like this

Address
Value
 5000H
04H


.
.
.
5050H
89H
5051H
7AH
5052H
2FH
5053H
56H


.
.
.
5070H
AFH
5071H
A9H
5072H
FBH
5073H
21H


.
.
.


Now, we are writing a program to exchange the block contents.

Program

      LDX#$5050
     
LOOP: LDAA 0, X
      LDAB $20 X

      STAA $20, X
      STAB $0, X

      INX
      DEC$5000
      BNELOOP
      WAI

Output


Address
Value
 5000H
04H


.
.
.
5050H
AFH
5051H
A9H
5052H
FBH
5053H
21H


.
.
.
5070H
89H
5071H
7AH
5072H
2FH
5073H
56H


.
.
.


  • Move block of data

Let us see another example of the M6800 Microprocessor Program. Here the program is to move a block of data to another location. There is one assumption, there is sufficient distance between source and destination. So blocks are not-overlapping. Basically, the block movement is not exactly moving, itis copying the data to other locations.

The number of items in the block is given at location 5000H, and the block is located at position 5050H.

So before movement, the items in the memory is looking like this.

Address
Value
 5000H
04H


.
.
.
5050H
89H
5051H
7AH
5052H
2FH
5053H
56H


.
.
.


Now, we are writing a program to move the block contents to other locations.

Program

LDX#$5050
LOOP: LDAA 0, X
STAA $20, X
INX
DEC$5000
BNELOOP

      WAI

Output

Address
Value
 5000H
04H


.
.
.
5050H
89H
5051H
7AH
5052H
2FH
5053H
56H


.
.
.
5070H
89H
5071H
7AH
5072H
2FH
5073H
56H


.
.
.

Updated on: 27-Jun-2020

530 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements