A simple HTTP webserver written entirely in x86-64 assembly language that responds with a JSON message.
This project implements a basic HTTP server in pure assembly language using Linux system calls. The server listens on port 8080 and responds to all requests with a JSON message: {"message":"Welcome to the Assembly Server!"}.
The server uses the following Linux system calls:
socket()- Creates a TCP socketbind()- Binds the socket to a local address and portlisten()- Puts the socket in listening modeaccept()- Accepts incoming connectionswrite()- Sends HTTP response to clientsclose()- Closes client connections
- Pure x86-64 assembly implementation
- HTTP/1.1 compliant responses
- JSON response body
- Proper Content-Length header
- Continuous operation (accepts multiple connections)
- Linux system with x86-64 architecture
- NASM (Netwide Assembler)
- GNU linker (ld) - Usually comes with GCC installation
- Podman or Docker (for containerized execution)
-
Install
NASM -
Assemble and link the server:
nasm -f elf64 server.asm -o server.o ld server.o -o server chmod +x server
-
Run the server (requires root to bind to port 8080):
sudo ./server
-
Build the container:
podman build -t asm-webserver . -
Compile the server in the container:
podman run -it --rm -v $(pwd):/workspace asm-webserver sh -c "nasm -f elf64 server.asm -o server.o && ld server.o -o server && chmod +x server"
-
Run the server:
podman run -d --name asm-server -v $(pwd):/workspace -w /workspace -p 8080:8080 asm-webserver sh -c "./server"
-
Make sure you have Docker or Podman with docker-compose installed
-
Run the server with a single command:
docker-compose up
Or with Podman:
podman-compose up
Note: If using Podman, you may need to install podman-docker compatibility layer.
Once the server is running, test it with curl:
curl http://localhost:8080Expected response:
{"message":"Welcome to the Assembly Server!"}
Or use a browser to navigate to http://localhost:8080