1 / 10

Assembler Language

Assembler Language. Guidelines for writing assembly code suggested by Microchip Write instruction mnemonics in lower case (e.g. xorwf ) Write special register names, RAM variable names, and bit names in uppercase (STATUS, RP0). Assembler Language.

selah
Download Presentation

Assembler Language

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. Assembler Language • Guidelines for writing assembly code suggested by Microchip • Write instruction mnemonics in lower case (e.g. xorwf ) • Write special register names, RAM variable names, and bit names in uppercase (STATUS, RP0)

  2. Assembler Language • Write instruction and subroutine labels in the mixed case (e.g. Mainline, LoopTime) • A sample program to flash an LED is given next

  3. Program hierarchy MainLine call Initial ; Perform necessary initializations Mainloop call Task1 ; Take care of Task1 call Task2 ; Take care of Task2 . . call LoopTime ; Force loop time to a fixed value coto MainLoop ; Repeat

  4. SAMPLE PROGRAM • Figure 1 gives the schematic of the circuit. • Figure 2 gives some necessary power supply and output pin drive specifications • Figure 3 shows the program code.

  5. Macros • Set of Instructions which can be inserted into source code by assembler when the code is compiled. • E.g. bcf STATUS, RP0 • Can be expressed in macro definition as: bank1 macro bcf STATUS, RP0 endm

  6. Macros • Definition of a macro can be inserted into a source file at any place before it is invoked. • Multiple macro definitions can be defined into files (e.g. name.inc) and then included into the source code as an include file • A macro definition in an include file will only be included added to the object file if it is invoked in the program.

  7. Macros • A macro definition can include one or more arguments • E.g. Load a literal value into a register movlf macro literal, register movlw literal movlf register Endm Usage: movlf MaxCount, BLNKCNT

  8. Macros • Use of macro generally effects the content of W register • Local labels can be defined inside a macro • Do not precede a macro with one of the skip instructions • E.g. btfsc STATUS, C movlw 5, COUNT

  9. Macros Macro definition without using local labels (not suggested) countdown macro COUNTREGISTER, InitialCount movlw InitialCount movwf COUNTREGISTER Again decfsz COUNTREGISTER goto Again endm

  10. Macros Macro definition using local labels countdown macro COUNTREGISTER, InitialCount local Again movlw InitialCount movwf COUNTREGISTER Again decfsz COUNTREGISTER goto Again endm

More Related