Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save xarical/658101a5c0a5511b9826966b242f0403 to your computer and use it in GitHub Desktop.

Select an option

Save xarical/658101a5c0a5511b9826966b242f0403 to your computer and use it in GitHub Desktop.
masm32-google-colab-easy-masm-quickstart.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyNTqizLcAKM2uU547/pdc39",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/xarical/658101a5c0a5511b9826966b242f0403/masm32-google-colab-easy-masm-quickstart.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"Installation\n"
],
"metadata": {
"id": "K3FK0hgGSj89"
}
},
{
"cell_type": "code",
"source": [
"# Install wine (takes about 1 minute to run)\n",
"!dpkg --add-architecture i386 &&\\\n",
" apt-get update >/dev/null 2>&1 &&\\\n",
" apt-get install wine32 >/dev/null 2>&1\n",
"!wine --version # verify wine installation"
],
"metadata": {
"id": "jUqa9GVp56a4",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "fb30614c-627e-4a88-e2c6-02eebe700529"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"wine-6.0.3 (Ubuntu 6.0.3~repack-1)\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Install Easy-MASM\n",
"!git clone https://github.com/jere-mie/easy-masm 2>/dev/null\n",
"\n",
"# Change cwd to /content/easy-masm\n",
"%cd easy-masm"
],
"metadata": {
"id": "ki7n7xFPD-yp",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "85456904-1516-4ca9-f521-d6b21e9110bc"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/easy-masm\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Test Easy-MASM on source.asm\n",
"!./run.sh source 2>/dev/null"
],
"metadata": {
"id": "_3Ed82HBEM5w",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "2ac47b92-e4eb-4e46-9ad6-14d045a80f97"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u001b[?25l Assembling:\u001b[K\u001b[1C\u001b[?25h\u001b[?25lsource.asm\u001b[?25h\r\n",
"\u001b[?25lMicrosoft (R)\u001b[K\u001b[1C\u001b[?25h\u001b[?25lIncremental Linker\u001b[?25h\u001b[?25l Version 12.00.21005.1\r\n",
"Copyright (C) Microsoft Corporation. All rights reserved.\r\n",
"\n",
"\u001b[?25h\n",
"\u001b[?25l EAX=\u001b[?25h\u001b[?25l3FFFE000\u001b[?25h\u001b[?25l EBX=\u001b[?25h\u001b[?25l3FFFE000\u001b[?25h\u001b[?25l ECX=\u001b[?25h\u001b[?25l00000000\u001b[?25h\u001b[?25l EDX=\u001b[?25h\u001b[?25l004010A0\u001b[?25h\n",
"\u001b[?25l ESI=\u001b[?25h\u001b[?25l00000000\u001b[?25h\u001b[?25l EDI=\u001b[?25h\u001b[?25l00000000\u001b[?25h\u001b[?25l EBP=\u001b[?25h\u001b[?25l0031FF48\u001b[?25h\u001b[?25l ESP=\u001b[?25h\u001b[?25l0031FF34\u001b[?25h\n",
"\u001b[?25l EIP=\u001b[?25h\u001b[?25l004010A5\u001b[?25h\u001b[?25l EFL=\u001b[?25h\u001b[?25l00000246\u001b[?25h\u001b[?25l CF=0\u001b[?25h\u001b[?25l SF=0\u001b[?25h\u001b[?25l ZF=1\u001b[?25h\u001b[?25l OF=0\u001b[?25h\u001b[?25l AF=0\u001b[?25h\u001b[?25l PF=1\u001b[?25h\n",
"\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"It should work now, have fun!"
],
"metadata": {
"id": "VhGU2XifSnHe"
}
},
{
"cell_type": "code",
"source": [
"# Create a hello.asm file\n",
"%%writefile src/hello.asm\n",
"; Include Irvine32 library\n",
"INCLUDE Irvine32.inc\n",
"\n",
"; Only necessary if you're not using Visual Studio\n",
"INCLUDELIB Irvine32.lib\n",
"INCLUDELIB kernel32.lib\n",
"INCLUDELIB user32.lib\n",
"\n",
".data\n",
" ; Define variables\n",
" string BYTE \"hello world\", 0\n",
"\n",
".code\n",
"main PROC\n",
" ; Main function\n",
" mov edx, OFFSET string\n",
" call WriteString\n",
" call Crlf\n",
" exit\n",
"main ENDP\n",
"END main"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "YFzBNO0Pf7cN",
"outputId": "baa04ee5-fb66-4823-9c2d-778da6ba7b58"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Writing src/hello.asm\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# If you need to take user input, run this command in xterm instead (see the next cell)\n",
"!./run.sh hello 2>/dev/null"
],
"metadata": {
"id": "yRgE0BMSnx89",
"colab": {
"base_uri": "https://localhost:8080/"
},
"outputId": "3fc3596d-b23b-49b4-c277-eaf7ae21eb33"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\u001b[?25l Assembling:\u001b[K\u001b[1C\u001b[?25h\u001b[?25lhello.asm\u001b[?25h\n",
"\u001b[?25lMicrosoft (R)\u001b[K\u001b[1C\u001b[?25h\u001b[?25lIncremental Linker\u001b[?25h\u001b[?25l Version 12.00.21005.1\n",
"Copyright (C) Microsoft Corporation. All rights reserved.\n",
"\n",
"\u001b[?25h\u001b[?25lhello world\u001b[?25h\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# Install and start xterm\n",
"!pip install colab-xterm >/dev/null\n",
"%reload_ext colabxterm\n",
"%xterm"
],
"metadata": {
"id": "96qg_KCpNg5N"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment