Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help me translate subroutine from Assembly to Picbasic Pro

Status
Not open for further replies.

jojokatada

Full Member level 5
Joined
Jan 13, 2005
Messages
255
Helped
19
Reputation
38
Reaction score
4
Trophy points
1,298
Activity points
2,122
if portb high picbasic pro

hi could anyone help me to translate the subroutine in assembly to picbasic pro
i want to use pic16f877a and checking each bit of portb if it is high then porta corresponding bit set to high

here is the assembly subroutine

checking portb

btfsc portb, 0
bsf porta, 0
btfsc portb, 1
bsf porta, 1
btfsc portb, 2
bsf porta, 2
btfsc portb, 3
bsf porta, 3

return

appreciate for anyone could help
 

maneco

Member level 3
Joined
May 22, 2004
Messages
65
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
610
translate from assembly to picbasic

easy...
LOOP:
TRISA=$ff 'port a is input
TRISB=0 'portb is output
PORTB=PORTA
GOTO LOOP

Added after 27 seconds:

easy...

TRISA=$ff 'port a is input
TRISB=0 'portb is output
LOOP:
PORTB=PORTA
GOTO LOOP
 

jojokatada

Full Member level 5
Joined
Jan 13, 2005
Messages
255
Helped
19
Reputation
38
Reaction score
4
Trophy points
1,298
Activity points
2,122
Re: subroutine for picbasic

appreciate but that not a subroutine for picbasic pro and i want to check each individual pin not the whole port
 

yo5oqa

Junior Member level 2
Joined
Oct 21, 2004
Messages
20
Helped
8
Reputation
12
Reaction score
4
Trophy points
1,283
Location
Romania
Activity points
188
Re: subroutine for picbasic

trisb=$FF
trisa=0

checking portb:
if portb.0=1 then porta.0=1
if portb.1=1 then porta.1=1 ; etc.
return

but it has no sense; if portb.0 returns to '0', porta.0 still remains on '1'.
 

jojokatada

Full Member level 5
Joined
Jan 13, 2005
Messages
255
Helped
19
Reputation
38
Reaction score
4
Trophy points
1,298
Activity points
2,122
Re: subroutine for picbasic

yo5oqa said:
trisb=$FF
trisa=0

checking portb:
if portb.0=1 then porta.0=1
if portb.1=1 then porta.1=1 ; etc.
return

but it has no sense; if portb.0 returns to '0', porta.0 still remains on '1'.


where do i put the endif ?
is it ok every end of if

if portb.0 =1 then porta.0 =1
endif
 

yo5oqa

Junior Member level 2
Joined
Oct 21, 2004
Messages
20
Helped
8
Reputation
12
Reaction score
4
Trophy points
1,283
Location
Romania
Activity points
188
Re: subroutine for picbasic

If there is a single instruction after 'then', on the same line, you don't need 'endif';
... if you have more than one it is like this:
if portb.0=1 then
porta.0=1
portc.0=1
endif
if ... then
...
...
endif ; etc
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top