DA Example
Directives highlighted in this example are:
Program Functional Description
This example shows the usefulnes of directive
da
in storing a character string in the program memory of 14-bit architecture devices. This directive generates a packed 14-bit number representing two 7-bit ASCII characters.Commented Code Listing
list p=16f877 ;Select the device.
#include <p16f877.inc> ;Include standard header file
;for the selected device.
ORG 0000 ;The following code will be
;programmed in reset address 0.
goto start ;Jump to an address labelled
;'start'.
start ;Write your main program here to
;display the string given in
;'Ch_stng'.
goto $
ORG 1000 ;Store the string starting from
;1000H.
Ch_stng da "PICmicro"
Sngl_ch da "A" ;7-bit ASCII equivalents of 'A'
;and a NULL charater will be packed
;in a 14-bit number.
da 0xff55 ;Places 3f55 in program memory.
;No packing.
end
Additional Comments
Determining 14-Bit Numbers
For the following statement:
Ch_stng da "PICmicro"
directive
da
produces four 14-bit numbers: 2849, 21ED, 34E3 and 396F representing the ASCII equivalent of PI, Cm, ic and ro.To see how the 14-bit numbers are determined, let's look at the ASCII values of P and I, which are 50h(01010000) and 49h(01001001) respectively. Each is presented in 7-bit as (0)1010000 and (0)1001001 respectively. The packed 14-bit number is 101000 01001001, which is stored as (00)101000 01001001 or 2849.
Microchip Technology Inc. Microchip's Web Site Voice: (480) 792-7200 Fax: (480) 899-9210 Microchip's E-mail Address |