I found a part of code, but it's written in "old" way. So plz convert it that it uses bcf bank0...
I tried, but what is OPTION in middle of nowhere, argh...
CODE:
Code:
;ORIGINAL
start clrf PORTA
clrf PORTB
movlw B'00010000'
tris PORTA ;<=PROBLEM
movlw B'00000000'
tris PORTB ;<=PROBLEM
movlw B'00000011'
option ;<=PROBLEM
movlw 0
movwf temp
clrf work
movlw B'10100000'
movwf INTCON
return
;********************************
;My conversion, probably wrong, because it's not working
;********************************
start clrf PORTA
clrf PORTB
[COLOR="Red"] bsf STATUS,RP0[/COLOR]
movlw B'00010000'
[COLOR="Red"] movwf TRISA[/COLOR]
movlw B'00000000
[COLOR="Red"] movwf TRISB[/COLOR]
movlw B'00000011'
[COLOR="Red"] movwf OPTION_REG [/COLOR]
;
[COLOR="Red"] bcf STATUS,RP0 [/COLOR]
movlw 0
movwf temp
clrf work
movlw B'10100000'
movwf INTCON
return
I found a part of code, but it's written in "old" way. So plz convert it that it uses bcf bank0...
I tried, but what is OPTION in middle of nowhere, argh...
CODE:
Code:
;ORIGINAL
start clrf PORTA
clrf PORTB
movlw B'00010000'
tris PORTA ;<=PROBLEM
movlw B'00000000'
tris PORTB ;<=PROBLEM
movlw B'00000011'
option ;<=PROBLEM
movlw 0
movwf temp
clrf work
movlw B'10100000'
movwf INTCON
return
;********************************
;My conversion, probably wrong, because it's not working
;********************************
start clrf PORTA
clrf PORTB
[COLOR="Red"] bsf STATUS,RP0[/COLOR]
movlw B'00010000'
[COLOR="Red"] movwf TRISA[/COLOR]
movlw B'00000000
[COLOR="Red"] movwf TRISB[/COLOR]
movlw B'00000011'
[COLOR="Red"] movwf OPTION_REG [/COLOR]
;
[COLOR="Red"] bcf STATUS,RP0 [/COLOR]
movlw 0
movwf temp
clrf work
movlw B'10100000'
movwf INTCON
return
As far as I'm aware using the TRIS command still works on modern devices?, although they keep threatening to drop it. So does the original code work?, and why are you wanting to change it?.
I scraped a part of code, there is no full listing. It's for PIC16f84a, under "old" way I was thinking on instructions like:
tris PORTB replaced with (for example) movwf TRISB
option replaced with OPTION_REG
at least I read somewhere that this way of writing should be avoided.
In other part I tried to write the same part of program, changes that I made are in red and probably wrong.
Yes it works, but I don't know what it means in that way, when are banks changed, ect.
hmm, ok, can somebody explain exactly what this part of code does:
Code:
movlw B'00000011'
option
, because there is no bank switching, but option is in bank1 (16f84), how can it be simply written without bank change, and why is it 'alone', without any other instruction, like movwf option, or something.
Because the 12 bit core chips didn't have banking, the tris and option registers were given special instructions to write to them. The 12 bit cores lacked other features as well like having a stack that was only 2 deep and no return instruction - you had to use retlw.
hmm, ok, can somebody explain exactly what this part of code does:
Code:
movlw B'00000011'
option
, because there is no bank switching, but option is in bank1 (16f84), how can it be simply written without bank change, and why is it 'alone', without any other instruction, like movwf option, or something.