An assembly language is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture's machine code instructions.

learn more… | top users | synonyms

2
votes
0answers
27 views

Benchmarking function variations

I'm trying to benchmark two variations of one of my functions. Namely, these functions are for displaying integer values on the command line. The first of the functions uses my own implementation of ...
1
vote
1answer
20 views

FizzBuzz in the MIPS ISA

The title pretty much explains it. This is the first program I've written in assembly, so any criticism, either on programming style or saving instructions, would be appreciated. ...
1
vote
0answers
38 views

Measuring CPU frequency in *nix

I have this small function for reading the TSC (time-stamp counter) in *nix. Using it seems to report my CPU frequency more or less correctly. ...
7
votes
1answer
58 views

Assembler listings parser components: Operands parser

I'm building the above mentioned parser. It reads a string of assembler instructions. I want to become a better coder, so I wanted to get a code review to start learning to do things property. As we ...
11
votes
4answers
595 views

Detecting arithmetic overflow in C with NASM

This snippet is about detecting whether the carry flag is set or cleared. I work on Mac OSX, so my snippet supports Mac only. First, we need a routine that does the job: func.s: ...
16
votes
2answers
169 views

Fast 32x32 bit multiply on ARM M0

I have a time-critical calculation running on an ARM Cortex-M0. This is the fastest 32x32 bit -> 64 bit multiplication that I can come up with. The following C compiles almost 1-1 to assembly ...
8
votes
2answers
115 views

Implementing min of 3 numbers in Mic-1 code

I have the following algorithm to find a minimum of three input numbers: ...
6
votes
1answer
34 views

Brainfix to NASM converter written in C (revision 2)

