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
1
vote
0answers
44 views

setjmp and longjmp implementation in mmix

I've written an implementation of setjmp and longjmp in MMIX (assuming no name mangling). I also hand-assembled it. Are there any mistakes anyone can spot? ...
5
votes
2answers
14k 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
1answer
76 views

MASM) assembly implementation of recursive Fibonacci

I'm trying to teach myself assembly via MASM, below is my first implementation of the recursive form of the fibonacci sequence. I timed it against an equivalent C implementation in release mode and ...
1
vote
0answers
48 views

Binary to hex in ARM64 SIMD assembly

As an exercise in learning ARM64 assembly (aka AArch64), I wrote this function to convert 64-bit binary to hexadecimal with SIMD instructions. I'm most interested in feedback on the algorithm, ...
4
votes
1answer
129 views

Decimal to binary conversion in ARM assembly

I'm "playing" with ARM assembly on a Raspberry Pi, reading various tutorials and posts to help - no, it's not a college assignment, I'm too old for college! I'm pleased with getting the ...
4
votes
2answers
131 views

Fastest (in clock cycles) 16-bit x 16-bit unsigned integer division algorithm for ATMEGA1284?

I am trying to create an optimized 16-bit division algorithm for the AVR ATMEGA1284. The goal is to reduce the number of clock cycles as much as possible. AVR INSTRUCTION SET MANUAL: https://ww1....
108
votes
11answers
43k views

Fastest way to clamp an integer to the range 0-255

I'm working on some image processing code that can generate pixel values outside of the normal range of 0 to 255, and I'd like to clamp them back into the valid range. I know that there are saturating ...
0
votes
1answer
81 views

Writing a recursive factorial function in x86-64

