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
26
votes
2answers
2k views

Euler's Totient Function in x86 assembly (MASM)

My task was to implement Euler's totient function, and I'm looking for any and all criticism. ...
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 ...
10
votes
1answer
220 views

A 8086 assembly hexdump program

I am trying to learn the 8086 assembly language. So as exercise, I decided to write a hexdump program, that outputs the contents of files in a format similar to Linux hexdump. I am developing under ...
14
votes
0answers
190 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. ...
6
votes
1answer
168 views

x86 FASM assembly Reverse FizzBuzz

This program counts down from 100 to 1 and: If the current number is a multiple of 3 it prints "Fizz" instead of the number If it is a multiple of 5 it prints "Buzz" instead of the number If it is a ...
2
votes
0answers
3k views

Bubble sort using user inputted numbers and size in MIPS assembly

I made this code to take user input, making a specific-sized array and printing user-inputted numbers after being sorted. It works well but I was wondering if there was a way to "shrink" it down. It ...
13
votes
2answers
156 views

Calculating (\$a^2\$ + \$b(2c-d)^2)/(3e)\$ in assembly

I made a simple assembly program to evaluate the function $$f =\frac{a^2 + b(2c-d)^2}{3e}$$ Since this is basically my first ever, I would like to hear what I can improve and know how to use ...
4
votes
1answer
111 views

x86 assembly [fasm] code which takes a number and adds 155 then shifts right

The following program takes a user-inputted integer and adds 155, shifts it to the right twice, and prints the output after the addition, then after the shift. It is written in fasm x86 assembly and ...
5
votes
1answer
64 views

Print which CPU flags are set at the start of the program

This is my first "real" x86 program developed from scratch. Please critique: ...
10
votes
1answer
939 views

Measuring the clock rate of an Intel CPU in C++

I created a short program to directly measure the clock rate of an Intel CPU. It runs, sleeps for a duration specified by the user, and then measures the number of clock cycles and the amount of time ...
3
votes
0answers
257 views

Implementing binary-heap in x86-64 assembly

I'm trying to implement some of the simplest classical data-structures in x86-64 assembly on linux. PRIMARY GOAL: Reduce memory consumption and increase performance (maybe using x86-64 architecture ...
2
votes
0answers
41 views

Write 16x16 bitmap to frame buffer

The following code writes a 16x16 bitmap to a framebuffer using up to AVX2 instuctions. I'm sure it can be improved with AVX512 ...
1
vote
1answer
1k views

Efficient LC3 assembly code to print the numbers leading up to any digit

I'm using an LC3 microarchitecture simulator to write assembly code. I've only been writing assembly for about three weeks, so I am still very new. My goal is to print all the numbers leading up to a ...
1
vote
1answer
60 views

X86-16 Function 01 -> Change destination and/or display pages

This code is intended to be included with X86-16 writing ASCIIZ strings directly to video and is dependent upon some of the declarations in that code. When combined with that code a string declared @ ...
2
votes
0answers
48 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 ...
1
vote
0answers
5k views

MIPS even or odd detection program

I am learning MIPS as a part of my Computer Organization class at school and I am writing a simple program that reads in a positive integer from the user and tells the user whether the number is even ...
2
votes
0answers
52 views

String to long double conversion using FBLD

I always wanted to try fbld x87 instruction to aid to convert string to floating point value. I sure a chance to face this instruction in disassembly of all the ...
1
vote
1answer
46 views

A console application that uses the Rich Edit Form Input procedure

This console application uses the Rich Edit Form Input procedure for which you can find the source here. It presents the user with a dialog that has 5 input boxes and 2 buttons. The dialog is drawn ...
4
votes
1answer
106 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....
2
votes
2answers
174 views

Checksum computation in x86_64

This is an implementation of the TCP/IP checksum computation as described in https://tools.ietf.org/html/rfc1071. The function is writen in DynASM, an assembler preprocessor that is part of LuaJIT. I ...
5
votes
3answers
1k views

Printing binary string in assembly

I'm writing a program to print binary string of a hardcoded word. Here is how it looks like currently: main.asm ...
9
votes
3answers
594 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 ...
6
votes
1answer
100 views

FAT16A/B disk and file variable initialization program for MS-DOS

Typically I use DOS file services for disk access, so that I don't have to care if the files are on a network drive, or CD-ROM, or in a mounted DOSBox folder. In the future, however, I would like to ...
14
votes
2answers
831 views

Parsing Z80 assembler in C++

I'm just starting with C++ (I have worked with C for more than a year) and as a first program I wanted to write a cleaner version of my Z80 assembler I had written in C before, this time trying to do ...
2
votes
0answers
44 views

Generic prologue/epilogue for interrupt driven Atmega328P system

My thinking is that with every application, there are a few fundamentals indicative of all interrupt driven systems. Contrary to popular opinion, assembly programs can be as maintainable as HLL's, ...
2
votes
1answer
6k views

MIPS assembly string to int function

