Skip to main content

Questions tagged [assembly]

Programming questions are off-topic here. Do not ask questions about how to write code in assembly. However, conceptual questions about how coding in assembly is different may be appropriate. See our help centre for the scope of this site.

Filter by
Sorted by
Tagged with
0 votes
0 answers
20 views

Is memory barrier NECESSARY for memory consistency?

After reading Memory Barriers: a Hardware View for Software Hackers, I came up with a point which I am not sure of its correctness, as posted in the title. I came up with this point because of ...
Xavier Z's user avatar
  • 101
0 votes
3 answers
67 views

How Many Times Would The Assembler Load and Store i

So, this is a snippet of a C code: for (i = 0; i < 20; i++) { a[i] = rand() & 0xFF; printf("a[%d]: %d\n", i, a[i]); } Now, imagine "i&...
River Uzoma's user avatar
0 votes
0 answers
21 views

Testing functions written in aarch64 asm

I had a few functions that were written in C which I had to rewrite in assembly for aarch64. How do I go about setting unit tests for the functions. And what environment would I require to do the same....
Q Tw's user avatar
  • 1
2 votes
1 answer
76 views

Calculate the CPI of a program

...
First_1st's user avatar
0 votes
1 answer
73 views

How do you tell whether a binary number is positive or negative?

Consider the figure in Exercise 2. If the current machine code that executes is 0x214bfffd and the values of the registers in the processor are as shown below, what is then the value of the input WD3 ?...
First_1st's user avatar
0 votes
1 answer
40 views

What is the reason or advantage of having special purpose status flags for the result of comparisons? [duplicate]

The C semantics treat the result of a comparison or any true/false operation as just an int ...
CPlus's user avatar
  • 207
0 votes
2 answers
642 views

How do you convert this x86 assembly program to binary

I'm trying to convert a x86 assembly language program to binary. I have read a 1979 Intel 8086 manual and so understand the basic architecture, however I am still unsure as to how to convert this. ...
Hannah's user avatar
  • 1
7 votes
6 answers
4k views

How AlphaDev improved sorting algorithms?

On the 7th of June 2023, Google DeepMind released an article about AlphaDev. AlphaDev is an evolution of AlphaZero (used to beat world champions at Go, Chess and Shogi), and it can produce assembly ...
nico263nico's user avatar
0 votes
0 answers
75 views

I'm having trouble storing the value in R0 into the correct memory location (LC-3 Assembly)

Here is my LC-3 Assembly code. It is designed to add up the 10 values in x3100 through x3109 and store them in x310A. It correctly adds the values, storing the total in R0, however I cannot seem to ...
Leo's user avatar
  • 1
1 vote
1 answer
229 views

Why do we shift by three in RISC-V loops?

In this youtube video, the instructor explained some basic code in RISC-V assembly, but i didn't understand why in the first line, he is shifting i by 3. Why do we have to multiply it by 8?? I feel ...
Denis's user avatar
  • 111
1 vote
3 answers
182 views

In theory, is it impossible, or possible (although ridiculously impractical), to inline recursive functions?

In an older question I asked about stack, the statement came up that recursive functions cannot be inlined (link). I am interested in whether this statement is actually true or not. I understand that ...
BipedalJoe's user avatar
1 vote
2 answers
163 views

Stack Program Counter

I am trying to understand stacks a little better. I don't understand why the content of the program counter is saved on the stack for the function call (call), but not for a jump (jmp)? can someone ...
DanielJackson1's user avatar
9 votes
2 answers
5k views

Why is static recompilation not possible?

I'm researching static recompilation but there doesn't seem to be too much information about the subject. I've heard that dynamic recompilation (emulation) can be up to 6 times slower than native ...
LetsdothisEpic's user avatar
1 vote
1 answer
55 views

Is the executable always loaded to the same place in the text segment?

I am reading a book about data architecture, and I am wondering about the text segment and the memory adresses. In one example(assembly using ARM) where the code was compiled there were adresses to ...
user394334's user avatar
0 votes
2 answers
85 views

Why scopes in general do not have prologue and epilogue instructions?

Data only accessible in a scope, seems to still be maintained by the stack. What is the reason that entering and exiting scopes (in general) does not do the same "prologue and epilogue" ...
user52174's user avatar
0 votes
2 answers
80 views

Is solving Binary String Matching equivalent to Solving All type of string matching?

This might be an irritating, naive question, but please bear with me. If an algorithm/code solves the string matching problem for a binary string, does not it imply that the algo/code actually solves ...
Michael's user avatar
  • 291
1 vote
1 answer
24 views

