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
4
votes
0answers
29 views

Arm Assembly Tokenize String (strtok()), Load Move, Add Efficiency

Dabbling a bit more with arm assembly, I wrote a few functions to handle string splitting. The goal was to write a few reusable functions that could be combined to emulate (roughly) what C ...
2
votes
1answer
84 views

Writing an x64 Code Emitter to eventually make a full fledged Assembler like NASM

As the title suggests, I'm writing an x64 Code Emitter. Right now I've only encoded 1 instruction (The add instruction). I want to know if this API can be improved at all. This is how you I use it. <...
3
votes
1answer
54 views

GNU assembly (AT&T syntax) bootloader load the next sector from floppy

I'm playing with the Real mode and was trying to code something when suddenly I exceeded the 510 boundary (.org 510) of the <...
7
votes
2answers
330 views

Hack machine language assembler as required for project 6 of Nand2Tetris

This is the implementation of the Assembler required to parse source code written in the Hack Machine Language and output it to a 16-bit binary file. After writing one go in Swift, I decided I wanted ...
1
vote
1answer
31 views

Printing one to ten in (GAS/AT&T x86/x64) assembly

I've started my journey of learning assembly on my Mac. As a start, I've decided to write a program to print the numbers one through ten to the console, then a final string signifying the end of the ...
4
votes
1answer
382 views

4x4 double precision matrix multiply using AVX intrinsics (inc. benchmarks)

Benchmark An optimised 4x4 double precision matrix multiply using intel AVX intrinsics. Two different variations. Gist For quick benchmark (with a compatible system) copy paste the command below. Runs ...
6
votes
1answer
97 views

Assembler. Algorithm for incrementing a decimal number

I share an algorithm that I have written myself. It is useful for incrementing any digit of a decimal number. That way, a conversion to decimal is not necessary. Please excuse the mistakes. I am ...
2
votes
1answer
87 views

FizzBuzz in arm64

I made a FizzBuzz program in arm64; I print out the values in hex instead of decimal. This was the first arm64 program I made and I'm looking for advice on how I can improve it. The code to print out ...
1
vote
0answers
34 views

81 variations of the rounded rectangle

If we apply outward curving, inward curving, and no curving at all, individually to each of the 4 corners of the rectangle, we get next 81 variations: The code implements next BASIC command: ...
1
vote
0answers
161 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, ...
2
votes
1answer
115 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? ...
1
vote
1answer
163 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 ...
4
votes
1answer
519 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 ...
0
votes
1answer
399 views

Writing a recursive factorial function in x86-64

The following assembly program works to print the factorial of a number: ...
-1
votes
1answer
82 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: ...
6
votes
3answers
191 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....
1
vote
1answer
69 views

Converting decimal to binary in Assembly

The longest example program in my PicoBlaze Simulator in JavaScript is this decimal-to-binary converter: ...
25
votes
4answers
3k 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
44 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
162 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
97 views

How do I optimize the bubble sort in Assembly8086?

I tried to implement bubble sort in Assembly 8086. ...
3
votes
0answers
55 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
78 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
78 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). ...
4
votes
2answers
330 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
89 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
55 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
52 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
63 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
170 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 ...
3
votes
0answers
59 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 ...
4
votes
1answer
230 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 ...
2
votes
1answer
70 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
172 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 ...
4
votes
2answers
160 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. ...
2
votes
2answers
94 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
113 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
2k 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
111 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
107 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
497 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
75 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
106 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
84 views

Fibonacci Sequence using Recursion with Memoisation

File fibonacci.aec: ...
1
vote
0answers
41 views

Analog Clock in AEC

I've made a simple terminal-based analog clock for Linux in AEC. Here we go: ...
4
votes
1answer
554 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
240 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 ...
3
votes
1answer
74 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 ...
2
votes
1answer
42 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
75 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 ...

1
2 3 4 5
7