.include "m8def.inc" ldi r16, HIGH (RAMEND) out SPH, r16 ldi r16, LOW (RAMEND) out SPL, r16 ldi r16, 0xff out DDRD, r16 rcall lcd_init ;Display initialisieren rcall lcd_clear ;Display l"oschen ldi ZH, HIGH(sortstr) ldi ZL, LOW(sortstr) ldi r16, 0 ldi r17, 'a' loop1: st Z+, r17 inc r17 inc r16 cpi r16, 16 brlt loop1 ldi ZH, HIGH (sortstr) ldi ZL, LOW (sortstr) ldi r19, 0 loop2: ld r16, Z+ rcall lcd_data inc r19 cpi r19, 16 brlt loop2 .def temp1 = r16 .def temp2 = r17 .def temp3 = r18 .include "lcd-routines.asm" .dseg sortstr: .byte 16
so, das programm tut Bisher sind sie noch nicht sortiert und ich muss noch kurz aufräumen dann sortiere ich sie. Sie sind sortiert, weil ich sie so rauf gezählt eingegeben habe, aber ich sortier sie umgekehrt herum.
.include "m8def.inc" ldi r16, HIGH (RAMEND) out SPH, r16 ldi r16, LOW (RAMEND) out SPL, r16 ldi r16, 0xff out DDRD, r16 rcall lcd_init ;Display initialisieren rcall lcd_clear ;Display l"oschen ldi ZH, HIGH(sortstr) ldi ZL, LOW(sortstr) ldi r16, 0 ldi r17, 'a' loop1: st Z+, r17 inc r17 inc r16 cpi r16, 16 brlt loop1 ldi ZH, HIGH (sortstr) ldi ZL, LOW (sortstr) ldi r20, 0 loop3: ldi r21, 0 mov YH, ZH mov YL, ZL loop4: ld r16, Z ld r17, Y cp r16, r17 brge noexchange ld r16, Z ld r17, Y st Z, r17 st Y, r16 noexchange: ld r16, Y+ inc r21 cpi r21, 16 brlt loop4 ld r17, Z+ inc r20 cpi r20, 16 brlt loop3 ldi ZH, HIGH (sortstr) ldi ZL, LOW (sortstr) ldi r19, 0 loop2: ld r16, Z+ rcall lcd_data inc r19 cpi r19, 16 brlt loop2 .def temp1 = r16 .def temp2 = r17 .def temp3 = r18 .include "lcd-routines.asm" .dseg sortstr: .byte 16