This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Assembly Code

I am trying to write 0xAA to Address location 0x5555.
The following code is working. May someone kindly explain in details how C167 controller interpret it? Why is #09555H used???

MOV	DPP2,#0001H
MOV	R12,#09555H
MOVB	RL1,#00AAH
MOV	[R12],RL1

Parents
  • It is usually not a good idea (or style) to modify the contents of the DPPx-Registers.
    The DPPx-Registers should be set to fixed values in the startup sequence (start.a66) and the compiler usually assumes that they are not changed.

    You are using "near" addressing mode together with DPP2. The shortest code would be:

    MOV DPP2,#1
    MOVB RL1,#0AAh
    MOV DPP2:1555h,RL1

    By using "DPP2:1555h" the assembler will calculate 9555h as near address, so you don't have to calc it yourself. There's no difference between "DPP2:1555h" and "DPP2:5555h"

    The first two bits of a near-address select the DPPx-Register, the last 14 bits contain the address offset.

    The first two bits of 9555h are "10", so DPP2 is selected. The contents of DPP2 is "1", and so data page #1 with start address 4000h is selected. The address offset (14 bit) is 1555h. By adding 4000h and 1555h you get the physical address 5555h.

    Instead of using DPP2, the "huge" addressing mode would be easier to use:

    MOVB RL1,#0AAh
    EXTS #0,#1
    MOV 05555h,RL1

    where #0 is the segment number (= high-word of the physical address), and #1 is the number of following instructions.
    (This code does not work for the C166 device, but it works well for all other devices such as C167, C164. Also beware when using EXT-instructions in a Class B trap handler: save and reset the TFR-Register first.)

Reply
  • It is usually not a good idea (or style) to modify the contents of the DPPx-Registers.
    The DPPx-Registers should be set to fixed values in the startup sequence (start.a66) and the compiler usually assumes that they are not changed.

    You are using "near" addressing mode together with DPP2. The shortest code would be:

    MOV DPP2,#1
    MOVB RL1,#0AAh
    MOV DPP2:1555h,RL1

    By using "DPP2:1555h" the assembler will calculate 9555h as near address, so you don't have to calc it yourself. There's no difference between "DPP2:1555h" and "DPP2:5555h"

    The first two bits of a near-address select the DPPx-Register, the last 14 bits contain the address offset.

    The first two bits of 9555h are "10", so DPP2 is selected. The contents of DPP2 is "1", and so data page #1 with start address 4000h is selected. The address offset (14 bit) is 1555h. By adding 4000h and 1555h you get the physical address 5555h.

    Instead of using DPP2, the "huge" addressing mode would be easier to use:

    MOVB RL1,#0AAh
    EXTS #0,#1
    MOV 05555h,RL1

    where #0 is the segment number (= high-word of the physical address), and #1 is the number of following instructions.
    (This code does not work for the C166 device, but it works well for all other devices such as C167, C164. Also beware when using EXT-instructions in a Class B trap handler: save and reset the TFR-Register first.)

Children
No data