AnsweredAssumed Answered

time base asm

Question asked by Logan Zhang on Oct 21, 2015
Latest reply on Oct 22, 2015 by Martin Kovar

I got a example project from the support. There are some code which I don't  know the function of the code in the project. The code is below.

 

# tbs_main_asm.s - Time Base example

# Rev 1 Aug 27 2004 S Mihalik

# Copyright Freescale Semiconductor, Inc 2004 All rights reserved.

 

 

 

.globl tbs_main_asm

 

 

.text

tbs_main_asm: 

                      # INITIALIZE TIME BASE=0

  e_li      r4, 0       # Load immediate data of 0 to r4

  mttbu   r4    # Move r4 to TBU

  mttbl   r4          # Move r4 to TBL

  # ENABLE TIME BASE

  mfhid0  r5    # Move from spr HID0 to r5 (copies HID0)

  e_li      r4, 0x4000  # Load immed. data of 0x4000 to r4

  or      r5, r4, r5  # OR r4 (0x0000 4000) with r4 (HID0 value)

  mthid0  r5          # Move result to HID0

                      # EXECUTE SOME CODE

  e_nop

  e_nop

  e_nop

  e_nop

                      # RECORD TBL

  mftbl   r5          # Move TBL to r5 to store TBL value

 

  e_li r4, 0

  e_li r5, 0

  mtmsr r4

  mfmsr r4

  wrteei 1

  mfmsr r5

 

  se_blr                 # (Set a breakpoint here and read r5)

Outcomes