Logo
Articles Compilers Libraries Books MiniBooklets Assembly C++ Linux Others Videos
Advertisement

Article by Ayman Alheraki on January 11 2026 10:37 AM

Drawing Graphics with CPU Only on Windows Using GAS Assembly (Intel Syntax)

Drawing Graphics with CPU Only on Windows Using GAS Assembly (Intel Syntax)

 

This example shows how to create a simple Windows application in pure x86 Intel syntax assembly, which:

  • Creates a window

  • Allocates a framebuffer in memory

  • Draws a red square pixel-by-pixel into the buffer

  • Displays it on the window using StretchDIBits (Windows GDI)

Prerequisites and Build Instructions

  • Use MinGW or TDM-GCC on Windows with as (GAS) and gcc tools.

  • Assemble with Intel syntax: add .intel_syntax noprefix directive.

  • Build commands:

Full Source Code (Intel syntax)

Notes:

  • .intel_syntax noprefix tells GAS to use Intel syntax (no % prefixes, normal Intel opcodes).

  • The code manually does pixel addressing and calls Windows API directly.

  • buffer is a linear 32-bit ARGB framebuffer.

  • Uses StretchDIBits to blit the buffer on the window.

  • The red square is 80x80 pixels drawn at (200,200).

How to Build

  1. Save as gfx.asm

  2. Open MinGW terminal or cmd with MinGW tools in PATH

  3. Run:

  1. Run gfx.exe

Summary

This example proves that pure assembly with CPU-only drawing is feasible on Windows by:

  • Allocating a framebuffer in memory

  • Implementing pixel-level drawing logic

  • Using Windows GDI calls from assembly

  • Building with GAS in Intel syntax

You can extend this by adding lines, circles, text rendering, or even animations, all coded in assembly.

Advertisements

Responsive Counter
General Counter
1001454
Daily Counter
654