6809 Assembler and Emulator
Students are to use the online 6809 Assembler and Emulator to perform this lab. The website for the online assembler is 'http://www.asm80.com/index.html'.
Assembler: Programs must first be saved as '.a09' files prior to compiling. Emulator Programs can be run using the 'Animate' button, and stopped using the 'STOP' button. Programs can also be run by stepping through each individual instruction using the 'Single Step' button. Each program jumps to address $D000 when complete, so adding a Breakpoint at $D000 may be beneficial.
PROGRAM B-Bubble Sort
ORG $100
LIST: FCB 11,3,8,7,1,9,-3,4,5
LSTEND: RMB
NVAL: RMB 2
STRT: LDY #LSTEND
LEAU -1,y
STU LSTEND
LEAY -LIST,y
STY NVAL
LEAY -1,y
LOOP1: LDX #LIST
LOOP2: LDA ,X+
CMPA BLS NEXT
LDB ,X
STA ,X
STB -1,x
NEXT: CMPX LSTEND
BLO LOOP2
LEAX -1,x
STX LSTEND
XEND: LEAY -1,y
BNE LOOP1
RETN: JMP $D000
END
Objective: The following program sorts a list of n one-byte numbers, using a very simple version of a sorting algorithm known as bubble sort. The list is scanned from top to bottom, comparing adjacent entries and swapping them if they are in the wrong order. After n-1 passes through the list, the entries are sorted in ascending numerical order.
1. Where and what data will be sorted?
2. What is the purpose of the reserved memory bytes (identify them)?
3. Identify the start and end of each loop. How many loops are there?
4. How are the counters and pointers established for each loop? (in which registers or memory locations)
5. On what condition does the program exit each loop?
6. What is accomplished by one pass through the inner loop?