J.P. Armstrong
/
IntToBinaryAssembly
Assembly procedure that represents binary using the LEDs on the mbed.
Diff: binasm.s
- Revision:
- 0:13e4e935bed6
- Child:
- 2:a81c9bc37084
diff -r 000000000000 -r 13e4e935bed6 binasm.s --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/binasm.s Thu Jan 27 06:24:28 2011 +0000 @@ -0,0 +1,50 @@ + AREA |.text|, CODE, READONLY + EXPORT binasm + +binasm PROC + PUSH {R4, LR} + + MOV R1, #0 + MOV R2, #0 + MOV R3, #0 + + ; Load GPIO Port 1 base address in register R1 + LDR R1, =0x2009C020 ; 0x2009C020 = GPIO port 1 base address + LDR R4, =leds + + ;CLEAR LEDS + MOV.W R2, #0xB40000 + STR R2, [R1,#0x1C] + + ADD R3, R3, #12 ; COUNTER FOR LOOP + ADD R0, R0, #1 ; INCREMENT PARAMETER BY 1 + +loop + ; CLEAR THE CARRY FLAG + ADC R0, R0, #0 + + LDR.W R2, [R4, R3] + LSRS R0, R0, #1 + + STRCC R2, [R1,#0x1C] ; if==0, clear LED bit + STRCS R2, [R1,#0x18] ; if==1, set LED bit + + CMP R3, #0 + SUB R3, R3, #4 + BNE loop + + POP {R4, PC} + ENDP + + AREA |.data|, DATA, READWRITE + EXPORT leds + +;BIT MASK FOR LED1...LED4 + +leds DCD 0x040000 + DCD 0x100000 + DCD 0x200000 + DCD 0x800000 + + ALIGN + END \ No newline at end of file