The following assembly program works to print the factorial of a number: ...
48
votes
2answers
3k 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: $$\dfrac{\...
-1
votes
1answer
60 views

Fork Bomb virus in Assembly

I made a fork bomb virus in Assembly. Now, I want to make my code better. Here is my code: ...
1
vote
1answer
47 views

Converting decimal to binary in Assembly

The longest example program in my PicoBlaze Simulator in JavaScript is this decimal-to-binary converter: ...
24
votes
4answers
2k views

x86-64 Assembly - Sum of multiples of 3 or 5

I'm trying to learn some basic x86 assembly and so I've begun solving Project Euler problems. I was hoping for some critique of my code that, hopefully, includes either the efficiency of the ...
1
vote
0answers
43 views

C++ calculation of curling number in sequences (Assembly?)

I'm writing a program that creates curling sequences -- in short this means that we start with a given sequences, consisting of 2's and 3's (i.e. a mix of 22 of them), and look for repetition at the ...
3
votes
2answers
138 views

Very simple OS in Assembly

I made a very simple OS in Assembly. But my code is too long. I want to make my code shorter. Here is my code: ...
3
votes
1answer
63 views

How do I optimize the bubble sort in Assembly8086?

I tried to implement bubble sort in Assembly 8086. ...
3
votes
0answers
38 views

Assembly REPL in Python using ctypes

I created a assembly REPL using some ctypes hacks to run the assembly code. Any suggestions on how I could improve it? I am unconcerned about some of the "obvious" security issues such as ...
5
votes
1answer
76 views

Find all the digits in a string

S is a given character string, then I have to find all the digits characters of S. Did I make it unnecessarily complicated? <...
6
votes
1answer
77 views

Given a byte string S of length l, obtain the string D of length l-1 as D(i) = S(i) * S(i+1)

Given a byte string S of length l, obtain the string D of length l-1 as D(i) = S(i) * S(i+1) (each element of D is the product of two consecutive elements of S). ...
3
votes
1answer
63 views

A very fast Game of Life

The rules of John Conway's Game of Life are simple: An OFF pixel that has 3 live neighbours is turned ON. An ON pixel that has anything other than 2 or 3 live neighbours is turned OFF. Many people ...
5
votes
1answer
105 views

Collatz Conjecture Disprover Unit - Googol Edition

The Wikipedia article about the Collatz Conjecture has these quotes: If the conjecture is false, it can only be because there is some starting number which gives rise to a sequence that does not ...
4
votes
2answers
189 views

x86_64 nasm criticism on malloc and free implementation

I have made my own malloc implementation using this resource as a guide https://danluu.com/malloc-tutorial/ I was hoping to receive some feed back on how I can improve upon it, and If I did any major ...
7
votes
1answer
87 views

x / 2 + 100 * (a + b) - 3 / (c + d) + e * e in assembly

write an algorithm for: x / 2 + 100 * (a + b) - 3 / (c + d) + e * e knowing that: a, c - word, b, d - byte, e - doubleword, x - qword ...
4
votes
1answer
47 views

Trivial string-reverser in MASM64

I've been learning MASM64 over the last few days and written a simple demo, so I can get feedback on my understanding of x64 assembly programming. It's really basic: it asks the user for their name, ...
2
votes
1answer
38 views

Debounce counter for PIC micro - Suggestions for improvement

I developed this code for a vertical debounce counter for the PIC micro (PIC16F57). The code is called every 512 microseconds. It takes 5 bits from PORTB and compares it to a last known debounced ...
1
vote
1answer
56 views

Criticism on x86_64 nasm printBigInt and bigPow implementation

The first "method" I have coded is _bigPow which can pow(x, y) on any number which is really big. And the _printBigInt prints a very big integer. Plus I have tried to comment most parts of ...
6
votes
1answer
124 views

CodeWars - Assembly Language - Check List For Value

I'm doing assembly language problems on CodeWars, a website with practice problems. Problem https://www.codewars.com/kata/545991b4cbae2a5fda000158/train/nasm Create a method that accepts a list and ...
4
votes
2answers
108 views

Criticism on x86_64 nasm assembly strToInt and printInt implementation

I am pretty new to assembly I would like criticism on two "methods" I have written. One converts string to int and the other prints an int to stdout. Any advise helps out. ...
4
votes
1answer
87 views

Print a list of strings in assembly

How does the following program look to print a list of strings? What places can I improve? Are there easier ways to print something like a linebreak after each string rather than hardcoding the ...
3
votes
0answers
54 views

Printing a decimal number as a string

I've written a short script to print a number to a string. This actually was very difficult for me to do -- I'm not sure if this is actually a tricky task or just because I'm so new to asm I was ...
2
votes
1answer
64 views

Program to find the maximum number/factor in a list

I have written the following basic assembly program to find the maximum number in a list divisible by a number. Here is what I have thus far: ...
2
votes
1answer
99 views

x86 program to do an exponent

For continuity, my last question was with adding numbers together with a function call: Example x86-64 program. In this one I've tried to apply the lessons pointed out in the previous answer (stack ...
2
votes
2answers
83 views

Exponentiation by squaring in x64 Linux Assembly

I am learning some assembly for a compiler project I am working on and I have come across the Exponentiation by Squaring algorithm when it came to calculating x ^ n. To get a grasp on how the ...
3
votes
1answer
91 views

Example x86-64 program

I wrote the following x86 program to make sure I'm following the correct practices in calling a function and then exiting to the OS: ...
3
votes
1answer
468 views

Simple input and output in assembly x86_64

I am new assembly programming in Linux (x86_64) and I want to make sure that I am programing in a correct way. I wrote a program that just takes an input from the user and then writes his input to ...
7
votes
1answer
98 views

Can I shorten this assembly code to test if a number is even?

Here is MIPS code to return 1 if a number is even, 0 otherwise: isEven: andi $t0, $a0, 1 li $t1, 1 sub $v0, $t1, $t0 jr $ra My question is whether ...
7
votes
1answer
97 views

Project Euler #1 AT&T Assembly

To practice learning x64 AT&T Assembly (GAS), I implemented three solutions for Project Euler Problem 1 (find the sum of all the multiples of 3 or 5 below 1000). The codes and a rough pseudocode ...
7
votes
1answer
245 views

x64 NASM Assembler: Binary Search

While quarantine I decided to look into the assembly language, as it's quite interesting to see how code works on the lower levels. To challenge myself I made a binary search algorithm. The OS is ...
5
votes
1answer
66 views

Hailstone Sequence in NASM

For practice, I wrote some NASM code that prints out the hailstone sequence of a (unfortunately, hardcoded) number. This is by far the most complex code I've ever written in NASM. I'd like advice on ...
3
votes
2answers
105 views

HybridSort of QuickSort and MergeSort

I'll try to publish a paper about the programming language I've made (ArithmeticExpressionCompiler, short AEC) in Osječki Matematički List and, in order to demonstrate its usability for implementing ...
3
votes
1answer
68 views
1
vote
0answers
40 views

Analog Clock in AEC

I've made a simple terminal-based analog clock for Linux in AEC. Here we go: ...
4
votes
1answer
298 views

Selection sort algorithm in x86_64 Yasm assembler

I returned to study assembly language. And this is actually my first function written in Yasm. Implementing this function is a suggested project from this book. I slightly modified the pseudo code ...
5
votes
2answers
136 views

SSE Assembly vs GCC Compiler - Dot Product

I am currently taking an introductory course in computer architecture. Our goal was to write a dot-product function in x86 Assembly which would use SSE and SIMD (without AVX). I am not to that ...
32
votes
3answers
6k views

Decide if the sum of three numbers is even or odd

Exercise from an Assembly course I'm enrolled into: Write a program that takes three numbers x,y,z as input, and returns: 0 if (x+y+z) is even. 1 if (x+y+z) is odd. (Note that ...
6
votes
0answers
2k views

Finding the length of arbitrary ASCII character strings

I have implemented this MIPS code to determine the length of given ASCII character strings. Is there a simpler way to implement this code? Is there is a built-in function in MIPS? Given String: ...
2
votes
1answer
40 views

Printing all permutations of digits of a number

So, a long time ago, I've made a program that prints all the permutations of digits of a number in AEC. Now I have refactored it a bit, and I would be interested in what you think about it. ...
3
votes
1answer
60 views

Pascal's Triangle in AEC

So, I am trying to make people interested in my compiler project (in the early stages of development) by making some simple and clear programs in my programming language. Here is my implementation of ...
6
votes
1answer
2k views

NASM tutorial (Linux syscalls, 64 bit) code with CI-build and test

According to this question, I have made an agreement with Peter Cordes to create such a question here. I think that I should prepare the tutorial using the modern technologies as the Continuous ...
5
votes
1answer
98 views

An echo program, mostly in C and completely from scratch

This is an echo program with no runtime or standard library. It's meant to be compiled with -nostdlib on an amd64 Linux system. ...
2
votes
1answer
103 views

An assembler to assemble a hypothetical instruction set [closed]

We have been given a college assignment (Yeah even during lockdown!!) to implement an assembler to assemble the reference instructions given here. The following is my code to implement pass1 of the ...

1
2 3 4 5
7