error in code assembler

Status
Not open for further replies.

mpardinho

New Member
i use this code but then i compile occurs some errors
help me with erros in lines please

i use picsimulator ide / assembler to test the code above.
ERRORS ARE IN RED


Code:
    DataPin equ 0x06                  ;PIC Pin
    ClockPin equ 0x07                 ;PIC Pin 
    Char equ 0x35                      ;buffer
    BitCounter equ 0x36              ;number of bits to read

GetScanCode
    bsf STATUS, RP0                   ;select bank 1 
    sf TRISB, DataPin                  ;set pins as input
    bsf TRISB, ClockPin
    bcf OPTION_REG, NOT_RBPU    ;pull-ups are enabled
    bcf STATUS, RP0                   ;select bank 0

    call ClockWait                       ;wait for Pull up to take effect and                          keyboard to pull clock low

;--- Read Data Bits ----

ReadKey
    clrf Char                           ;
    movlw .8                          ;bits to read  
    movwf BitCounter

ReadChar
    rrf Char                           [COLOR="Red"]Error: Invalid argument[/COLOR]
    bcf Char, 7                       ;default value is 0
    call ClockWait                    ;wait for clock to go high then low

    btfss PORTB, DataPin              ;read Data
    goto Next                         [COLOR="Red"]Invalid argument of the instruction[/COLOR]
    bsf Char, 7                       ;Data is High
    Next decfsz BitCounter            [COLOR="Red"]Unrecognized instruction[/COLOR]        
    goto ReadChar                     ;read next Data Bit


call ClockWait                    ;Parity Bit

call ClockWait                    ;Stop Bit

;Pull Clock Line Low (keyboard will buffer any further keystrokes)

    bsf STATUS, RP0                   ;select bank 1
    bcf TRISB, ClockPin               ;set clock line as output
    bcf STATUS, RP0                   ;select bank 0 
    bcf PORTB, ClockPin               ;set clock line low


    movf Char, W
return

;----wait for clock to go high----
ClockWait
    btfss PORTB, ClockPin
    goto ClockWait

;----wait for clock to go low----
ClockWait2
    btfsc PORTB, ClockPin
    goto ClockWait2
 
Last edited:
Try posting the code surrounded by the 'code' button (select advanced to enable it), this leaves the formatting intact to make it readable.
 
I think you just need to indent your code so it looks like this.

Code:
DataPin equ 0x06                  ;PIC Pin
ClockPin equ 0x07                 ;PIC Pin
Char equ 0x35                     ;buffer
BitCounter equ 0x36               ;number of bits to read

GetScanCode
	bsf STATUS, RP0                   ;select bank 1
	bsf TRISB, DataPin                ;set pins as input
	bsf TRISB, ClockPin
	bcf OPTION_REG, NOT_RBPU          ;pull-ups are enabled
	bcf STATUS, RP0                   ;select bank 0

	call ClockWait                    ;wait for Pull up to take effect and keyboard to pull clock low

HTH

Mike.
 
column 0 for 'labels' only, it needs spaces or tabs at the start of all non 'label' lines.
 
Try changing it to
Code:
ReadChar
    rrf Char,1                          ;Error: Invalid argument
    bcf Char, 7                       ;default value is 0
    call ClockWait                    ;wait for clock to go high then low

    btfss PORTB, DataPin              ;read Data
    goto Next                         ;Invalid argument of the instruction
    bsf Char, 7                       ;Data is High
Next decfsz BitCounter            ;Unrecognized instruction        
    goto ReadChar                     ;read next Data Bit

That should now assemble.

However, as Nigel says, the microchip assembler is better. Download **broken link removed** free from microchip.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…