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.

41
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
2k 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: ...
12
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
170 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
102 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, ...
70
votes
2answers
8k 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 ...
35
votes
2answers
11k 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 ...
38
votes
2answers
951 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
1answer
2k 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
274 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 ...
13
votes
3answers
1k 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
198 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 ...
2
votes
0answers
45 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 ...
13
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
0answers
149 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
502 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
1k 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
303 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
1answer
620 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 ...
7
votes
2answers
711 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 ...
6
votes
2answers
248 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
2answers
265 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
3answers
260 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 ...
5
votes
1answer
101 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....
5
votes
1answer
978 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
2answers
450 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 ...
3
votes
1answer
63 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 ...
3
votes
1answer
162 views

Simple spinlock for C using ASM, revision #1

Revision #1 for Simple spinlock for C using ASM The code: ...
3
votes
1answer
85 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 ...
2
votes
1answer
113 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...
1
vote
1answer
126 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.) ...