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
45
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{\...
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: ...
13
votes
4answers
2k views

Countdown program in x86 NASM

I am fairly new to Assembly language programming and, for practice, I gave myself a problem: count down from 10 and right after 1, say "Blast off!". ...
5
votes
1answer
231 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: ...
4
votes
2answers
116 views

X86 Legacy boot loader prologue

No matter the ultimate goal of any legacy X86 system, startup or prologue, should take into consideration the fundamentals. In this case, the intention before dropping into protected or long modes, ...
76
votes
2answers
9k 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 ...
36
votes
2answers
12k views

Counting Sequence Length in TIS-100

I picked up a programming game, TIS-100. Programming manual can be found on Steam as well, but I have described the relevant syntax in my question. Basically, you're dealing with some old machine ...
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 ...
10
votes
1answer
5k 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 ...
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 ...
9
votes
2answers
322 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:...
6
votes
1answer
2k views

Assembler for Hack Assembly Language

I have been reading this great book and I decided to do the Project in Chapter 5: Writing an Assembler for the Hack Assembly Language. You can find the specification for the Hack Machine Language and ...
4
votes
2answers
81 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. ...
14
votes
1answer
3k views

Linux NASM assembly linked list implementation

Inspired by all of the lovely linked lists lately, I decided to implement one in assembly language. This code maintains two linked lists - one is a free store and the other is the active linked list. ...
13
votes
3answers
2k views

Inefficient differential converter

Following Pimgd's question, I decided to take a look at the TIS-100 myself. This is my solution to the 3rd challenge, building a differential converter. Requirements: Read values from IN.A and IN....
10
votes
2answers
334 views

Disassembler for intel 8080

I have written a disassembler for Intel 8080, able to translate binaries into opcodes and parameters. Sorry for posting so much code, but everything posted here is useful for the understanding of the ...
9
votes
2answers
112 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. ...
2
votes
0answers
64 views

X86-16 writing ASCIIZ strings directly to video

While developing my OS, I decided there was a need to be more verbose about what was happening in real-mode. The idea of embedding non-printable characters in an ASCII string was born from knowledge ...
19
votes
0answers
286 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 (...
9
votes
3answers
788 views

Assembly Nasm Bootloader x86

I just started with deep learning of x86 architecture and assembly so i decided to go from bare metal and write my own bootloader. To add some "functionality" i decided to make quine (from binary ...
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 ...
8
votes
2answers
428 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
2answers
1k views

8086 ASM Bresenham's Line Algorithm

As part of a first year university course in computer architecture some time ago we were tasked with learning 8086 ASM. The final course work required creating a small animation of shapes moving ...
7
votes
1answer
981 views

8086 ASM Bresenham's Line Algorithm Pt2

Following the successful review of my implementation of Bresenham's Line Algorithm, I've been asked to upload the full implementation of my project which creates a small animation of shapes moving ...
6
votes
2answers
569 views

Hex Dump Utility in x86-64 Assembly, under Linux

As a relative newbie to Assembly programming, although I can get my programs to work, I have no idea if they are disastrously constructed or not. I have created a simple Hex Dump Utility, using x86-...
6
votes
3answers
629 views

Finding the maximum of a given list of data in GNU Assembly x86 (32 bit)

I am following the book Programming from the Ground Up and as an answer to a question in the Use the Concepts section of chapter 4: Convert the maximum program given in the Section called ...
6
votes
3answers
4k views

strlen and strcmp implementation in x86 FASM assembly

I wrote my own implementation of strlen and strcmp from C in x86 FASM and I would like to know is there anything that should be changed or improved. strlen needs string in eax and is returning length ...
6
votes
2answers
283 views

Brainf*ck to NASM converter written in C

I have made a very simple Brainfuck to NASM converter, that is usable for practically all programs. It has one trivial optimisation (to subsitute ADD for ...
6
votes
2answers
227 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 ...
5
votes
1answer
1k views

Computing a mathematical function in MIPS assembly

This code computes the function (3x^2-4x+16) / (5x^2+2x-4). I ran the program and it works, but I am fairly new to assembly language and am not quite sure how to ...
4
votes
1answer
121 views

Rich Edit Form Input (x86-16)

This procedure is the natural continuation of the Example 4 that I wrote for How buffered input works, a Stack Overflow Q/A. Features include: freely positioning the cursor. Left Moves cursor left....
4
votes
2answers
519 views

Assembler for Hack Assembly Language - Take 2

I have been reading this great book and I decided to do the Project in Chapter 5: Writing an Assembler for the Hack Assembly Language. You can find the specification for the Hack Machine Language and ...
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
786 views

Reading all file contents via x64 assembly

I have come up with the following snippet by building upon the answers given to my StackOverflow question. Just trying to get some other eyeballs to review things so that they can point out any ...
3
votes
1answer
205 views

Simple spinlock for C using ASM, revision #1

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

Binary values in hexidecimal notation written directly to video memory

In X86 Legacy boot loader prologue the first seven instructions preserve the state of the 8 general purpose and 6 segment registers. This is where they are displayed, right justified without leading ...
2
votes
1answer
52 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
1answer
128 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...
2
votes
1answer
803 views

Variations on binary searching an ordered list

In the Wikipedia article about the binary search algorithm, a small paragraph in particular got my attention: Midpoint and width A different variation involves abandoning the L and R pointers and ...
1
vote
1answer
142 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.) ...