summary refs log tree commit diff
path: root/F2024/coe718/labs/lab2/cond_exe/cond_ex.c
blob: 473a9bd20e6cfdf3bef40c11eb3e50ec42785a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//conditional execution code example
#include "LPC17xx.h"

int main(void){
	int r1 = 1, r2 = 0;
	
	while(r1 <= 0x07){
		if((r1 - r2) > 0){
		  r1 = r1 + 2;
	}
		else{
			r2 = r2 + 1;
		}
	}
	return 0;
}


/* //barrel shifter code
#include "LPC17xx.h"

int main(void){
	int r1 = 1, r2 = 0, r3 = 5;
	
	while(r2 <= 0x18){
		if((r1 - r2) > 0){
		  r1 = r1 + 2;
			r2 = r1 + (r3*4);
			r3 = r3/2;
	}
		else{
			r2 = r2 + 1;
		}
	}
	return 0;
}*/