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 562277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:32:14+00:00 2026-05-13T12:32:14+00:00

I currently try to write a program for the VFP unit of the iPhone

  • 0

I currently try to write a program for the VFP unit of the iPhone using ARM assembly code.
The VFP can do floatingpoint calculations, but AFAIK no integer arithmetic. However, it can convert a float to a signed integer (4 bytes). Also, according to this quickreference: http://www.voti.nl/hvu/arm/ARMquickref.pdf
it seems it does not support any shifting operations

what i would like to do is to convert 4 floats of which i’m sure that each is larger than -127 and smaller than 127 into 4 signed bytes.

if i’d have shifting operations available, i could convert the float to signed integer, then shift the value by 12 bytes to the left (8 and 4 bytes for the next two values respectively) and bitwise OR all four together.

however, since shifting is not available, i need to find another way to do it. Also – i cannot use integer arithmetics (so i can’t multiply the already converted integer by 2^n in order to shift but i have to work on the float instead).

Anyone knows how i could achieve that?

btw for those familar with the ARM architecture – i don’t want to switch to Thumb instructions, because this is done in a loop operating on many elements and i don’t want to switch between thumb and arm instructions inside this loop (since that’s expensive)

Thanks!

edit:

additional question: how can I normalize a Vector with three elements?

  • 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-13T12:32:15+00:00Added an answer on May 13, 2026 at 12:32 pm

    You want the VFP ftosis instruction, which converts a single-precision FP value to a 4 byte integer. If you have four floats in s0-s3, then after doing:

    ftosis s0, s0
    ftosis s1, s1
    ftosis s2, s2
    ftosis s3, s3
    

    you have four 4 byte integers in s0-s3, which can be stored contiguously to memory with a fstm.

    On an ARM processor that supports NEON, you can use vcvt.s32.f32 q0, q0 to do four conversions with one instruction.


    Edit to answer your follow-up question, here’s a simple example function which takes as input a pointer to four floats in memory and returns the converted values packed into a single int32_t:

    _floatToPackedInt:
        fldmias   r0,  {s4-s7}
        ftosizs   s0,   s4
        ftosizs   s1,   s5
        ftosizs   s2,   s6
        ftosizs   s3,   s7
        fmrrs r0, r1,  {s0,s1}
        fmrrs r2, r3,  {s2,s3}
        uxtb      r0,   r0
        uxtb      r1,   r1
        uxtb      r2,   r2
        orr       r0,   r0, r1, lsl #8
        orr       r0,   r0, r2, lsl #16
        orr       r0,   r0, r3, lsl #24
        bx        lr
    

    I didn’t really put any effort into tuning this, because you wouldn’t want to do conversions this way if they were performance-critical; you’d rather either operate on large arrays of values, and pipeline this code so that several conversions were in flight simultaneously, or interleave it with other operations that are doing useful work as well.

    You may also like to insert ssats before the uxtbs to make any out-of-range values saturate instead of wrapping.

    Also, be aware that this code will have poor performance on ARMv7 cores; you’ll definitely want to use the NEON vector operations on that platform.

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

Sidebar

Ask A Question

Stats

  • Questions 344k
  • Answers 344k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Got it working, sorry for wasting everyones time, the answer… May 14, 2026 at 5:44 am
  • Editorial Team
    Editorial Team added an answer Marcelo's answer is great. If for some reason you can't… May 14, 2026 at 5:44 am
  • Editorial Team
    Editorial Team added an answer You can try using the __in operator: qs = Category.objects.filter(editors__in=request.user.groups.all()) May 14, 2026 at 5:44 am

Related Questions

I have a foxpro database that we are trying to write to using MS
I'm currently working on a project where I need to track the usage of
We have a WPF application where parts of it may throw exceptions at runtime.
I'm having a problem designing part of my program (not writing it, for once!).
I'm using adjacency_list< vecS, vecS, bidirectionalS ... > extensively. I have so many graphs

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.