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

  • SEARCH
  • Home
  • 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 6997687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:18:54+00:00 2026-05-27T20:18:54+00:00

I am writing a high-level MIPS assembler. I’m having trouble off the bat trying

  • 0

I am writing a high-level MIPS assembler. I’m having trouble off the bat trying to get fwrite to output correctly. An example assembly file looks like this:

.text
    addi    $t0,$0,7 
    addi    $t1,$0,1 
L1: 
    beq $t0,$0,DONE 
    mult    $t1,$t0 
    mflo    $t1  
    addi    $t0,$t0,-1 
    j   L1 
DONE:   
    add $a0,$0,$t1 
    addi    $v0,$0,1 
    syscall 
    addi    $v0,$0,10 
    syscall 

My code should convert these into 32-bit binary instructions and fwrite them to a file to be read by the faux-CPU.

I have a problem off the bat where the 32-bit delimiter at the beginning of the file should be 0xf0f0f0f0. I know you can’t “read” a binary file, but looking at the example file that I have, the delimiter is represented by /360/360/360/360 after being written by fwrite. Why is this and how would I replicate that behavior when I’m writing my own file (as in how do I use fwrite to achieve this to create other binary files)?

  • 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-27T20:18:54+00:00Added an answer on May 27, 2026 at 8:18 pm

    The fwrite(3) for your delimiter would look like this:

    unsigned int delim = 0xF0F0F0F0;
    
    fwrite(&delim, sizeof delim, 1, output);
    

    This writes one object of delim‘s size to the standard C stream output.

    You can use od(1) or xxd(1) to “read” binary files:

    $ od -bc /etc/passwd
    0000000 162 157 157 164 072 170 072 060 072 060 072 162 157 157 164 072
              r   o   o   t   :   x   :   0   :   0   :   r   o   o   t   :
    $ xxd /etc/passwd
    0000000: 726f 6f74 3a78 3a30 3a30 3a72 6f6f 743a  root:x:0:0:root:
    0000010: 2f72 6f6f 743a 2f62 696e 2f62 6173 680a  /root:/bin/bash.
    

    (The hexer(1) program (in the hexer package on Ubuntu) is a lot like an interactive xxd(1), you might find it useful some day.)

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

Sidebar

Related Questions

I'm writing a program that needs to print off high resolution .tiff images. The
Following up on this comment from the question Writing firmware: assembly or high level?
When writing object-oriented software, I use dependency injection a lot: to compose together high-level
I'm writing a code synthesizer which converts high-level models into CUDA C code. As
I am writing a high performance parser, and it seems to me that Int32.Parse
I'm writing a high-loaded daemon that should be run on the FreeBSD 8.0 and
When writing code do you consciously program defensively to ensure high program quality and
I'm writing a small online flash game that keeps high scores of players. Obviously
I am writing a small program for our local high school (pro bono). The
At fairly high level in the Linux write() function, it filters out requests for

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.