Hi Everyone,

I would like to get some help in a way to convert C code to DLX assembly code.I have tried to search if there are tools available which would perform this, but whatever I find is to convert to MIPS assembly code.

Guidance to move further in this direction would be of great help.

Thanks.

UncleLeroy commented: violation of the multiple-post policy +0

Dani AI

Generated

Quick summary / practical next steps (builds on ’s point that compilers can emit assembly):

Most compilers will produce assembly with an option such as -S, but you still need a compiler that targets the DLX ISA. For an existing workflow, try to find an academic “gcc‑dlx” / DLX toolchain first — some university courses ship a patched GCC plus a DLX assembler/simulator you can use directly (the usual pattern is gcc-dlx -S ... and a dlxsim/dlxasm to run/assemble). (cs.wellesley.edu)

If you can’t find a ready DLX cross‑compiler, two practical options work well in teaching/experimental settings:

  • Reuse an existing assembler/simulator (openDLX, dlxsim, or other DLX emulators) and feed them assembly output. Those tools can assemble .s / .S and exercise DLX code while you work on a toolchain. (softpedia.com)

  • Generate assembly from a nearby ISA (MIPS is very similar to DLX) then translate the text output to DLX syntax with a small script. Typical differences are register naming and operand order (e.g., MIPS: lw $1, 16($2) vs DLX: lw r1, 16(r2)), so a conservative translator that renames registers and adjusts a few mnemonics will get you most of the way. Watch out for ABI/library calls and differences in calling conventions — those need manual handling. (ece.lsu.edu)

If you need full, robust C support (stdlib, linkable objects) the long‑term route is writing/porting a backend (GCC or LLVM). That is feasible but nontrivial: add the target description, assembler output, register/calling‑convention rules, and toolchain glue. For step‑by‑step learning, the GCC internals and LLVM backend tutorials are the right references. (chiark.greenend.org.uk)

Practical commands to try:

# If you find/build a DLX gcc:
gcc-dlx -S -O3 -mtraps file.c -o file.s

# Or as a fallback, produce MIPS asm and translate:
mips-linux-gnu-gcc -S -O2 file.c -o file.s

Notes: the UMBC/course toolchains historically required specific patches and options (e.g. -mtraps, using an old GCC tree), so expect some build work or to use prebuilt binaries if available. For initial experimentation, use a DLX simulator/assembler to validate generated DLX text before investing in a full backend. (courses.cs.umbc.edu)

Recommended Answers

All 5 Replies

Assuming you have a C compiler for a DLX (whatever that is), this is trivial, since most C conpilers (all the ones I have ever seen) have an option to save the assembly language output to a file. This takes advantage of the way many compilers are written, ie. they convert the C code to assembly language, and then run the assembler.

Assuming you have a C compiler for a DLX (whatever that is), this is trivial, since most C conpilers (all the ones I have ever seen) have an option to save the assembly language output to a file. This takes advantage of the way many compilers are written, ie. they convert the C code to assembly language, and then run the assembler.

yes, thats true. I am in a situation where in I find C compiler which would compile in assembly language, but not as per the instruction set of DLX processor. I was looking for if somebody has an idea, about any C compiler which would compile in DLX instruction set.

You can get much faster (and better) results searching google "C compiler for DLX".

you mean, results like this one?

Posting the same question in multiple forums is a violation of web-site policy.
Please go back and read the rules.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.