You are on page 1of 2

//If there are 8 LEDs connected to the port B

//the lit LED will continuously move up and down
//(example for PIC target)

program TEST;

const var a: array[2..9] of char := ( 1, 2, 4, 8, 16, 32, 64, 128 );
var i, i16: 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;

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 );

while 1 do
begin
for i8 := 2 to 9 do
begin
OUTPUT_PORT_B( a[i8] );
delay;
nop;
end;

for i8 := 8 downto 3 do
begin
OUTPUT_PORT_B( a[i8] );
delay;
nop;
end;

for i16 := 2 to 9 do
begin
OUTPUT_PORT_B( a[i16] );
delay;
end;

for i16 := 8 downto 3 do

for i8 := 2 to 9 do begin OUTPUT_PORT_B( a[i8] ). for i16 := 8 downto 3 do begin OUTPUT_PORT_B( a[i16] ). end. for i8 := 8 downto 3 do begin OUTPUT_PORT_B( a[i8] ). delay. end. for i16 := 2 to 9 do begin OUTPUT_PORT_B( a[i16] ). end. for i16 := 259 to 266 do begin OUTPUT_PORT_B( a[i16-257] ). end. delay. delay. delay. delay. . end. end. delay. end. end. end. delay. delay. delay. for i16 := 265 downto 258 do begin OUTPUT_PORT_B( a[i16-257] ). begin OUTPUT_PORT_B( a[i16] ). end. for i16 := 259 to 266 do begin OUTPUT_PORT_B( a[i16-257] ). end. for i16 := 265 downto 258 do begin OUTPUT_PORT_B( a[i16-257] ).