//Salman Taş 20191701044
void setup() {
asm volatile (
".equ DDRB, 0x04 \n"
".equ PORTB, 0x05 \n" // set as output
".equ DDRD, 0x0A \n"
".equ PIND, 0x09 \n" // set as input
"mainProgram: \n" // Main program
" in r21, PIND \n" // read from PIND to r21
" cpi r21, 0b11110000 \n" // compare r21 with 11110000
" breq yellow \n" // Branch if Equal to yellow
" brlo red \n" // Branch if Lower to red
" brsh green \n" // Branch if Same or Higher to green
" jmp mainProgram \n" //(no need for this line; just to make sure)
"yellow: \n" // yellow
" cbi PORTB, 0 \n" // off pin 0
" sbi PORTB, 1 \n" // on pin 1
" cbi PORTB, 2 \n" // off pin 2
" jmp mainProgram \n" // Jump to mainProgram
"red: \n" // red
" cbi PORTB, 0 \n" // off pin 0
" cbi PORTB, 1 \n" // off pin 1
" sbi PORTB, 2 \n" // on pin 2
" jmp mainProgram \n" // Jump to mainProgram
"green: \n" // green || since breq is before brsh I don't need additional check here
" sbi PORTB, 0 \n" // on pin 0
" cbi PORTB, 1 \n" // off pin 1
" cbi PORTB, 2 \n" // off pin 2
" jmp mainProgram \n" // Jump to mainProgram
);
}
void loop() {
}
// pin 0 and 1 resposible for serial connection, so they are throwing random chars.
// but circuit works ok
mid
most
least