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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:18:05+00:00 2026-05-23T10:18:05+00:00

We are attempting to port a legacy application from an old monolithic RTOS to

  • 0

We are attempting to port a legacy application from an old monolithic RTOS to a unix based RTOS on a PowerPC 8360. In the old system, our large code base became dependent upon 1/0 returning zero, and 0/0 returning zero. Now in the new operating system 1/0 returns inf and 0/0 returns NaN, which breaks our application. We’ve tried playing around with the FPSCR register with no results.

Secondly, if there is a way to change it, can the change take affect for our application process and not the entire system? We do not want to change the div/0 behavior of other applications within the system.

Anticipating the inevitable “why are you doing it that way” question, we have to preserve the previous behavior so changing the app to actually not divide by zero is out of the question. This is a sore spot with us so please refrain from asking. Thanks in advance!

  • 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-23T10:18:05+00:00Added an answer on May 23, 2026 at 10:18 am

    Note: it’s been a while since I worked on this kind of stuff. Hopefully my answer is in the ballpark.

    You’ll need to trap the div-0 exception that occurs when this happens — I believe MSR.FE0 and MSR.FE1 as well as FPSCR.VE and FPSCR.ZE will need to be manipulated in order to ensure the handling of this the way you want.

    So once you get that set up and working, you’ll need to:

    • take control of the exception handling for these scenarios (0/0 and 1/0). In most of the small real-time kernels I use, with all source code available, I would know what to do. Not sure what your RTOS is or how much control you have. Chances are, if it’s a “heavierweight” OS, it’s not going to let you fiddle with exception handler logic.
      I think 0/0 will trigger an “Invalid Operation” exception (FPSCR.VE), whereas 1/0 will trigger an IEEE floating-point zero divide exception (FPSCR.ZE).

      • if you get the Invalid Operation exception you need to determine if the cause was 0/0 or something else. With 0/0, FPSCR.VXZDZ will be set (I think). There are other ways to trigger this exception so here FPSCR is your friend.

      • if you get the IEEE FP div-0 exception you need to determine if the cause was 1/0 or something else (e.g. 2/0). I think for this you’ll have to examine the registers of the interrupted context to see if the numerator was 1 at the time of the division operation that caused the exception. The FPU doesn’t care if you attempted 1/0 or 2/0, but apparently your application does.

    • next, you need to alter the returning context so that you get the desired result. This might be something like changing the FP registers used in the operation so that when you return from exception & the FP division is re-tried, it yields zero. For example, make the numerator 0 and the divisor 1.

    Then when you return from the exception, you should get your desired result. Sorry I’m rusty on the specific registers and values, I hope this is enough to get the job done.

    You also asked about selectively enabling this behavior just for your application process. I’ve had to do things like this before, but more in flat-address space, “single process, multiple thread” type kernels (where each task is really a thread, all running in the same flat address space). I’ve done it a couple different ways, here are some ideas that might work for you:

    • In the exception handler, examine the process ID / task ID and if it’s your application process, handle it the special way, otherwise handle it the standard “system” way.

    • Alternatively, on a context switch into your application, install your “special” handling for this exception. On a context switch out of your application process, replace it with the standard handling. Note that the application itself won’t be able to do this, you’ll have to tap into the kernel to do it (there might be a context switch hook/callout that you can use, otherwise you’ll probably be modifying kernel source).

    I’ve inherited legacy code like this before & I feel your pain. You want to shake your fist at the people who installed such bone-headed behavior, but right now shaking your fist doesn’t help you ship product. You need a solution. Good luck.

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

Sidebar

Related Questions

I'm attempting to port an application that plays chiptunes (NSF, SPC, etc) music files
I have been attempting to compile/run a sample WCF application from Juval Lowy's website
I'm attempting to consume a dll written in C++ from a C# application. I
I'm attempting to port some content from TWiki to MediaWiki and whereas the former
I am attempting to port a small data analysis program from a 64 bit
I'm attempting to use one of the pins from the serial port to toggle
I am attempting to create a small application to collect data received from an
I'm attempting to read data from a serial port, show the data in some
I am attempting to port one of my hobby project to linux. Preferrably to
I'm attempting to port over an Internet Explorer plugin to Firefox, but I'm not

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.