;;;; Solution to largest of 3 problem ;;;; .org 0xF000 ; begin program code here .move_word 0xEFFD, r1 ; load address to first int .move_word 0xEFFE, r2 ; load address to second int load r3, r1 ; load first int value into r3 load r4, r2 ; load second int value into r4 cmp r4, r3 ; r3-r4 -> first int minus second int bgt L1 ; branch if second int (r4) is greater ; first int (in r3) was greater mov r1, r2 ; save address of first int in r2 mov r3, r4 ; save value of first int in r4 for later L1: ; compare the greater of the first two with the third int .move_word 0xEFFF, r5 ; load address of third int in r5 load r6, r5 ; load value of third int into r6 cmp r4, r6 ; r6-r4 -> third int minus greater of first two bgt L2 ; branch if greater of first two is still the greatest ; third int is the greatest mov r5, r2 ; save the address of the third int in r2 L2: ; store the address of the greatest of 3 into subi 1, r1 ; memory location 0xEFFC stor r2, r1 L3: buc L3 ; loop here forever... .end ;; end of file