# Solution to Problem 23 on Project Euler

The problem: — A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A […]

# 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: […]

# Solution to Project 22 on Project Euler

The problem: — Using names.txt (right click and ‘Save Link/Target As…’), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score. For example, when the […]

# 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 […]

# Solution to Problem 21 on Project Euler

The problem: Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers. For example, […]

# 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 […]

# Solution to Problem 20 on Project Euler

The problem: n! means n × (n − 1) × … × 3 × 2 × 1 For example, 10! = 10 × 9 × … × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + […]

# Solution to Problem 19 on Project Euler

The problem: You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. A leap year occurs […]

# 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 […]