🇩🇪
Zitat von: vloki in 05.02.2024, 09:55:27 CETrlncf COMMAND, Wich war mir hier nicht sicher, ob man das W-Register mal zwei nehmen muss, das ist hiermit beantwortet.
Zitat von: ^Cobra in 03.02.2024, 13:06:02 CETDer Controller 16f877A wird scheinbar nicht kommplett beschrieben?! o.O Im Programmspeicher geht es bis Ende der Interrupt Routine ab dann steht nur noch ADDLW 0xFF. und nicht nur das: In der Codezeile 1 steht goto 0xXX (Adresse grade nicht zur Hand) und dieser Sprung führt genau zu so ein nix...
; This jump table must exist entirely within one 256 byte block of program memory.
#if ($ & 0xFF) > (0xFF - .24)
; Too close to the end of a 256 byte boundary, push address forward to get code
; into the next 256 byte block.
messg "Wasting some code space to ensure jump table is aligned."
ORG $+(0x100 - ($ & 0xFF))
#endif
JUMPTABLE_BEGIN:
movf PCL, w ; 0 do a read of PCL to set PCLATU:PCLATH to current program counter.
rlncf COMMAND, W ; 2 multiply COMMAND by 2 (each BRA instruction takes 2 bytes on PIC18)
addwf PCL, F ; 4 Jump in command jump table based on COMMAND from host
bra BootloaderInfo ; 6 00h
bra ReadFlash ; 8 01h
bra VerifyFlash ; 10 02h
bra EraseFlash ; 12 03h
bra WriteFlash ; 14 04h
bra ReadEeprom ; 16 05h
bra WriteEeprom ; 18 06h
bra WriteConfig ; 20 07h
bra GotoAppVector ; 22 08h
reset ; 24 09h
#if (JUMPTABLE_BEGIN & 0xFF) > ($ & 0xFF)
error "Jump table is not aligned to fit within a single 256 byte address range."
#endif
Zitat von: pic18 in 04.02.2024, 19:28:24 CET.....wird denn wenn INCF PLATH aufsgeführt wird noch CALL Table2 ausgeführt?Ja! Bei diesen Bit-Test-Sprung-Bedingungen wird nur im Falle des Zutreffens der Bedingung einmal die nächsten Anweisung übersprungen. Im Falle des Nicht-Zutreffens läuft das Prog wie üblich Zeile nach Zeile weiter.
ZitatThe Program Counter (PC) specifies the address of the
instruction to fetch for execution. The PC is 21 bits wide
and is contained in three separate 8-bit registers. The
low byte, known as the PCL register, is both readable
and writable. The high byte, or PCH register, contains
the PC<15:8> bits; it is not directly readable or writable.
Updates to the PCH register are performed through the
PCLATH register. The upper byte is called PCU. This
register contains the PC<20:16> bits; it is also not
directly readable or writable. Updates to the PCU
register are performed through the PCLATU register.
The contents of PCLATH and PCLATU are transferred
to the program counter by any operation that writes to
the PCL. Similarly, the upper two bytes of the program
counter are transferred to PCLATH and PCLATU by an
operation that reads PCL. This is useful for computed
offsets to the PC (see Section 5.1.4.1 "Computed
GOTO").
Zitatwird denn wenn INCF PLATH aufsgeführt wird noch CALL Table2 ausgeführt?BTFSC STATUS,C ;see if it overflows INCF PCLATH ;If so, increment PCLATH and CALL Table2 ;Jump to the data table
ZitatEs sollte also anstelle von "f" halt 'ne Null oder Eins stehen, je nach Ziel.f entspricht 1
Zitat von: ^Cobra in 04.02.2024, 16:16:15 CETIch dachte immer das bra im Grunde das gleiche wie GOTO ist nur halt über ein Macro anders geschrieben
Zitat von: picass in 04.02.2024, 17:30:10 CETzum einen hat der Programm-Counter zwei Bytes, ein "lowes" und ein "highesbeim 18er sogar 3 Bytes, deswegen aufpassen, das kein Überlauf entsteht
[pre];*** define amount of table items for startup message ***
#define tab_items d'39'
movlw tab_items ; store amount of table items in counter
movwf TEMP6
;*** transmit startup message ***
_ILOOP movlw HIGH WelcomeTable ; get correct page for PCLATH
movwf PCLATH ; prepare right page bits for table read
movfw TEMP6 ; get actual count-down value
sublw tab_items ; table offset: w = tab_items - TEMP3
call WelcomeTable ; call lookup table
movwf TEMP7 ; create backup of fetched item
SENDw ; RS232 output
movfw TEMP7
LCDw ; LCD output
decfsz TEMP6,F ; decrement counter
goto _ILOOP
[pre]WelcomeTable
addwf PCL,F ; add offset to table base pointer
DT "PIC 16F77 AT Keyboard Decoder connecte" ; create table
WTableEND DT "d"
IF (high (WelcomeTable) != high (WTableEND))
ERROR "WelcomeTable hits page boundary!"
ENDIF
END[/pre]
[/pre]