Questions tagged [assembly]

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.

Filter by
Sorted by
Tagged with
2
votes
1answer
127 views

AT&T assembly - Basic loop & write - follow-up

This is a follow-up question to this one: AT&T Assembly - Basic loop & write The code loops to display "Hello, World!" ten times. I implemented the syscall...
8
votes
1answer
2k views

AT&T Assembly - Basic loop & write

The code loops to display "Hello, World!" ten times. I would like someone to criticize it. I know that's far from being good assembly but I only started learning it a few days ago and I would like to ...
6
votes
2answers
273 views

FizzBuzz in MIPS, unneccessary branches

I'm just starting out in MIPS (as is evident by the fact that I'm writing a FizzBuzz program), and my program runs fine and gives the desired output, but I feel like there is a way to do it without as ...
5
votes
2answers
1k views

FASM assembly: Write a program which checks if a number is a prime number

Coming from high-level languages like PHP and JavaScript, I'm doing an Assembly course on Udemy. Yesterday I tried to implement the following task: Write a program that takes a number m as input, ...
40
votes
2answers
1k views

Brainfuck to x86 Assembly Compiler

After my Brainfuck Interpreter written in x86 Assembly I decided that it was time to get to the next step, writing a Brainfuck Compiler in Java that generates x86 Assembly and compiles that to an ...
8
votes
2answers
2k views

Checking if CPU supports rdrand

My goal with this bit of code is to check if my processor supports rdrand and, if not, execute some other random number generating function. To check if ...
74
votes
2answers
8k views

Brainfuck Interpreter written in x86 Assembly

Story time: A week ago I found a question about optimizing Assembly code, then I remembered how awesome Brainfuck was, and the match was made very quickly. I decided to write a Brainfuck Interpreter ...
11
votes
1answer
468 views

Assembler for CPU

I recently put together an assembler for a CPU I designed. I'm looking for feedback on my program structure, formatting, or anything else. I'm self taught on all of this so I don't have opportunities ...
4
votes
2answers
2k views

x86 assembly function that determines whether an array is continuous

I wrote an x86 assembly function using MASM that tests for whether or not an array is continuous. That is to say, if an array with length n that starts with the value k, all the subsequent entries in ...
6
votes
1answer
101 views

X86 Legacy boot loader error trapping

The boot loader that I'm designing is just simply going to setup (A) Stack, (B) Segment registers (C) Load remainder of track for specified device. Conventionally, this could have been up to 4 floppy ...
3
votes
2answers
868 views

X86_64 implementation of STRCHR using NASM

As this will eventually become part of an operating system I'm developing, there is no specific adherence to any particular ABI, even though this is being developed ...
3
votes
1answer
633 views

NASM RPN Calculator

I've been learning Assembly over the past few days, and I've made a simple RPN calculator. Here is the main logic of the program, excluding utility functions such as printing: ...
2
votes
0answers
301 views

Interpreter for an assembly language with variadic instructions

I am currently implementing a virtual machine that runs a programming language similar to assembly. The difference is that an instruction in this language can have any number of operands. and the ...
8
votes
1answer
4k views

Integer-to-ASCII algorithm (x86 assembly)

This is my best effort at converting a 32 bit integer in EAX, to an 8 character ascii string (result in RDI). It will work ...
3
votes
1answer
2k views

Unsigned integer division ARM Cortex-M0+ Assembly

I am writing a subroutine for unsigned integer division in Assembly. I will call the subroutine DIVU. Inputs: R1 will be the ...
3
votes
1answer
423 views

Sum up all odd numbers between 1 and 2n + 1

Assignment: Write a program which reads a number n from the console. Then calculates the sum of all odd numbers between 1 and 2n + 1 (incl.). Assignment also on GitHub, Exercise 0.0. The ...
2
votes
1answer
11k views

MIPS program to find the sum and square sum of 10 integers

I wrote a program (hard-code) in MIPS that gets an array of 10 integers and calculates the sum and the square sum of them. The array is ...
3
votes
2answers
1k views

Hexdump utility in x86 NASM assembly

It's a simple hexdump that prints to stdout. I wanted to handle correctly input coming from the user typing at the terminal, this made the logic a little more complicated than just exiting after ...
3
votes
1answer
273 views

File shredder in x86 NASM Assembly

This is a file shredder utility that runs on Linux. It writes random bytes over the file contents, repeating this 48 times and calling sys_fsync after each pass to ...
5
votes
1answer
46 views

Program to print all evironment variables

I'm learning x86 assembly on Linux and this is the first program I wrote, so I'm looking for all kinds of ways to improve it. ...
5
votes
4answers
11k views

A simple assembly program to count the number of ones in a register

I made a simple assembly program to count the number of ones in a register. Since this is basically my first ever, I would like to hear what I can improve or if there are some major flaws in this one: ...
10
votes
2answers
1k views

