Page 31 - DCAP210_INTRODUCTION__TO_MICROPROCESSORS
P. 31

Unit 2: Introduction to Assembly Language


            .ORIG, .FILL, .BLKW, .STRINGZ, and .END. All are easily recognizable by the dot as their first  Notes
            character.
            .ORIG

            .ORIG tells the assembler where in memory to place the LC-3b program. In line 05, .ORIG x3050
            says, start with location x3050. As a result, the LEA R2, NUMBER instruction will be put in
            location x3050.
            .FILL
            .FILL tells the assembler to set aside the next location in the program and initialize it with the
            value of the operand. In line 15, the ninth location in the resultant LC-3b program is initialized to
            the value x0006.

            .BLKW
            .BLKW tells the assembler to set aside some number of sequential memory locations (i.e. a Block
            of Words) in the program. The actual number is the operand of the .BLKW pseudo-op. In line 11,
            the pseudo-op instructs the assembler to set aside one location in memory (and also to label it
            NUMBER, incidentally).
            The pseudo-op .BLKW is particularly useful when the actual value of the operand is not yet
            known. For example, one might want to set aside a location in memory for storing a character
            input from a keyboard. It will not be until the program is run that we will know the identity of
            that keystroke.
            The argument is a sequence of n characters, inside double quotation marks. The first n 1 bytes of
            memory are initialized with the ASCII codes of the corresponding characters in the string, followed
            by x00. A final byte x00 is added if necessary to end the string on a word boundary. The n 1st
            character (x00) provides a convenient sentinel for processing the string of ASCII codes.

            For example, the code fragment
            .ORIG x3010
            HELLO .STRINGZ “Hello, World!”
            would result in the assembler initializing locations x3010 through x301D to the following values:
            x3010: x48
            x3011: x65
            x3012: x6C
            x3013: x6C
            x3014: x6F
            x3015: x2C
            x3016: x20
            x3017: x57
            x3018: x6F
            x3019: x72

            x301A: x6C
            x301B: x64
            x301C: x21
            x301D: x00





                                             LOVELY PROFESSIONAL UNIVERSITY                                    25
   26   27   28   29   30   31   32   33   34   35   36