Maxim-integrated MAXQ622 Manual do Utilizador Página 245

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 255
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 244
MAXQ612/MAXQ622 Users Guide
Maxim Integrated 17-9
17.5 ROM Example 2: Calling A Utility ROM Function Indirectly
The second example shows the indirect addressing method (lookup table) for calling utility functions. We use the
same function (UROM_MoveDP1Inc) to read our static string, but this time we must figure out the address we want
dynamically. Note the inserted code where we before had a direct call to the function. Also note that the function index
of moveDP1inc is 7.
Text:
DB “Hello World!”,0 ; Define a string in code space.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Function: PrintText
;; Description: Prints the string stored at the “Text” label.
;; Returns: N/A
;; Destroys: ACC, DP[1], DP[0], and GR.
;; Notes: This function assumes that DP[0] is set to word mode,
;; DP[1] is in byte mode, and the device has 16-bit
;; accumulators.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintText:
move DP[1], #Text ; Point to the string to display.
move ACC, DP[1] ; “Text” is a word address and we need a
sla ; byte address, so shift left 1 bit.
or #08000h ; Code space is mapped to 8000h when running
move DP[1], ACC ; from the ROM, so the address must be masked.
PrintText_Loop:
;
; Fetch the byte from code space.
;
move DP[0], #0800Dh ; This is where the address of the table is stored.
move ACC, @DP[0] ; Get the location of the function table.
add #7 ; Add the index to the moveDP1inc function.
move DP[0], ACC ; Point to where the address of moveDP1 is stored.
move ACC, @DP[0] ; Retrieve the address of the function.
call ACC ; Execute the function.
move ACC, GR
jump Z, PrintText_Done ; Reached the null terminator.
call PrintChar ; Call a routine to output the char in ACC
jump PrintText_Loop ; Process the next byte.
PrintText_Done:
ret
Vista de página 244
1 2 ... 240 241 242 243 244 245 246 247 248 249 250 ... 254 255

Comentários a estes Manuais

Sem comentários