Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
16 views

String printing macro in NASM Win16 Assembly (No DOS\21h)

Building upon the knowledge gained from my other experiments, here is an attempt at making some macros to handle string printing and definition. Reference this post for building instructions. string....
4
votes
1answer
73 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
85 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
384 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
37 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
69 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
84 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
79 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
75 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
55 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
885 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
81 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
192 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
95 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
81 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 ...
5
votes
1answer
63 views

Multiplying a Matrix with its Transpose

Currently, I am in the process of optimizing a MIPS assembly program that takes a n x n matrix and multiplies it with its transpose. I am trying to optimize my matrix calculation algorithm so that it ...
3
votes
1answer
35 views

Transposing a square matrix (n x n)

I wish to transpose a square matrix, permanently overwriting it. This is not the same as creating a 2nd matrix with the transposed contents of the 1st matrix. I call the procedure with 3 parameters: ...
9
votes
2answers
11k 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. ...
3
votes
2answers
918 views

Hexdump utility in x86 NASM assembly

It's a simple hexdump that prints to stdout. I wanted to handle correctly input coming from the user typing at the terminal, this made the logic a little more complicated than just exiting after ...
4
votes
1answer
102 views
17
votes
1answer
236 views

Brainfreeze: A Brainfuck compiler in C

BrainFreeze This is my implementation of a brainfuck compiler in C. The instruction to build/run the project (GitHub repo) can be found here. I am first converting the brainfuck source to x86 ...
11
votes
3answers
2k views

Decoding assembly instructions in a Game Boy disassembler

I am coding a game boy disassembler in C++. The program (simplified here) converts a vector of byte into an assembly instruction and print it. To do so, it iterates through the vector of bytes (char)...
3
votes
1answer
140 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 ...
5
votes
3answers
842 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 ...
4
votes
3answers
150 views

A simple shellcode that will kill all your processes GNU/Linux x86_64

So I made a simple shellcode that will kill all your process. Now I would like to know, can it be done in some better way? It contains 13 bytes. Thanks for all your feedback Assembly: ...
13
votes
1answer
142 views

Brainfuck to NASM compiler in Haskell

After reading this article on writing a Brainfuck interpreter in Haskell and achieving awful performance with it (for example, mandelbrot generating 37.5 minutes on an old Intel Atom powered laptop) I'...
4
votes
0answers
80 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 ...
6
votes
4answers
219 views

Find some X^2 - Y^2 equal to a given Z

Request input (Z) from user, \$-65535 \leq Z \leq 65535\$. Check if \$(X^2)-(Y^2)=Z\$ (while \$0 \leq X,Y \leq 1000\$). I wrote a code which will receive Z from user, if it's negative, store the ...
9
votes
2answers
173 views

Caesar cipher in i686 assembly + MMX

I have written the following implementation of the Caesar cipher for an old Linux computer with a Pentium MMX chip. The code has been written with the following design goals in mind: the code should ...
4
votes
2answers
119 views

Test whether a number is a Harshad Number

A little code I wrote that will check if the entered 4-digit number is Harshad or not (Harshad number is one which divided by the sum of its digits will leave no remainder, special Harshad is the same ...
4
votes
1answer
29 views

Compare two strings in extended memory - classic 8052

I'm looking for a simpler code that isn't resource hungry that can compare two strings stored in different locations in the extended memory of a classic 8052 (namely the AT89S52 microcontroller) to ...
1
vote
0answers
15 views

Swapping variable length strings asynchronously with connected microcontroller (Byte-banging)

I have an AT89S52 and an AT89C4051 microcontroller (both in the 8052 family) in which the bit lines of the data bus, one control pin and one status pin are connected together. In code, the data bus is ...
3
votes
3answers
922 views

Simple puts() function in x64 assembly

I'm trying to write as simple I/O library in x64 using linux syscalls ...
1
vote
1answer
93 views

Variadic Functions in NASM Win64 Assembly

Simple variadic function implementation in NASM Assembly. When implemented like I have below: sum.asm ...
3
votes
1answer
1k views

Unsigned integer division ARM Cortex-M0+ Assembly

I am writing a subroutine for unsigned integer division in Assembly. I will call the subroutine DIVU. Inputs: R1 will be the ...
1
vote
1answer
170 views

Guessing game in NASM Win64 Assembly

Still learning Assembly. This program is a simple guessing game to test most of the new things I've learned! Any advice and all topical comments on code optimization and conventions is appreciated! ...
2
votes
0answers
101 views

x64 Windows Assembly - Structs in Assembly

I'm trying to code a simple person database using structs and arrays in assembly. Each person has a firstName, lastName, ...
0
votes
1answer
75 views

gcc constant time implemenation [closed]

I need to make the following function time constant - I have already removed if statements and have written it down to one line in the loop. ...
4
votes
1answer
151 views

Main loop in assembly for a Brainfuck interpreter

I have written 2 Brainfuck interpreters, one in C++, then another in C++ with Assembly inner loop. My interpreter code can be found here (C++/ASM, requires MSVC and MASM) and here (C++). Both are ...
2
votes
1answer
128 views

Routine for 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 ...
4
votes
1answer
217 views

Hex Dump Utility in x86-64 Assembly: Version 1.1

I recently posted a code review and received some very useful feedback. I have spent some time implementing the suggested improvements/fixes, and wish to post a follow up review, with the new and ...
6
votes
2answers
358 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-...
3
votes
2answers
104 views

Disassembler for intel 8080 v2

As many suggestions were given for the code I posted here, I decided to show you the new version for review. I Removed the OpenCatalog class, ...
10
votes
2answers
239 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 ...
10
votes
1answer
1k views

string length in x64 assembly (fasm)

Please critique this very, very basic routine which returns the length of a given char buffer or "string." ...
2
votes
1answer
84 views

Optimizing reverse movmskb code

I have some code that performs (nearly) the opposite function of a pmovmskb. It takes as input a 16-bit bitfield and expands it into 2 xmm registers. (I'm limited to working with AVX1 code). The ...
5
votes
1answer
79 views

Console TicTacToe implementation

I am new to assembly and I want to know how I can improve this implementation both by speed and/or binary size optimization and making code to read and support easily. Platform: Linux, x64 Assembler:...
1
vote
0answers
873 views

MIPS Assembly Program to access elements in the 4x4 matrix, row or column-major oder

This MIPS Assembly program will make you access the elements in the 4x4 matrix in either row or column-major order i.e. accessing all elements row by row or column by column. Output is posted below ...
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....