# Problem 8 on Project Euler with x86 Assembly

Find the greatest product of five consecutive digits in the 1000-digit number.

# A Simple Multi-Tasking Operating System in ARM Assembly

This project was done for the ‘Computer Organization and Assembly Language’ class, with Prof. Borin from Unicamp. Below you’ll find the code that runs a very simple operating system in ARM Assembly. On system start the OS will configure some pieces of hardware (e.g., GPT, UART and TZIC) and it will setup the environment (supervisor […]

# Problem 7 on Project Euler with x86 Assembly

The problem: — By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? — My solution: .text .globl main main:   /*-enter stack frame-*/   pushl %ebp   movl %esp, %ebp   movl \$3, %edi   movl \$1, %esi   mainLoop: […]

# Problem 6 on Project Euler with x86 Assembly

The problem: —— The sum of the squares of the first ten natural numbers is, 12 + 22 + … + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + … + 10)2 = 552 = 3025 Hence the difference between the sum of the […]

# Problem 5 on Project Euler with x86 Assembly

In order to practice x86 Assembly (NASM especifically) I am solving some problems on Project Euler with it. Here’s problem 5: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of […]

# Printing “Hello World” with x86 NASM Assembly

After playing a lot with ARM assembly I am starting to code a bit in x86 Assembly (especifically Linux NASM, so the AT&T syntax). Below you’ll find three basic programs to print “Hello World” and variations. 1. Using Syscall Write .text .globl main main:   movl \$4, %eax   movl \$1, %ebx   movl \$string1,%ecx   movl \$20, %edx […]

# IAS Simulator in ARM Assembly

This project was done for the ‘Computer Organization and Assembly Language’ class, with Prof. Borin from Unicamp. Below you’ll find an IAS Computer simulator, written entirely in ARM assembly. The ias_engine.s file is the core that simulates the IAS computer. Interface.s is the simulator interface that lets the user run the whole program, run a […]

# Matrices Multiplication in ARM Assembly

Below is the ARM assembly code that multiply two matrices: .extern printf .extern scanf .global main .text main:   push {ip, lr}   @–read lines and columns of matrix A   ldr r0, =scanf2   ldr r1, =linesA   ldr r2, =columnsA   bl scanf   @–read all values of matrix A   ldr r4, =linesA   ldr r4, [r4]   ldr r5, =columnsA   ldr […]

# Hamming 7-4 Code in ARM Assembly

This project was done for the ‘Computer Organization and Assembly Language’ class, with Prof. Borin from Unicamp. The Hamming Code (also called 7-4 code) is an error-correcting code used to make transmission and store of data less error-prone. It adds 3 parity bits to every 4 bits (hence 7-4). You can read the details here. […]

# Printing in Binary Form – ARM Assembly

When programming in assembly there are many occasions where you need to examine the bits at a particular register or memory address. Printf doesn’t offer the option to print in binary form, so you need to create your own function if you want to do that. Here’s one that will do just that. It prints […]