nothing9099
Newbie level 4
I'm using a MSP430F5438A
I've been learning C for a little while and I've just started to learn assembler.
I have this question:Change the above code to turn on both LED 1 and LED 2 when both switches s1 and s2 are pressed (and turn both LEDs off otherwise)
Here is the code:
I know how to do this question in C, but in assembler I'm not so sure. If you look at this line:
sw_check: bit.b #0x40,&P2IN ; check if switch is pressed
To check if both sw1 and sw2 are pressed in C, I would just put if ((P2IN & BIT6+BIT7) == BIT6+BIT7). What is the equivalent way of writing that in assembler?
I've been learning C for a little while and I've just started to learn assembler.
I have this question:Change the above code to turn on both LED 1 and LED 2 when both switches s1 and s2 are pressed (and turn both LEDs off otherwise)
Here is the code:
Code:
; CONFIGURE PORTS FOR INPUT AND OUTPUT
bis.b #0x01,&P1DIR ; set P1.0 as output
bic.b #0x40,&P2DIR ; set P2.6 as input
bis.b #0x40,&P2REN ; enable pullup for P2.6
bis.b #0x40,&P2OUT ; enable pullup for P2.6
sw_check: bit.b #0x40,&P2IN ; check if switch is pressed
jnz led_off ; if so jump to led_off
; else
bis.b #0x01,&P1OUT ; turn on LED 1
jmp continue
led_off: bic.b #0x01,&P1OUT ; turn off LED 1
continue: jmp sw_check
nop
sw_check: bit.b #0x40,&P2IN ; check if switch is pressed
To check if both sw1 and sw2 are pressed in C, I would just put if ((P2IN & BIT6+BIT7) == BIT6+BIT7). What is the equivalent way of writing that in assembler?