#include "dt_inc.s" .data .org 0x0 arr: .fill 2 .fill 3 .fill 5 .fill 7 .fill 11 .fill 13 .fill 17 .fill 19 .fill 23 .fill 29 .fill 31 .fill 37 .fill 41 .fill 43 .fill 47 .fill 53 str: .ascii "hier das ergebnis: " .text .org 0x0 start: br+ main br+ main ret main: call+ u_init call+ u_recv_byte call u_send_newline ; benchprolog call t_init call t_stop ldis r1, 0 call t_valset call t_start ; /benchprolog ; max start ldis r1, 16 ldil r2, arr@lo ldih r2, arr@hi call+ max ; max end ; benchepilog push r0 call+ t_init call+ t_stop call+ t_valget subi r0, r0, 0xc ; offset abziehen pop r3 push r0 push r3 ; /benchepilog call u_init ; weil r10 ueberschrieben wird ldis r1, str@lo ldih r1, str@hi ldis r2, 19 call u_send_string pop r1 call+ u_send_uint call u_send_newline pop r1 call+ u_send_uint call u_send_newline br+ main max: ; r1 = len ; r2 = arr ; r4 = arr[x] ; r0 = x = arr[0] ldw r0, 0(r2) subi r5, r1, 1 andx r5, 0x3 cmpi r5, 0 breq+ loop0 cmpi r5, 1 addideq r1, r1, 3-1 subideq r2, r2, 12 breq+ loop1 cmpi r5, 2 addideq r1, r1, 2-1 subideq r2, r2, 8 breq+ loop2 cmpi r5, 3 ; addideq r1, r1, 1-1 subideq r2, r2, 4 breq+ loop3 loop0: addi r1, r1, 4-1 maxloop: subi r1, r1, 4 retzs- ldw r4, 4(r2) cmp r0, r4 movlt r0, r4 loop1: ldw r4, 8(r2) cmp r0, r4 movlt r0, r4 loop2: ldw r4, 12(r2) cmp r0, r4 movlt r0, r4 loop3: ldw r4, 16(r2) cmp r0, r4 movlt r0, r4 addi r2, r2, 4*4 br+ maxloop