Forum: Mikrocontroller und Digitale Elektronik Tabelle implementieren Assembler MPLAB


von Lukas H. (cupra100)


Lesenswert?

Hallo!

Bitte um Hilfe!
Ich programmiere den PIC16f88 in MPLAB mit der Sprache Assembler.
Ich hab 2 sehr große tabellen. Jede Tabelle hat die Werte von 0-255.
Nun mein Problem ist dass der PCL überschritten wird und er beim call 
tab irgendwo hinspringt.
Ich muss also die Tabelle implementieren. Dafür gibts auch das 
Datenblatt AN556. Aber ich komme trotzdem nicht weiter.

z.B.:
                          addlw   0x01
        movwf  PCLATH
        movlw  d'7'
        call  tab_timerlow

tab_timerlow    addwf  PCL,f
                retlw  0x00
                .
                .
                .

??
funktioniert aber nicht!
Bitte um Hilfe. Eventuell den Programmteil kurz posten !
Danke schon im Voraus!

LG Lukas H.

von Flo (Gast)


Lesenswert?

So sollte es funktionieren.
1
    movlw   d'7'
2
    movwf   address
3
    call    tab_timerlow
4
5
6
tab_timerlow
7
    movlw   high tablestart
8
    movwf   PCLATH 
9
    movlw   low tablestart
10
    addwf   address, w 
11
    btfsc   STATUS, C
12
    incf    PCLATH, f
13
    movwf   PCL
14
tablestart
15
    retlw   0
16
    retlw   1
17
    retlw   2

Gruß Flo

von Lukas H. (cupra100)


Lesenswert?

Danke für die schnelle Antwort!
Eine Frage hätte ich noch zu dem Programm. Welcher Wert befindet sich im 
high tablestart und welcher im low tablestart ??

LG  Lukas H.

von John (Gast)


Lesenswert?

Hallo Lukas,
das ist die Adresse (high- und lowbyte) des Labels 'tablestart' und 
damit die Adresse vom ersten Wert der Tabelle, hier: 'retlw  0'.
Du brauchst dich nicht darum zu kümmern, das macht der Compiler.

Gruß
John

von Lukas H. (cupra100)


Lesenswert?

Vielen lieben Dank! :D
Programm funktioniert!

LG
Lukas H.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.