# Writing and building code

> Getting to know the simulation workspace; files, the code editor, the build backend and clock frequency, build output, error messages and diagnostics; the Build & Analysis module for shippable output.

Source: https://embedarium.com/guide/code-and-build · Last updated: 2026-11-14


When you open a project, the **workspace** opens full screen. You write code, build it, run the program on the simulated processor and see the circuit, all in the same place.

## Parts of the workspace {#workspace}

![The workspace with numbered parts](https://embedarium.com/assets/images/guide/en/cb-ide-overview.webp "Parts of the workspace; the numbers follow the list below.")

1. **Views:** **Code** (the editor), **Simulation** (code and the live circuit side by side) and **Circuit** (the schematic editor). Switching views doesn't stop a running simulation.
2. **Commands:** **Save**, **Submit to assignment**, **Build**, **Debug** and **Run**, on the second row of the bar next to the views. While debugging, the step buttons appear here too (see [Debugging](https://embedarium.com/guide/debugging)).
3. **Project:** the project's name, its target processor and revision, and next to them whether your changes are saved. The arrow on the left goes back to your projects.
4. **Project explorer:** the project's files. Switch to another of your projects from the **Active project** list, or find a file with **Search files**. The files under **Processor pack** (such as `device.h` and `device.inc`) belong to the pack and are read-only. The **Code Notes** panel lists the `TODO:`, `FIXME:` and `HACK:` comments in your code; select one to jump to that line.
5. **Code editor:** an editor with syntax highlighting, line numbers and error markers. You can open several files in tabs.
6. **Output panel:** **Build** (the build log), **Diagnostics** (errors and warnings), **Trace** (instructions executed while debugging), **Build Outputs** (the files produced) and **Assistant** (the AI helper — coming later, see [The AI assistant](https://embedarium.com/guide/debugging#assistant)).
7. **View buttons:** font size (**A−** / **A+**), editor appearance (font and colors), showing and hiding panels (file explorer, output panel, revision history, code notes) and the editor theme.
8. **Status bar:** target processor and language; the **Build backend** list (which compiler builds the code) and the clock list (the simulated processor's frequency, for example 12 MHz — timing is calculated from it); the length of one machine cycle; while running, the total cycle count and elapsed time; the project's revision.

## Working with files {#files}

- **New file:** the **+ New** button at the top of the explorer.
- **Renaming and deleting:** the **⋮** menu at the end of the file's row has **Rename** and **Delete**, and **Make entry file** for a file the build can start from. The entry file itself can't be deleted.
- The **ENTRY** badge marks the main file the build starts from (for example `main.asm` or `main.c`).
- The project's circuit is stored in `.embedarium/schematic.json`; you don't need to edit it by hand — change the circuit in the **Circuit** view.

To **save**, select **Save** or press [[Ctrl+S]] ([[⌘+S]] on a Mac). **Saved** in the header shows your changes were written to the server. Every save is a revision; you can go back to earlier versions from the [revision history](https://embedarium.com/guide/simulation-projects#revision-history).

## How do I build my code? {#build}

Select **Build** or press [[Ctrl+B]] ([[⌘+B]] on a Mac). Progress and the result appear on the **Build** tab of the output panel; a successful build shows the size of the program produced (in bytes).

![A successful build and the build log](https://embedarium.com/assets/images/guide/en/cb-build-output.webp "A successful build: the compiler, revision and program size at the top, the steps below.")

**Run** ([[F5]]) builds first if needed, then runs the program; you don't have to build separately.

### Choosing the build backend {#backend}

Choose the compiler from the **Build backend** list in the status bar at the bottom of the workspace:

| Backend | When |
| --- | --- |
| Built-in ASM | Assembly on the 8051 family. No dependencies and fast; runs in the browser. |
| SDCC · C/ASM | C (and assembly) on the 8051 family. SDCC 4.6 runs in the browser; the toolchain is downloaded once on the first build (about 4.8 MB). |
| Server SDCC · C/ASM | The same compiler for the 8051 family, on the server. Nothing is downloaded into the browser. |
| Server gcc · C | ATmega328P, ATmega2560 and ATtiny85 (avr-gcc) and Cortex-M0+ (arm-none-eabi-gcc). The build runs on the server in an isolated environment. |
| Server SDCC (PIC) · C/ASM | PIC16F877A (SDCC pic14 and gputils), on the server. |

Only the backends that match your project's target processor are listed.

## Reading build errors {#errors}

If the build fails, the **Diagnostics** tab opens and lists each error with the file name, line number and description. The faulty line is underlined with a red squiggle in the editor. Select a diagnostic to jump to that line.

![A build error on the Diagnostics tab](https://embedarium.com/assets/images/guide/en/cb-build-error.webp "Diagnostics: the ERROR badge, file and line (main.asm:5) and the description. The faulty line is underlined in the editor.")

> [!tip]
> An AI helper that explains build errors on the **Assistant** tab is planned for later (see [The AI assistant](https://embedarium.com/guide/debugging#assistant)).

**Download diagnostics report** downloads a file with the environment, the project lock, the toolchain and the latest build diagnostics; it doesn't include your source code. Attach it when you ask the support team for help.

Sometimes the error comes from the server rather than your code; then the panel says "The build server failed — this is not about your code." and shows a **Retry with the same sources** button.

## Build outputs {#build-outputs}

The **Build Outputs** tab lists the files the build produced — for example the program's HEX file, the listing and the memory map. You can preview, copy or download each file.

## Building for release: Build & Analysis {#build-and-analysis}

A build in the simulator answers "does my code run on the processor?". The **Build & Analysis** module answers "can this code be shipped to real hardware?": it builds the code on the server, runs static analysis and MISRA C:2012 checks, and produces downloadable outputs. The module is licensed separately; if your license includes it, **Build & Analysis** appears in the sidebar.

1. Open **Build & Analysis** in the sidebar and select **New build**.
2. Choose the source: a **Simulation project** (and its revision) or a **ZIP package**. The target device and toolchain come from the project.
3. Select **Start build**. The job appears in the list; when it finishes it is **Succeeded** or **Failed**.

![Build & Analysis: the job list and a job's details](https://embedarium.com/assets/images/guide/en/cb-build-analysis.webp "A build job: the source, duration, the analyses that ran and the files produced.")

In the job's details:

- **Outputs:** HEX and BIN files, the listing, the memory map, the build log and other files depending on the target. Outputs are kept for **30 days**; if you **mark an output as a release**, it is kept permanently.
- **Compiler diagnostics** and **Analysis findings:** each finding is linked to a line; select it to open the project at that line of that file. "No findings" only means clean if that analysis ran; the job's details say which analyses ran (for example *MISRA C:2012 (10 rules) · Static analysis (7 rules)*).
- **Rebuild the same source** and **Open the project in the workspace**.

You can also start a release build from the **Simulation projects** page: **Build for release (Build & Analysis)** in the row's ⋮ menu opens the new build dialog with that project selected.

## Keyboard shortcuts {#shortcuts}

| Keys | Action |
| --- | --- |
| [[Ctrl+S]] / [[⌘+S]] | Save |
| [[Ctrl+B]] / [[⌘+B]] | Build sources |
| [[F5]] | Run / continue debugging (builds first if needed) |
| [[Shift+F5]] | End debugging |
| [[F9]] | Toggle the breakpoint on the cursor line |
| [[F10]] | Step over |
| [[F11]] | Step into |

In the workspace, [[F5]] doesn't reload the page; it runs the program.
