Bit (asm)


Simple example which toggle bit on port P1.3. Program written in assembler.

Toolkit:SDCC 8051 Development System

Location:/bipom/devtools/SDCC/examples/bit/asm/

Code Example


.area HOME    (CODE)
.area CSEG    (CODE)

; Loop forever to generate a square wave on Port P1.3
Loop:

	; Reset Port P1.3
	clr		_P1_3
	lcall	Delay
	
	; Set Port P1.3
	setb	_P1_3
	lcall	Delay
	
	; Loop forever
	sjmp	Loop


; Implement a small delay
Delay:
	
	; Load the counter with 100
	mov		r2,#100			;

DelayLoop:
	
	; Do nothing, NOP operations eat some time
	nop
	nop						
	
	; If --r2 > 0, keep delaying
	djnz	r2,DelayLoop
	
	; Return from delay function