Files
rear/Aufgabe1.X68

68 lines
1.4 KiB
Plaintext

*-----------------------------------------------------------
* Title : Aufgabe 1
* Written by : Manuel Vögele and Simon Wörner (Team 1)
* Date : 2015-04-28
* Description: This program compares two strings and calculates the sum of the smaller characters
*-----------------------------------------------------------
ORG $1000
START: ; This is where the program starts - obviously
* Put program code here
; Clear variables
clr.l Sum
; Load string address
move.l #String1, A0
move.l #String2, A1
move.l #String3, A2
LOOP:
; Load chars to register
move.b (A0), D0
move.b (A1), D1
; If end of string is reached end loop
cmp.b #0, D0
beq LOOP_END
; If String2[i] <= String1[i] jump to ADD_STRING2
cmp.b D0, D1
ble ADD_STRING2
; Add lower char to Sum
ADD_STRING1:
add.l D0, Sum
move.b D0, (A2)
bra LOOP_FOOTER
ADD_STRING2:
add.l D1, Sum
move.b D1, (A2)
; Move to next char
LOOP_FOOTER:
add.l #1, A0
add.l #1, A1
add.l #1, A2
bra LOOP
LOOP_END:
; Add '\0'
move.b #0, (A2)
SIMHALT ; halt simulator
* Put variables and constants here
String1 dc.b 'Studierender',0
String2 dc.b 'Informatiker',0
String3 ds.b 13
Sum ds.l 1
END START ; last line of source
*~Font name~Courier New~
*~Font size~10~
*~Tab type~1~
*~Tab size~4~