1 / 11

Look-up tables

Look-up tables. Macros. A macro is a grouping of instructions, defined by the programmer and given a name. When the source code is assembled, the macro is expanded out into the original instructions that made it up. The macro itself is contained within the directives macro and endm . Eg:

loe
Télécharger la présentation

Look-up tables

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Look-up tables

  2. Macros • A macro is a grouping of instructions, defined by the programmer and given a name. • When the source code is assembled, the macro is expanded out into the original instructions that made it up. • The macro itself is contained within the directives macro and endm. • Eg: • Bank1 macro • Bsf STATUS,RP0 • endm

  3. Puzzle • Give output of the following instructions • Bcf STATUS,RP0 ;Select bank0 • Movlw 33h • Movwf TRISA • Output???

  4. Output • PORTA = 33h

  5. Bank Seletion • Ensure you have chosen correct bank in data memory • In the above program, if you want to input some value in trisa, you should select bank 1 (bsf status,5).

  6. Context saving (Intservice ISR) • ;ISR • ;PUSH OPERATION • movwf w_temp ;Copy W to W_TEMP register, • swapf status,0 ;Swap status to be saved into W • movwf status_temp ;Save status to STATUS_TEMP register • ;Interrupt Service Routine • ... • actual ISR goes here • ... • ;POP OPERATION • swapf status_temp,0 ;Swap nibbles in STATUS_TEMP register • ;and place result into W • movwf status ;Move W into STATUS register ;sets • ;bank to original state • swapf w_temp,1 ;Swap nibbles in W_TEMP and keep result in • ;W_TEMP • swapf w_temp,0 ;Swap nibbles in W_TEMP and place result into W • ... • clear interrupt flag(s) here • ... • retfie

  7. Cblock assembler directive • Blnkcnt equ 20h • Num1 equ 21h • Num2 equ 22h • Counth equ 23h • Countl equ 24h • Cblock 20h • Blnkcnt • Num1 • Num2 • Counth • Countl • Endc =

  8. Assembler directives • While the Assembler program is written for the target microcontroller, it has to be processed by the Assembler first. • To aid this process and make it more powerful and flexible, a way is needed of passing information and instructions to the Assembler, which it recognizes as being for its attention only. • These instructions are called Assembler directives.

  9. Number representation

More Related