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
3
votes
2answers
89 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 ...
2
votes
1answer
43 views
0
votes
0answers
33 views

Analog Clock in AEC

I've made a simple terminal-based analog clock for Linux in AEC. Here we go: ...
3
votes
1answer
34 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 ...
3
votes
2answers
79 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
948 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
38 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
32 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 ...
2
votes
0answers
25 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 ...
6
votes
1answer
1k 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
91 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
101 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 ...
16
votes
0answers
250 views

Multiplying big numbers using Karatsuba's method

The Karatsuba algorithm, first published in 1962, aims to speed up the multiplication of big numbers by reducing the number of 'single-digit-multiplications' involved. Because of its complexity (...
11
votes
3answers
12k 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. ...
2
votes
1answer
140 views

Routine to 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 ...
2
votes
1answer
63 views

Is this the rigth way to write power and factorial functions with nasm?

I wrote factorial and power functions with nasm but I don't know if it is the right to write assembly code. For example, by executing the functions I make some changes in the registers and I don't ...
4
votes
1answer
46 views

A fast generator of palindrome dates in chronological order

02/02/2020 is a palindrome day because reading the date left-to-right or right-to-left still refers to the same calendar date. And because it doesn't matter whether you use the DD/MM/YYYY format or ...
5
votes
2answers
106 views

x86 Single Stage Bootloader

I'm learning OS development and have written a single stage bootloader that loads the kernel, enters to protected mode and finally jumps to the kernel. I'll very appreciate any feedback and ...
15
votes
1answer
363 views

Signed integer-to-ascii x86_64 assembler macro

I have implemented an algorithm which converts a signed integer to its ASCII equivalent string with the corresponding sign as a first byte. I have tested it on several numbers and it worked correctly. ...
4
votes
1answer
69 views

Program for string length in x86

It takes in a string from the command line. prints out the length of the string. I'm mostly looking for tips and general convention suggestions But I'm open to any other criticism also. Roast it ...
1
vote
0answers
46 views

Simple arithmetic operations in MASM using dosbox [closed]

This program does simple arithmetic calculation (+. -, *, /, %) in masm. I've tested the code. ...
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 ...
5
votes
1answer
87 views

Assembler for Brookshear Machine

As a small exercise in Python, I created an Assembler for the rather simple Brookshear Machine (see f.e. Brookshear Machine, please note, however, that the instruction set differs from mine). The ...
6
votes
1answer
1k views

Assembler for Hack Assembly Language from nand2tetris in Java

I have been doing a brilliant course on coursera based on the book "The Elements of Computing Systems: Building a Modern Computer from First Principles" by Simon Schocken and Noam Nisan. You can find ...
3
votes
0answers
30 views

Instant to-and-from Roman Numeral Conversion

Ⅰ Roman numerals are composed of digits taken from a small set of uppercase characters. Lowercase characters were first used in the Middle Ages. $$I,V,X,L,C,D,M$$ With these digits we can represent ...
4
votes
2answers
35 views

A progression of quines - follow up

This is a follow up on A progression of quines. Based on the reviews I got, I have reworked my first and fifth programs. The nice quine The answer I received from ecm made me realize that my nice ...
3
votes
1answer
40 views

Key-scanning macro in NASM Win16 against DOSBOX (Intel 8086)

Supports backspacing, but not wrapped backspacing. ...
9
votes
2answers
111 views

A progression of quines

A quine is a program whose only job it is to reproduce the source file that was used to create the executable in the first place. This stackoverflow post provides some reasoning about its usefulness. ...
7
votes
5answers
158 views

Assembler-program which reverses the content of EAX

Following exercise: Write a program that takes a number (of size 4 bytes) x as input, and then reverses all the bits of x, and outputs the result. By reversing all bits we mean that the ...
43
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{\...
6
votes
1answer
116 views

Multitasking in NASM Win16 Assembly

Requirements (Installed using Scoop) scoop install nasm dosbox Build (Using NASM) nasm -g tasks.asm -o tasks.com ...
4
votes
1answer
110 views

fasm convert hex byte to binary string

This fasm x64 (Linux) code seems very crude and repetitive, but it gets the job done. How could I perform this task in a more idiomatic manner? ...
3
votes
1answer
39 views

x64 fasm strlen

This is a simple strlen function with registers documented: ...
1
vote
1answer
131 views

Shifting bits in assembly (nasm)

I wrote a function which takes a byte and shifts the bits around. That is, there shall be the same number of 1 bits and 0 bits in the output but the bits will be shifted in position: ...
4
votes
1answer
138 views

Printing a string in NASM Win16 Assembly

A small script that simply prints a given string. It's an improved snippet that combines some recommendations given in my post on string helper functions. ...
23
votes
3answers
4k views

Checking if a number is prime in NASM Win64 Assembly

I'm just learning Assembly. This program is a simple attempt to determine if a given number is prime or not. Compiled as follows using VS2019 x64 Native Tools Command Prompt: ...
6
votes
2answers
191 views

String helper functions in NASM Win16 Assembly

Environment NASM is required to build this program, and DosBox is required to run it. I'd recommend installing these using the Scoop Package Manager. Feel free to ignore install statements for any ...
7
votes
1answer
497 views

Tower of Hanoi in NASM Win64 Assembly

This program is an implementation of the classic puzzle Tower of Hanoi! This is my first mostly recursive Assembly program. Any advice and all topical comments on code optimization and conventions is ...
3
votes
1answer
42 views

Ubuntu 18.04.3 ASCII strings length with embedded VT100 control codes

As my applications rely on VT-100 emulation, I found that I had to do quite a few workarounds to determine the number of visible characters in a string with embedded VT-100 control codes. So that led ...
6
votes
1answer
83 views

Cat program in x64 FASM

I wrote cat program in x64 FASM and I would like to know if there is anything that can be improved. This implementation of cat supports: Reading from stdin. Multiple arguments. I checked few cases ...
6
votes
1answer
133 views

Cat program in x86 NASM

I wrote cat program in x86 NASM and I would like to know if there is anything that can be improved. This implementation of cat ...
7
votes
4answers
85 views

Ubuntu 18.04.3 LTS get terminal columns and rows NASM

As part of the prologue of all my console applications, I need to determine the extents of the current terminal so if there are less than 132 columns or 43 lines the user can be warned output may not ...
5
votes
2answers
87 views

Display hexadecimal value stored at a register

I read a book about OS development and faced with a simple exercise: write a function that prints a hexadecimal value stored at a register. The program runs as a boot sector. I would really ...
7
votes
1answer
58 views

X86 Feature detection in preparation for Long Mode

These are the three steps that need to be taken in order to successfully activate Long Mode. Error reporting is sparse as most real hardware for developing an OS is 64 bit but probably still a good ...
7
votes
1answer
956 views

Fastest fill memory with specified 64-bit value

I need to fast fill a memory block in C#, so I wrote something like this (in Free Pascal Compiler + Lazarus in 64 bit mode): ...
3
votes
2answers
84 views

Multi-line text reader (x64 ASM)

Building upon my previous question, I have come up with a method that'll search through a buffer and return a pointer to the end of the line. The primary purpose of the function to extract rows from a ...
7
votes
3answers
207 views

String routines

These are a few string routines (just the mem* ones). I've tried to optimize them the best I can without having them be too big, but I'm unsure if I've done a good ...
13
votes
1answer
209 views

Loading a file from a FAT32 filesystem in 16 bit real mode on x86 (Intel syntax assembly)

I am writing a bootloader that needs to load a file from a FAT32 filesytem. Since I need to load both the root directory first to find the start of the file, and then the actual file, I wrote a ...
5
votes
2answers
92 views

Find the maximum number in an array of numbers

The task is to find the maximum number in an array of numbers. I have taken every number in the array to be byte-sized. I have written the code such that the result is stored in ...

1
2 3 4 5 6