what does this UC3B asm code means?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

80002000 :
80002000:	48 1f       	lddpc	pc,80002004 
80002002:	00 00       	add	r0,r0
80002004:	80 00       	ld.sh	r0,r0[0x0]
80002006:	23 68       	sub	r8,54

I can't understand this code.

What's the initial value in r0 after reset? (0 I guess)

what does this "add r0,r0" means? (just times r0 by 2?)

and what does this "ld.sh r0,r0[0x0]" means? (if r0 is 0, then does this means reading memeory 0x00000000 into r0?)

Cheng

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The key to understand this is the lddpc command right before the strange code.

The lddpc will load the constant at address 0x80002004 into the PC (a jump). If you then look at the address of the strange code you can see that it is stored at the address loaded by the lddpc (0x80002004). The "code" is the jump target loaded by the lddpc (0x80002368).

So the strange code you see is not code it is data interpreted as code. Pseudo disassembly:

80002000 : 
80002000:   48 1f          lddpc   pc,80002004
 
80002002:   00 00          "Word allignment of the jump target" 
80002004:   80 00          "Jump target MSB"
80002006:   23 68          "jump target LSB"
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wow, now i got it, thanks a lot!