Monthly Archives: September 2017

Building IA32 assembly project in Visual Studio 2017

If you saw my presentation at DevConf you may have gotten curious and want to play with assembly language yourself. Setting up Visual Studio for compiling and debugging Intel assembly is not hard, but not straightforward. Hence, this short tutorial. I’ll show you simple setup with C file as an entry point and small assembly “library”.

Project setup

1. Create new project – C++ Win32 Console Application


2. On a first screen click Next, as we want into pick some custom settings. On the second mark “Console Application” and “Empty Project”. For this simple example, we won’t need any default Windows headers. Click “Finish”.


3. Right-click on the project, “Add” -> “New Item…”. Pick C++ file, but rename it to .c, for example “source.c”.


4. Add another file in a similar way and also rename it – to “lib.asm”. What names you pick doesn’t really matter, as long as C and ASM file have different. Add also header file. Name it for example “header.h”. Your project should have a similar structure to this:


5. Right-click on the project, “Build Dependencies” -> “Build Customizations…”. Mark “masm” as selected. This adds Microsoft Macro Assembler into the build.


6. Right-click the assembly file (lib.asm), “Properties”. Item type most likely says “Does not participate in build”. Change it to Microsoft Macro Assembler.



Now let’s add simplest possible code to make it run. First assembly file. This code declares simple multiplication function that takes two arguments.


PUBLIC _multiply

_CODE SEGMENT dword public 'CODE' use32

_multiply PROC near

	push    ebp
	mov     ebp, esp   
	push	ebx
	mov	eax, [ebp+12]			;; second argument
	mov	ebx, [ebp+8]			;; first argument
	imul	eax, ebx			;; multiplying; lower 32 bits -> eax; 
						;; higher -> edx
	pop	ebx
	pop	ebp
_multiply ENDP



Then let’s add the header, so we can use this function:

#pragma once

int multiply(int a, int b);


And for the finish, the C file that will call our function:

#include "header.h"

int main(int argc, char *argv[]) {
	int a = 3;
	int b = 2;

	int mult = multiply(a, b);

	return 0;


Now you’ll be able to debug it like every other application in visual studio. You can set breakpoints and even Watches to see what’s in registers:


One problem, that I’ve noticed happening quite often, is that Visual Studio doesn’t notice changes made in the .asm file and do not recompile the project. I found that a good way to force it is to change target CPU for something different, build, change back to our preferred settings and rebuild again.


Intel® 64 and IA-32 Architectures Software Developer’s Manual

This x86 Assembly guide at University of Virginia CS


Good luck with your experiments and exploring your computer’s architecture!

Weekly Machine Learning drop #14

I’ve become more and more interested in machine learning during last year. This is my way of collecting and sharing interesting reads on the topic I stumble upon. I publish those posts every Friday. They are divided into few categories and the format is constantly evolving.


In this part, I share interesting news from machine learning and artificial intelligence world. Those are mostly not very scientific articles about applications, predictions and controversies around ML.

Inside Waymo’s Secret World for Training Self-Driving Cars
In this article, author visits Waymo’s facility for testing self-driving cars. He describes the operations there and how Waymo is using recorded real life situation, to rerun them in a virtual test environment. And this environment now evolved to simulate also previously “unseen” situation.

Microsoft unveils Project Brainwave for real-time AI
Microsoft presented new FPGA-based chip specifically designed for running high-performance machine learning computations. Together with it, they announced Project Brainwave, which (apart from the chip) consist of distributed system architecture and compiler and runtime for easy deployment of models.

How Big Data Mines Personal Information to Craft Fake News and Manipulate Voters
A darker side of Machine Learning revolution. With current computer powers and algorithms, it became very easy for evil actors to gather information about people, and create very tailored news that alters’s people opinions and decisions.

How does Physics connect to Machine Learning
Fascinating (and a bit math heavy) article on how concepts known from Physics find their translation into Machine Learning world.

Learning materials

This week I wanted to share with you some repositories with Tensorflow best practices and new Deep Learning course by Andrew Ng. 

Machine Learning for humans
It’s a series of articles targeted at technical professionals wanting to understand ML or non-technical people who are happy to engage with technical content.

Practical Deep Learning for Coders
This 7 weeks course by is fun, project based way to learn Deep Learning. It’s pretty heavy in content – authors suggest to secure 10hrs a week to be able to succeed with it.

This is it for today, thanks for reading. If you liked the post, let me know and please check other parts of the series.