UMBC CMSC 391 -- Programming Microcontrollers  


Immediate Addressing Mode

No programming class can legally be taught without the first example program being Hello, World, but it does have an example of immediate addressing mode.

2000: 90 20 0A    mov     dptr, #hello
What is being put into the data pointer. The address of the string hello is being put in. Notice that we are referring to the constant value (which is the address) and it is indicated as being immediate by the pound sign (#). Notice that immediate data can only be the source, not the destination.

We can have other things like:

2000:                   .org    0x2000
                   
                   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                   ;; Equates                                  ;;
                   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2000:                   .equ    d0h, 5
                   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                   ;; Code                                      ;;
                   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                   
                   begin:
                   
                   ;; Should generate the same code for each line.
2000: 75 F0 FF             mov  B, #0FFh
2003: 75 F0 FF             mov  0F0h, #0FFh
                   
                   ;; Notice the difference.
2006: 74 35                mov  A, #53        ;  Two bytes,
                                              ;    one cycle
2008: 75 E0 35             mov  0E0h, #53     ;  Three bytes,
                                              ;    two cycles
                   
                   
200B: E5 05                mov  A, D0h        ;  
200D: 74 D0                mov  A, #0D0h
200F: 22                   ret
                   
                   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                   ;; Data                                      ;;
                   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                   ;;d0h:    .db     2        ; This produced an
                                              ; error saying not
                                              ; an 8-bit value
  


©2004, Gary L. Burt