#ifdef VERBETERING * g o a t s e x * g o a t s e x * g o a t s e x * g g o / \ \ / \ o a| | \ | | a t| `. | | : t s` | | \| | s e \ | / / \\\ --__ \\ : e x \ \/ _--~~ ~--__| \ | x * \ \_-~ ~-_\ | * g \_ \ _.--------.______\| | g o \ \______// _ ___ _ (_(__> \ | o a \ . C ___) ______ (_(____> | / a t /\ | C ____)/ \ (_____> |_/ t s / /\| C_____) | (___> / \ s e | ( _C_____)\______/ // _/ / \ e x | \ |__ \\_________// (__/ | x * | \ \____) `---- --' | * g | \_ ___\ /_ _/ | g o | / | | \ | o a | | / \ \ | a t | / / | | \ |t s | / / \__/\___/ | |s e | / / | | | |e x | | | | | |x * g o a t s e x * g o a t s e x * g o a t s e x * #endif #include int main() { int a = 23; int b = 98; int c = 17; int swap = 0; printf("De mediaan van verzameling [a, b, c]\n"); if ( a > b ) { swap = b; b = a; a = swap; } if ( a > c ) { swap = c; c = a; a = swap; } if ( b > c ) { swap = b; b = c; c = swap; } printf("[%d, %d, %d]\n",a, b, c); return 0; } Is in MIPS ASM: .text .globl main main: lui $2, 0x1000 ori $1, $0, 0 ori $12, $0, 1 lw $8, 0x00($2) # A lw $9, 0x04($2) # B lw $10, 0x08($2) # C sll $0, $0, 0 slt $11, $8, $9 # 1 als A kleiner is dan B anders 0 bne $12, $11, swap1 # Als dat niet waar is wisselen sll $0, $0, 0 slt $11, $8, $10 bne $12, $11, swap2 sll $0, $0,0 slt $11, $9, $10 bne $12, $11, swap3 sll $0, $0, 0 swap1: or $13, $0, $9 # swap = b or $9, $0, $8 # b = c or $8, $0, $13 # a = swap swap2: or $13, $0, $10 # swap = c or $10, $0, $8 # c = a or $8, $0, $13 # a = swap swap3: or $13, $0, $9 # swap = b or $9, $0, $10 # b = c or $10, $0, $13 # c = swap j save sll $0, $0, 0 save: sw $9,0x0c($2) sll $0, $0, 0 lw $15, 0x0c($2) j exit sll $0, $0, 0 exit: sll $0, $0, 0 .data A: .word 23 B: .word 98 C: .word 17 ZONDERRRRRRRRRR I/O!!