Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6250183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:22:33+00:00 2026-05-24T13:22:33+00:00

As an intro to learning Arm assembly, I’m trying to recreate disassembled functions in

  • 0

As an intro to learning Arm assembly, I’m trying to recreate disassembled functions in a higher level language. However I’m confused by the following bit of assembly:

0000315e        2101    movs    r1, #1
00003160    e8dff000    tbb [pc, r0]
00003164        030e    lsls    r6, r1, #12
00003166        0907    lsrs    r7, r0, #4
00003168        050b    lsls    r3, r1, #20
0000316a        2106    movs    r1, #6
0000316c        e008    b.n 0x3180
0000316e        2102    movs    r1, #2
00003170        e006    b.n 0x3180
00003172        2103    movs    r1, #3
00003174        e004    b.n 0x3180
00003176        2104    movs    r1, #4
00003178        e002    b.n 0x3180
0000317a        2105    movs    r1, #5
0000317c        e000    b.n 0x3180
0000317e        2100    movs    r1, #0
00003180        4608    mov r0, r1
00003182        4770    bx  lr

I believe it may be some kind of switch statement but I’m unsure to what exactly it’s doing

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:22:35+00:00Added an answer on May 24, 2026 at 1:22 pm

    Yes, that is a switch. tbb stands for Table Branch Byte, it takes a table of byte-offsets, with base at pc, and index at r0, and uses that to do a branch.

    So:

    0000315e        2101    movs    r1, #1           ; ret = default value
    00003160    e8dff000    tbb [pc, r0]             ; switch (r0)
    
    ; jump table, byte-sized offsets
    00003164        03 0e 09 07 05 0b
    
    ; case 1: (0x3164 + 0x3 * 2)
    0000316a        2106    movs    r1, #6           ; ret = 6
    0000316c        e008    b.n 0x3180               ; break
    
    ; case 5: (0x3164 + 0x5 * 2)
    0000316e        2102    movs    r1, #2           ; ret = 2
    00003170        e006    b.n 0x3180               ; break
    
    ; case 2: (0x3164 + 0x7 * 2)
    00003172        2103    movs    r1, #3
    00003174        e004    b.n 0x3180
    
    ; case 3: (0x3164 + 0x9 * 2)
    00003176        2104    movs    r1, #4
    00003178        e002    b.n 0x3180
    
    ; case 4: (0x3164 + 0xb * 2)
    0000317a        2105    movs    r1, #5
    0000317c        e000    b.n 0x3180
    
    ; default:
    0000317e        2100    movs    r1, #0
    
    ; case 0: (0x3164 + 0xe * 2)
    : end switch
    00003180        4608    mov r0, r1        ; mov ret to r0 (return value)
    00003182        4770    bx  lr            ; return
    

    The basic idea should be clear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just learning ASP.NET c# and trying to incorporate best practices into my
I am a DSP, embedded software programmer, looking to improve my assembly language programming
I'm learning to use Netbeans and for my intro pet projects, I don't want
Say I'm learning about the UIGestureRecognizer class. In the intro text it mentions UITapGestureRecognizer
I am trying to improve my embedded C/C++ development on ARM architecture. I have
When learning (or relearning) a language, a significant amount of time goes into learning
Are there any 100% Microsoft developers out there who have ventured out into learning
Is there an online Java book like Dive into Python for learning Python? Other
I know this is fairly subjective, but I'm diving into testing and learning about
I'm learning ObjectiveC and ran into a problem relating to introspection. Basically, I'm looping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.