//If there are 8 LEDs connected to the port B //the lit LED will continuously move up and down //(example for PIC target) program SWAP; var a16, b16: integer; var i8: char; procedure delay; var i, j: char; begin i := 0; while i < 150 do begin i := i + 1; j := 0; while j < 200 do begin j := j + 1; nop; end; end; end; procedure swap( var a, b: integer ); var tmp: integer; begin tmp := a; a := b; b := tmp; end; begin //Initialization disable_interrupt( 'GIE' ); set_bit( STATUS, 'RP0' ); set_tris_a( 0 ); set_tris_b( 0 ); clear_bit( STATUS, 'RP0' ); output_port_a( 0 ); output_port_b( 0 ); i8 := 0; while 1 do begin a16 := i8; b16 := 255 + i8; swap( a16, b16 ); if ((b16 <> i8) or (a16 <> 255+i8)) then begin output_port_b( 255 ); delay; output_port_b( 0 ); end; i8 := i8 + 1; if i8 mod 2 then output_high_port_b( 7 ); else output_low_port_b( 7 ); delay; end; end.