I have written the following code for a programming assignment. I would appreciate some help to improve this code and see if it meets all the requirements and criteria. I would like to improve my loop ...
1
vote
0answers
363 views

Assembly Language (AVR) Button Scanning/Debouncing Routine

So, I'm very new to assembly language programming for microcontrollers. I'm using an AVR XMega A3BU X-plained board, and I've got a program where I need to interface with 7 buttons. 3 of them are on ...
6
votes
1answer
175 views

Simple fruit machine game for the Sinclair ZX80 (old ROM)

I've developed a quick Sinclair ZX80 game using z88dk. I used the beautiful C programming language along with a small amount of Z80 assembly. Notes: I'm using integer maths, which is faster and more ...
5
votes
1answer
2k views

Adding integers together

I am trying to write an assembly program that takes integers and adds them all together and spits out the sum. However my code currently just has the same block of code repeating. How can I turn this ...
6
votes
1answer
945 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 ...
1
vote
0answers
18 views

Real-time timekeeping logic for ATmega16A

As part of a clock I'm building based on an ATmega16A, I wrote some assembly code to handle setting up the timer for a 32.768kHz crystal and handle second/minute/hour/day updates. Here are the ...
1
vote
0answers
118 views

Sending data from UART to microcontroller via AT89C2051 functioning as a UART/SPI bridge

I have an unusual setup. I have an AT89S52 microcontroller in which its UART is used by the PC. I needed a way to make a second UART based device work with it, so what I decided to do was make a UART ...
2
votes
0answers
453 views

Computing the square root of a number using binary search

This is implemented in MIPS assembly. I've hard-coded the initial guess, as I haven't figured out how to allow the user to input a negative or non-negative integer to then display the result back to ...
1
vote
0answers
71 views

RFID card reader validation routine in 8051 assembly

I came up with the following code to check to see if the last 2 bytes of a 12-byte value read in from a RDM6300 card reader is actually the checksum of the first 10 bytes. ...
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 ...
6
votes
1answer
868 views

x64 Assembly zeroing an array (8 bytes at a time)

Is there a better way of implementing this other than using simd instructions? What is the best way of dealing with arrays not divisible by 8, as in the code where if there are less than 8 bytes left ...
6
votes
3answers
360 views

Fast bitswap in assembly

Can the following code to swap two bits be optimized? ...
5
votes
1answer
985 views

AVX assembly for fast atan2 approximation

I'm writing a fast atan2 approximation, and would like some feedback on my assembly in particular. I know one of the first things is that people will question why I'm using inline assembly instead of ...
3
votes
1answer
46 views

Two bidirectional Software UARTs with AT89S52 microcontroller

I have learned one way to read from a serial port via software UART is via timer interrupts. I have made an implementation of receiving data from one serial port below. I haven't tested it yet because ...
4
votes
1answer
286 views

8051 RFID reader for Atmel microcontroller

I am currently using an AT89S52 microcontroller for a major project that involves a use of an RFID reader that outputs data in a serial format (9600 baud, no parity, 8 data bits, 1 stop bit). The ...
5
votes
1answer
123 views

Summing all primes below 2,000,000 - Project Euler #10 in Assembly

I am currently learning assembly for university, and I'd like to hear some feedback concerning what I've written. Currently I have implemented Problems 1, 2, 3 and 10 from ProjectEuler. The goal is to ...
6
votes
2answers
448 views

Shifting an 128-bit integer consisting of four 32-bit integers

For a little project of mine I have written two versions for shifting a 128-bit unsigned integer consisting of four 32-bit unsigned integers in x86 assembly. I cannot really decide which is better in ...
10
votes
3answers
367 views

SSE loop to walk likely primes

This is a continuation of a discussion that was started here. While there are some interesting points there about instruction timing and latency, it is not necessary to read that Question to ...
3
votes
1answer
108 views

Find the number in an array which is closest to an given number

Exercise from an Assembly course I'm enrolled in: Find closest number. Add the following into the data section: nums dd 23h,75h,111h,0abch,443h,1000h,5h,2213h,433a34h,0deadbeafh ...
1
vote
0answers
56 views

Legacy boot E820 entries written to low memory

In another post of mine, there was some discussion about a small area just above (see end of page @) BDA (500H - 534H) that handles DOS print screen. As not to ...
4
votes
1answer
176 views

E820 display using X86 legacy boot sector or DOS 6.22 com file

The time has come in the development of the initialization process of my OS to get details about memory. I could have done this a lot simpler as both systems I use, have 4 gigs, but on every system ...
2
votes
1answer
54 views

Asserting CPUID and enabling A20

At this point, the user will probably want to know if this system is Long Mode capable, which is indicated by the word CPUID in green. This is determined by attempting to toggle bit 21 in EFLAGS. <...
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 ...
4
votes
2answers
339 views

BIOS Video Service INT 10H (functions 9 and 13H) functionality

On the way to protected or long modes, real mode code needs to provide a lot of visual feedback. Video services INT 10H provide this functionality, but lack ...
4
votes
2answers
103 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, ...