Decomposing large bit mult or exp into smaller bit operations

Imagine a machine that can only hold N-bit values (N-bit uint). The machine can also calculate the 2N-bit result of two operations: mult, exp. The 2N-bit result is stored across 2 N-bit values (high/...
1m1's user avatar
  • 11
-2 votes
1 answer
55 views

Approximate x*(a/b)^(c/d) using integer arithmetic only (assembler)

0 < x,a,b,c,d < M are all positive integers (uint64). also, a<b if that helps. we have assembler (integer only) operations available (e.g. division only yields integers). we want to ...
imi kim's user avatar
  • 101
-1 votes
1 answer
52 views

Computer Architecture MIPS assembler with predictors

This MIPS code is given: ...
Pol's user avatar
  • 11
0 votes
2 answers
224 views

Are all CPU computations done using registers?

From my understanding, a CPU register is a temporary storage or working location built into the CPU itself. The CPU includes some functional units such as the ALU (which is part of the chip, as far as ...
wrongbyte's user avatar
  • 101
1 vote
1 answer
110 views

Boot Loaders, Boot Sectors, BIOS, and GRUB

Again, I must apologize if this is "easily googlable". I have tried. My understanding is that the BIOS typically looks for the magic number 0x55aa at the end of a 512 byte sector (so bytes #...
prss98408's user avatar
0 votes
2 answers
214 views

Assembly language addressing mode instructions

I am studying assembly language. I feel very difficult in understanding few instruction. ADD R1,R2,[R3] ADD R1, R2, R3 What is the difference between these two instructions. I think second instruction ...
user avatar
0 votes
1 answer
144 views

How do data registers work in assembly programming?

I'm learning assembly programming and I can't seem to get my head around the register usage, as I'm using emu8086 which emulates old 8086 processors. According to 8086 (16-bit architecture) the four ...
Uzair Ahmed Nasir's user avatar
1 vote
1 answer
62 views

What happens if 2 processor try to access the same memory in one clock cycle?

Assume a parralled adder program: CPU0: ADD sum,eax;or LOCK ADD sum,eax CPU1: ADD sum,eax;or LOCK ADD sum,eax If these 2 instructions are issued in the same clock ...
Zackham's user avatar
  • 13
0 votes
0 answers
20 views

Is arithmetic/constants code optimization a function of the Language/Compiler/CPU/ALU/OS and what languages implement such features in itself?

Take the following case ...
newInt1x1's user avatar
0 votes
0 answers
84 views

Can you decompile from code that was written in assembly?

I've been reading a little about decompilers, and I think I get the general idea. I understand that I could start with either assembly or machine code, and then I'd have a decompiler which would ...
Jojo's user avatar
  • 133
0 votes
3 answers
703 views

How does a CPU do function calls?

Besides basic instructions for a general-purpose computer (binary arithmetic, move instruction, and jump on condition), it seems you can't implement a universal turing machine (is that even the right ...
theDoctor's user avatar
  • 113
3 votes
1 answer
451 views

What makes 'interrupt vectors' vectors?

I've recently been learning about interrupt vectors, partly from this Wikipedia page. I've understood that different processors will have different types of interrupts, and the interrupt vector table ...
Jojo's user avatar
  • 133
0 votes
1 answer
50 views

How did 8-bit computers (Intel 8088) iterate numbers beyond 256?

I never recall any problem making FOR loops in BASIC to 10000 on old IBM PC computers, but how does it work at the machine level when the number in the data register is (presumably) limited to a ...
theDoctor's user avatar
  • 113
0 votes
1 answer
263 views

Why are lw and sw byte addressable but jump and beq word addressable?

I am refering to MIPS (32 bits). Is there any particular reason that when loading or storing a word, we address memory in bytes, but when we jump or branch using beq we address memory in words? Thanks!...
pgiouroukis's user avatar
1 vote
0 answers
157 views

Number of stall cycles when there is only EX/MEM pipeline registers or only MEM/WB pipeline register

I am working on a problem which is related to The processor. The problem is the problem 4.12 in the book whose title is "Computer Organization and Design". The problem has the assumption as ...
Hoang Nam's user avatar
  • 111
1 vote
1 answer
881 views

Manipulating stack pointer in assembly

I have written an assembly program to store digits in a stack. And to print the digits I have used loop2: mov ah,2 int 21h sub cl,1 jnz loop2 But this would only ...
kiv's user avatar
  • 339
0 votes
0 answers
99 views

How does the assembler translate english assembly to binary machine code instructions?

My assumptions (please correct me if anything in this part is wrong including wrong usages of jargons) In MIPS instructions, add t1 t2 t3 translates to ...
Acy's user avatar
  • 101
0 votes
1 answer
192 views

Are EAX , EBX registers 64 bit in length in modern processors [closed]

The EAX, EBX and ECX registers on a cpu are they 64 bits for a 64-bit cpu ?
Monu Didi's user avatar
0 votes
0 answers
32 views

Why are registers name in assembly cryptic

Why are registers named so short - EAX, EBX,...etc They could have easily made the names more descriptive rather than encrypted like that.
Amit wadhwa's user avatar
1 vote
1 answer
111 views

Addressing mode in 8086

I'm a beginner learning about Assembly language and I was doing questions where I have to identify different addressing mode in 8086 processor. One such instruction is: mov ah,09h Here the source ...
kiv's user avatar
  • 339
1 vote
0 answers
224 views

purpose of stack segment in assembly language

The code snippet below is the "beginning lines of an assembly language program" used to display a single line string . ...
Tina's user avatar
  • 11
0 votes
1 answer
88 views

What will a given CPU architecture do in the event that we were to invert all of the instruction bits to a given instruction?

Given an arbitrary CPU - Architecture and its instruction set... What would be the outcome of the given inverted instruction within that Architect? For simplicity, let's use an 8-bit CPU architecture ...
Francis Cugler's user avatar
1 vote
0 answers
43 views

How does an assembler manage varying offsets when using a literal pool?

I am trying to write a simple multi-pass assembler. Wikipedia states that: Multi-pass assemblers create a table with all symbols and their values in the first passes, then use the table in later ...
Pop Flamingo's user avatar
1 vote
2 answers
137 views

Why can't we compile 8086 Assembily for all OSs from any OS?

If Mac OS, Linux, and Windows (mostly) all use Intel's 8086 64 bit instruction set, why can't we compile 8086 64 assembly from any operating system to any other operating system? (e.g. compile a Mac ...
maxbear123's user avatar
0 votes
0 answers
146 views

Unbanked access, banked access and common memory access

What are they and what are their differences? Unbanked access Banked access Common memory access [EDIT] This question is originated from my reading of MPLAB XC8 PIC Assembler User's Guide where the ...
KMC's user avatar
  • 101
3 votes
1 answer
205 views

Detecting Data and Control Hazards for a mips 5 stage pipeline

I'm practicing data and control dependencies, but having trouble detecting them. For this example, I'm assuming this pipeline is fully bypassed (with forwarding). I think the only data dependency is ...
User9123's user avatar
0 votes
3 answers
122 views

CPU Registers and Computation

How exactly does the control unit in the CPU retrieves data from registers? Does it retrieve bit by bit? For example if I'm adding two numbers, A+B, how does the computation takes place in memory ...
Pratheek R Pai's user avatar
0 votes
1 answer
74 views

Is it possible to modify the linux assembler in order to modify what fuctions do?

I was wondering if it were possible to modify the linux assembler in order to change the function of "-" to "+" and vice versa. I was also wondering if this would affect the whole system making it ...
david david's user avatar
2 votes
0 answers
85 views

What is "orthogonality" in the context of Instruction Encoding?

What does it mean by "orthogonality" in the context of Instruction Encoding? Why CISC Architecture is orthogonal while RISC is not?
David Roonie's user avatar
0 votes
1 answer
169 views

RAM and ROM confusion

we know RAM contains instruction for we ask computer to do operations we know ROM contains instructions which for computer to work does this mean RAM contains address of instruction sitting in ROM? ...
wannabeprogrammer's user avatar
0 votes
1 answer
367 views

Can a 32-bit processor work with a 64-bit size word?

In a 32-bit byte addressable memory system, each "row" has 4 bytes and each byte has a 32-bit address. My question is: can I read and/or write word of length 64 bits from/to memory? In other terms, ...
OmarAI's user avatar
  • 3
9 votes
5 answers
1k views

Are assembly languages untyped?

I'm writing my Bsc thesis about type systems of various languages and I want to have a short section about assembly languages. Initially I thought I'll bring up assembly as a counter example to ...
A. Sallai's user avatar
  • 243
0 votes
1 answer
1k views

Direct and Associate Cache - Offset, Index, and Tag

I have two questions: ...
Hawkeye's user avatar
2 votes
1 answer
38 views

Names of power-of-two bit operations on bitsets that would not assume any number interpretation

Three commonly used functions when it comes to bit manipulation are : is_pow2: Checking that an integer is a power-of-two (only one bit is set): $00010000 \...
Vincent's user avatar
  • 221