MIMAGolf
Challenges
Playground
Login
Register
Playground
You can test your own MIMA programs here.
There is no tutorial here yet, but we might add one later.
It looks like you don't have JavaScript enabled. Please enable JavaScript to simulate the MIMA client-side.
; Find the largest element in an array * = 0 ARR1: DS 51 ARR2: DS 43 ARR3: DS 12 ARR4: DS 90 ARR5: DS 1000 * = $40 ARRLEN: DS 5 ; Length of the array MAX: DS 0 ; The maximum value (store the result here) -MAX: DS 0 ; -MAX, used in calculations POS_ONE: DS 1 ; Position of the number 1 (useful in calculations) INDEX: DS 0 ; The current index into the array. * = $100 LOOP: LDIV INDEX ; Load current array value ADD -MAX ; Subtract current max value JMN LOOP_END ; If new - max < 0, max > new, so nothing changes LDIV INDEX ; new > max, therefore, we store new in max STV MAX ; store new max NOT ; Calculate -max ADD POS_ONE STV -MAX ; Update -max in storage LOOP_END: LDV INDEX ; No matter what happens, always advance to the next element ADD POS_ONE STV INDEX EQL ARRLEN ; Check if index == arrlen (=> we checked the whole array)) JMN END JMP LOOP END: HALT ; We are done here.
Compile
The memory is empty or the MIMA is not yet initialized.