Dijkstra's algorithm for computing the GCD of two integers, translated from C to x86 assembly

This is the x86 version of a C file assignment (I have included both). We were to convert the C code to assembly. I am rather new at assembly and would really appreciate suggestions and help for ...
6
votes
1answer
96 views

Turn a vsscanf call into a sscanf call

I am reviewing some C code (see extract below) that uses inline asm. I believe there are 4 spec violations, 1 inefficiency and 1 honking big design flaw in this code. While some of the problems I'm ...
0
votes
1answer
3k views

Absolute value function in MIPS

The following is my implementation of the absolute value function in the MIPS assembly language. I would very much like to hear constructive criticism of my code from you as well as any words of ...
2
votes
1answer
79 views

Recursive spinlock for C using ASM, revision #1

Precursor for this revision here in code-review: Recursive spinlock for C using ASM Improvements have been made thanks to forsvarir. Now I am trying to optimize this lock so it becomes more ...
13
votes
2answers
1k views

Brainf*ck interpreter written in x86 assembly

I have written a program in x86 assembly (Intel syntax/MASM) that interprets brainfuck code that is fed to it via an interactive console and prints the final stack to stdout. Note that it does not ...
1
vote
1answer
138 views

Recursive spinlock for C using ASM

My history of C/ASM locks here in codereview: Simple spinlock for C using ASM Simple spinlock for C using ASM, revision #1 (basis for this approach. If this one fails, then so will the one below.) ...
3
votes
1answer
189 views

Simple spinlock for C using ASM, revision #1

Revision #1 for Simple spinlock for C using ASM The code: ...
5
votes
1answer
221 views

Simple spinlock for C using ASM

This is my second attempt to make simple lock using extended assembly. See https://stackoverflow.com/questions/37241553/locks-around-memory-manipulation-via-inline-assembly/37246263 The code: ...
-1
votes
1answer
148 views

Motorola 6809 Prime finder

I'm trying to make a small program which takes a number (form 1 to 1000) and shows the primes between 2 and that number. Right now I have a quite functioning program (except a couple of bugs), but the ...
6
votes
2answers
3k views

x86 assembly method that mimics strcat

I'm trying to learn x86 assembly and hopefully move on to projects of the scope that more than one person would be involved. This is a (relatively) simple subroutine written in Intel x86 assembly ...
1
vote
1answer
262 views

HPC kernel for DGEMM: compiler v.s. assembly

This is a correct version, for computing a small matrix multiplication: C += A * B, where C is ...
6
votes
1answer
2k views

8086/DOS assembly keyboard I=input, data loss in registers

I am working on a project for class, and it works as required by the rubric, though I am wondering if there is a slightly better way to implement a few things. I was docked a few points for an ...
3
votes
0answers
35 views

Using STORAGE macro using QSAM for input/output

I was wondering if you can help me out. I wanted to know if there is an easier way to do the following. My code works but I feel like there is a lot things going out with multiple loops and wanted to ...
4
votes
2answers
132 views

FizzBuzz in ToyVM

Since I have my own virtual machine and an assembler for it, I decided to test it with a FizzBuzz implementation. I have this: fizzbuzz.toy ...
3
votes
2answers
109 views

Assembler for ToyVM

After rolling my own virtual machine, I decided to implement an assembler for it. Ironically, it's all Java, since I needed to do a lot of text manipulations. Please, tell me anything that comes to ...
11
votes
1answer
3k views

ToyVM - a small and simple virtual machine in C - follow-up

(See the previous and initial iteration) Now I have refactored the code in order to conform to the suggestions made in the answers to the first iteration. I have this: toyvm.h: ...
3
votes
1answer
669 views

Hardware interrupt handler in C++

I wrote this class to use a C++ function as hardware interrupt handler. The idea is to have a single entry point where I can switch stacks, and call a chain of ...
9
votes
2answers
308 views

ToyVM - a small and simple virtual machine in C + FizzBuzz demonstration

(See also the next iteration.) I have this small virtual machine. What is there: Stack and, thus, recursion. Conditional and unconditional jumps and, thus, choice and iteration. What is not there:...
2
votes
1answer
3k views

Simple calculation program in assembly MASM

I am a beginner in assembly. This program calculates: (Z+Z)+(X-Y) ...
3
votes
1answer
148 views
4
votes
0answers
126 views

Parallel popcount of packed bytes

I want to do a popcount of bytes in an array. Not a total popcount of everything, but lots of little popcounts for every individual byte to determine the neighborhood count in GoL. The following ...
2
votes
0answers
69 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 these uses my own implementation and prints ...
1
vote
1answer
214 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
1answer
83 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
363 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
988 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: ...
26
votes
4answers
6k 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
382 views

Implementing min of 3 numbers in Mic-1 code

I have the following algorithm to find a minimum of three input numbers: ...
7
votes
1answer
108 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 ...