See this post for the previous question. I have made several enhancements to this compiler and language that make it a lot easier to work with, as well as slightly decreasing executable size (if new ...
5
votes
2answers
110 views

Brainf*ck to NASM converter written in C

I have made a very simple Brainfuck to NASM converter, that is usable for practically all programs. It has one trivial optimisation (to subsitute ADD for ...
4
votes
0answers
71 views

Selection Sort in Assembly [closed]

I was wondering if there could be anything done to clean up this code a bit. There is also a problem where every so often the sorted array will only display a fraction of the original amount of ...
3
votes
1answer
32 views

Routine for convert decimal digits to Densely Packed Decimal

I've written an amd64 assembly routine (in gas syntax using the System V calling convention) to convert three decimal digits to densely packed decimal because I wasn't satisfied by the performance of ...
6
votes
1answer
98 views

A C function for returning the address of the calling function

Suppose you are given two functions, foo and bar, and neither of them are inlined. Now, if ...
1
vote
0answers
49 views

Variations on binary searching an ordered list

In the wikipedia article about the binary search algorithm (https://en.wikipedia.org/wiki/Binary_search_algorithm) a small paragraph in particular got my attention. Midpoint and width A ...
6
votes
2answers
140 views

Finding multiples of 3 or 5 with MIPS assembly (Project Euler #1)

I just started learning MIPS assembly at my university and I would like some feedback on this code. The program is Project Euler Problem #1, finding the sum of multiples of 3 or 5 less than 1000. It ...
11
votes
2answers
167 views

A low tech approach to measuring game speed

Whilst developing a game I needed a delay routine capable of doing delays ranging from 0.5 sec to just a few msec. The obvious choice was to use the BIOS delay function 86h on int 15h. In a true real ...
14
votes
1answer
118 views

Embedded FizzBuzz

Recently, I have started to enter the realms of embedded systems programming. And, as my first major project, I thought I'd do the obvious: FizzBuzz. However, this is a little different: this is a ...
2
votes
2answers
165 views

Assembling an Interrupt Handler

- INTERRUPT HANDLER - ...
8
votes
1answer
61 views

Assembling a Sequence

I've completed the "Sequence Counter" level of TIS-100, but this is horrendously inefficient. My cycle counts are at about twice the minimum possible according to the charts: I'm not really as ...
12
votes
2answers
297 views

Inefficient differential converter

Following Pimgd's question, I decided to take a look at the TIS-100 myself. This is my solution to the 3rd challenge, building a differential converter. Requirements: Read values from IN.A and ...
8
votes
2answers
117 views

Filling a memory segment with a bit pattern

I want to fill a memory segment with a certain byte pattern using powerpc assembly: ...
32
votes
5answers
2k views

The loaderless bootloader

I began this month with trying to discover how shellcode is made. My search led me to wanting to learn assembly, so I wrote a simple bootloader with NASM: ...
7
votes
1answer
89 views

Monte Carlo Pi (MASM)

I'm currently trying to brush up on my assembly skills and, being at the FPU section of the tutorial, I implemented a very basic version of a Monte-Carlo-Algorithm to compute pi. I deliberately use ...
25
votes
2answers
6k views

Counting Sequence Length in TIS-100

I picked up a programming game, TIS-100. Programming manual can be found on Steam as well, but I have described the relevant syntax in my question. Basically, you're dealing with some old machine ...
3
votes
2answers
193 views

Assembler for Hack Assembly Language in Python

My Python implementation of for Hack Assembly Language. See this question for the Java implementation. Any comment about best practices and performance improvement? ...
10
votes
3answers
139 views

Distance between two n-dimensional points (NASM)

I just finished writing a function that computes the distance between two n-dimensional points. The original one was written in C and it's basically a translation of this formula: ...
2
votes
1answer
140 views
9
votes
1answer
405 views

A Virtual Piano

I have created a virtual piano that turns the home row (excluding 'g' and 'h') and the top row (excluding 'y' and 'u') of the user's keyboard in a piano's keyboard. The home row is used for white ...
3
votes
0answers
87 views

Porting x86 assembly that is used to increment a value

I'm working on a port of some existing inline x86_64 assembly code to AArch64 compatible assembly and would appreciate the feedback. I'll post below the original x86 and my ported AArch64 code. The ...
2
votes
2answers
263 views

Assembly Summation Implementation

I wrote a simple summation program in MARS to practice using loops and jump instructions. I feel like this is pretty lightweight and wanted some feedback on possible improvements: Lowering ...
3
votes
2answers
57 views

Implementing OR with the lc-3

Today, something possessed me and I started learning assembly. My poison of choice is the lc-3, this is my very first program. It is actually only the first part of a two part problem, but this ...
7
votes
2answers
545 views

Spinlock for C++ kernel (with x86 ASM)

This is some prototype code for a spin-lock for my toy operating system. Bear in mind this means there are no standard library routines to fall back on. It's also for C++11 compilation and will only ...
3
votes
2answers
175 views

Assembler for Hack Assembly Language - Take 2

I have been reading this great book and I decided to do the Project in Chapter 5: Writing an Assembler for the Hack Assembly Language. You can find the specification for the Hack Machine Language and ...
9
votes
1answer
125 views

A BrainF*ck-ish compiler in C

-ish because I removed the input functionality from the compiler. And, the compiler does not support nested loops I've been recently reading up on compilers and how they work. Although this doesn't ...
6
votes
1answer
636 views

Assembler for Hack Assembly Language

I have been reading this great book and I decided to do the Project in Chapter 5: Writing an Assembler for the Hack Assembly Language. You can find the specification for the Hack Machine Language and ...
4
votes
1answer
979 views

Binary to ASCII converter

This is a program I wrote to convert binary to ASCII. I am still learning ARM assembly. How can I improve my program? Are there any bad programming habits in my code? I've tested it on Raspberry Pi ...
3
votes
1answer
1k views

MIPS assembly addition program

I am new to assembly and have made a simple addition program to sum two integers read from the keyboard. The program outputs correctly, but I want to know if there is a way to streamline my code. It ...
10
votes
2answers
353 views

Printing integers up to 1000 and are not multiples of 5

How can I shorten this? ...
1
vote
1answer
44 views

Two index computations differing in execution time

Code I have the following piece of code ...
3
votes
1answer
72 views

Improved countdown program in x86 NASM

A while back, I posted a question involving code of the same function. This post contains improved code. From the last post, I have improved size, my work with conventions, and my comments. I was ...
5
votes
1answer
845 views

Printing prime numbers in Assembly

I am learning to code in the Assembly language for the x86 architecture. I currently know of a few registers and certain arithmetic operations like add, sub, inc, dec, mov and to check for ...
12
votes
4answers
890 views

Countdown program in x86 NASM

I am fairly new to Assembly language programming and, for practice, I gave myself a problem: count down from 10 and right after 1, say "Blast off!". ...
14
votes
1answer
244 views

Calculating the harmonic average

In this program I was required to calculate the Harmonic Average using an assembly program with a C driver. Harmonic mean is defined as: $$ \frac{n}{\dfrac{1}{x_1} + \dfrac{1}{x_2} + \cdots + ...
12
votes
2answers
345 views

Find binary sequences with low peak sidelobe level of autocorrelation function

I would like to find all binary sequences from the specified range, which has low peak sidelobe level of its autocorrelation function. Here is the solution (this is simplified version of the real ...
14
votes
3answers
832 views

Reverse Polish Notation Compiler

Description A reverse polish notation based compiler. Very small subset of forth This is a proof of concept level compiler, no optimizations or over/underflow checking see the embedded POD for more ...
7
votes
2answers
2k views

Checking substring in 8086 ASM

I have tried like this to check a substring in a mainstring in 8086. Is there any shorter way of doing this? My implementation seems lengthy. ...
30
votes
2answers
1k views

16-bit FizzBuzz in x86 NASM assembly

Since this problem involves small numbers (particularly with a small loop count of 100), it's possible to ease the modulo operation setup by simply working with 16-bit and 8-bit registers: ...
12
votes
2answers
481 views

x64 Assembly - checking for largest prime factor

Using x64 assembly, I solved the Largest Prime Factor problem on Project Euler. The problem is as follows: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of ...
2
votes
1answer
190 views

Inline assembly correctness (especially __volatile__)

Here's my inline-assembly functions, which is used my x86 32bit kernel. ...
8
votes
3answers
3k views

Integer square root in x86 assembly (NASM)

This program calculates the square root of an unsigned 32-bit number with some bit fiddling to get a very close approximation, then one iteration of the Babylonian method to get an exact value. I ...
7
votes
2answers
4k views

String length calculation implementation in Assembly (NASM)

I just made a working implementation of calculating a string's length, but I'm not exactly sure it's the most efficient way. I divide the string up in blocks of four bytes each (32 bits), and add 4 to ...