RADIX Example

MPASM Assembler

RADIX Example

Directives highlighted in this example are:

  • list r=
  • radix
  • Program Functional Description

    This example shows the usage of the radix directive for data presentation. If not declared, then the default radix is in hex(adecimal).

    Commented Code Listing

    list p=16f877,r=dec ;Select the device and set

    ;radix as decimal.

    #include <p16f877.inc> ;Include standard header file

    ;for the selected device.

    movlw 50H ;50 is in hex

    movlw 0x50 ;Another way of declaring 50 hex

    movlw 50O ;50 is in octal

    movlw 50 ;50 is not declared as hex or

    ;octal or decimal. So by default

    ;it is in decimal as default radix

    ;is declared as decimal.

    radix oct ;Use `radix' to declare default

    ;radix as octal.

    movlw 50H ;50 is in hex.

    movlw 0x50 ;Another way of declaring 50 hex.

    movlw .50 ;50 is in decimal.

    movlw 50 ;50 is not declared as hex or

    ;octal or decimal. So by default

    ;it is in octal as default radix

    ;is declared as octal.

    radix hex ;Now default radix is in hex.

    movlw .50 ;50 is declared in decimal.

    movlw 50O ;50 is declared in octal

    movlw 50 ;50 is not declared as hex or

    ;octal or decimal. So by default

    ;it is in hex as default radix

    ;is declared as hex.

    end


    Microchip Technology Inc.
    Microchip's Web Site
    Voice: (480) 792-7200
    Fax: (480) 899-9210
    Microchip's E-mail Address
    PreviousNext