Monthly Archives: June 2013

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