4180 lab 1
Dependencies: mbed MCP23S17 PinDetect USBDevice
assembly_ec.s@12:cc5bda248946, 2020-01-22 (annotated)
- Committer:
- emilywilson
- Date:
- Wed Jan 22 13:08:48 2020 +0000
- Revision:
- 12:cc5bda248946
- Parent:
- 7:b7720a8623b5
mouse extra credit and power management extra credit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| emilywilson | 7:b7720a8623b5 | 1 | // AREA asm_func, CODE, READONLY |
| emilywilson | 7:b7720a8623b5 | 2 | //; Export my_asm function location so that C compiler can find it and link |
| emilywilson | 7:b7720a8623b5 | 3 | // EXPORT assembly_ec |
| emilywilson | 7:b7720a8623b5 | 4 | //assembly_ec |
| emilywilson | 7:b7720a8623b5 | 5 | //; |
| emilywilson | 7:b7720a8623b5 | 6 | //; ARM Assembly language function to set LED1 bit to a value passed from C |
| emilywilson | 7:b7720a8623b5 | 7 | //; Pushbutton is on GPIO port 2.4 (connected to p22) |
| emilywilson | 7:b7720a8623b5 | 8 | //; Led is on GPIO port 2.0 (connected to p26) |
| emilywilson | 7:b7720a8623b5 | 9 | //; See Chapter 9 in the LPC1768 User Manual |
| emilywilson | 7:b7720a8623b5 | 10 | //; for all of the GPIO register info and addresses |
| emilywilson | 7:b7720a8623b5 | 11 | //; Pinnames.h has the mbed modules pin port and bit connections |
| emilywilson | 7:b7720a8623b5 | 12 | //; |
| emilywilson | 7:b7720a8623b5 | 13 | // |
| emilywilson | 7:b7720a8623b5 | 14 | //; Load GPIO Port 2 base address in register R1 |
| emilywilson | 7:b7720a8623b5 | 15 | // LDR R1, =0x2009C040 ; 0x2009C040 = GPIO port 2 base address |
| emilywilson | 7:b7720a8623b5 | 16 | //; Load value from pushbutton into register R0 |
| emilywilson | 7:b7720a8623b5 | 17 | // LDR R0, R1 |
| emilywilson | 7:b7720a8623b5 | 18 | //; Move bit mask in register R2 for bit 4 only |
| emilywilson | 7:b7720a8623b5 | 19 | // MOV.W R2, #0x000010 ; 0x000010 = 1<<4 all "0"s with a "1" in bit 4 |
| emilywilson | 7:b7720a8623b5 | 20 | //; See if pushbutton is pressed |
| emilywilson | 7:b7720a8623b5 | 21 | // CMP R0, #0 |
| emilywilson | 7:b7720a8623b5 | 22 | //; (If-Then-Else) on next two instructions using equal cond from the zero flag |
| emilywilson | 7:b7720a8623b5 | 23 | // ITE EQ |
| emilywilson | 7:b7720a8623b5 | 24 | //; STORE if EQ - clear led 1 port bit using GPIO FIOCLR register and mask |
| emilywilson | 7:b7720a8623b5 | 25 | // STREQ R2, [R1,#0x58] ; if==0, set LED1 bit |
| emilywilson | 7:b7720a8623b5 | 26 | //; STORE if NE - set led 1 port bit using GPIO FIOSET register and mask |
| emilywilson | 7:b7720a8623b5 | 27 | // STRNE R2, [R1,#0x5C] ; if==1, clear LED1 bit |
| emilywilson | 7:b7720a8623b5 | 28 | //; Return to C using link register (Branch indirect using LR - a return) |
| emilywilson | 7:b7720a8623b5 | 29 | // BX LR |
| emilywilson | 7:b7720a8623b5 | 30 | // END |