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.
2
votes
1answer
45 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
90 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
71 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 ...
4
votes
2answers
79 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, ...
12
votes
0answers
128 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
132 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 ...
54
votes
2answers
5k 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 ...
10
votes
1answer
356 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 ...
5
votes
2answers
125 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
65 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
88 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
79 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:
...
0
votes
0answers
22 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 ...
5
votes
1answer
63 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 ...
2
votes
1answer
65 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
115 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
240 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 ...
1
vote
2answers
87 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
55 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
39 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.
...
4
votes
3answers
135 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
212 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
47 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
221 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
59 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 ...
11
votes
2answers
195 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
73 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
59 views
Simple spinlock for C using ASM, revision #1
Revision #1 for Simple spinlock for C using ASM
The code:
...
5
votes
1answer
81 views
Simple spinlock for C using ASM
This is my second attempt to make simple lock using extended assembly.
See http://stackoverflow.com/questions/37241553/locks-around-memory-manipulation-via-inline-assembly/37246263
The code:
...
-1
votes
1answer
122 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
251 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
162 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 ...
5
votes
1answer
442 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
23 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
91 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
67 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 ...
10
votes
1answer
562 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
105 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 ...
7
votes
2answers
124 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:...
5
votes
0answers
315 views
Cooperative multi-tasking / coroutine implementation
Here is my implementation of user-level cooperative threads in C++14, which I'm working on for a hobby project. It's not entirely finished but works pretty well so far. The target operating system is ...
2
votes
1answer
618 views
Simple calculation program in assembly MASM
I am a beginner in assembly. This program calculates:
(Z+Z)+(X-Y)
...
3
votes
1answer
49 views
4
votes
0answers
54 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
55 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
62 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
61 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
87 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
663 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:
...
17
votes
2answers
747 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
149 views
Implementing min of 3 numbers in Mic-1 code
I have the following algorithm to find a minimum of three input numbers:
...