Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [assembly]

An assembly language is a low-level programming language for a computer, microcontroller, or other programmable device, in which each statement corresponds to a single machine code instruction.

-4
votes
2answers
142 views

Performance question - what are the defects of high level programming languages and compilers that makes assembly still a better choice today [closed]

What I want to know is, how can we still make use of assembly today, in productive manners? When assembly outperform C, so it would seem practical to write a section of the project in assembly rather ...
0
votes
1answer
79 views

Registers and Stacks in NASM

So, I am more or less voluntarily learning NASM, and I have problems finding sources that really explain it. Unlike with Java or C# I can't just use google as well, since Assembly just isn't used by ...
-5
votes
1answer
121 views

Why does the C compiler use memory for simple arithmetic operations

Assume the following C code: #include <stdio.h> int main() { int a = 5; int b = 15; return a + b; } Compiling it using gcc creates an assembly code which includes the following: ...
2
votes
1answer
171 views

What is the difference between writing in assembly vs converting high level language into assembly using compiler?

So i heard that in modern operating systems and device drivers, some parts of them are still written in assembly for better memory optimisation and speed but do developers actually write it in ...
0
votes
2answers
219 views

How can I test generated assembly?

I'm working on a C compiler for Linux for the purpose of personal curiosity/fun. How can I test the generated assembly before the compiler is complete enough to do anything useful? For example, if I ...
1
vote
1answer
77 views

Simulating Comparison Without Using Comparison Primitives

In the same way that you can simulate the if statement and functions, I am wondering if there is a way to simulate the comparison operators ==, !=, >, >=, <, <=. For example, in ...
0
votes
3answers
144 views

How to Simulate Control-Flow without using Control-Flow Primitives

Basically, I want to know how to simulate while and if if I'm handling the control flow myself through an array of instructions. The while loop can be simulated by if, as seen with assembly branching ...
-5
votes
1answer
130 views

Why do assembly languages often include symbols as a language feature? [closed]

I wonder why in assembly there are often included symbols as a language feature and what's the purpose of it?
0
votes
0answers
74 views

How to manage dynamically generated variables in Assembly

Along the lines of How v8 JIT compiler manages dynamically changing variables, wondering how you would go about creating dynamically generated variables in assembly. Not necessarily looking for ...
-4
votes
1answer
127 views

Assemblers Used During the Development of a Programming Language?

I am currently designing and developing a programming language from scratch. Mostly as a learning experience. Although it's not entirely related to the question, it's important that you know a little ...
-1
votes
1answer
329 views

How to make compiler portable?

I am writing a simple compiler. I have written lexer and parser and it now generates assembly code from given code. Now I need to write an assembler which generates machine code. But the problem is ...
1
vote
0answers
166 views

How does the BIOS detect the size of installed memory? [closed]

I'm writing a little toy operating system using a mix of C and Assembly (It's not meant to be good/fast, just meant to learn from). I know that I can issue an interrupt (I think it's INT 0x15) to ...
0
votes
2answers
145 views

How does x86 deal with register pairs?

I’ve been reading about older processors (8080, 8086 and that) and i’ve seen that those older 8-bit processors had some 16-bit instructions through the use of register pairs. For example, on the 8080, ...
3
votes
2answers
571 views

How does a CPU load multiple bytes at once if memory is byte addressed?

I've been reading about CPUs and how they are implemented, and some big complex architectures (looking at you x86) have instructions that load from memory during one clock cycle. Since one address ...
0
votes
0answers
85 views

Why does GNU AS use different characters for single-line comments depending on the architecture?

The GNU Assembler as uses different characters depending on the architecture to specify single-line comments, such as # on x86, ; on 29k, or @ on ARM. Moreover, regardless of platform, C-style ...
-1
votes
1answer
115 views

Help With Memory Mapped I/O and Hardware Interrupts for Virtual Machine

I've been working on a 24-bit virtual machine to help me learn more about computers and programming in general and was hoping to find a bit more information on memory mapped input/output and hardware ...
0
votes
4answers
383 views

How to evaluate efficiency of assembler code?

I was coding some functions in C++ and wondered how different versions of those functions would affect generated assembly code. I put different versions into the Godbolt Compiler Explorer Tool and ...
6
votes
1answer
565 views

Why data alignment is used exactly?

Each data type must be aligned to a multiple of some number of bytes, for example a short int must be aligned to a multiple of 2 bytes, and an int must be aligned to a multiple of 4 bytes. But why ...
-3
votes
1answer
168 views

What is Allison's Algorithm?

What is Allison's Algorithm and how does it aid in converting hex digits into ASCII characters? ;algorithm (found online) ADD AL, 90h DAA ADC AL, 40h DAA http://computer-programming-forum.com/...
3
votes
1answer
377 views

Where are the stacks for the other threads located in a process virtual address space?

The following image shows where the sections of a process are laid out in the process's virtual address space: You can see that there is only one stack section (since this process only has one thread ...
1
vote
3answers
190 views

Does an ISA (Instruction Set Architecture) also specify the registers available in the CPU?

I am new to Assembly, and based on my understanding, an ISA (Instruction Set Architecture) specifies what instructions are available for a particular CPU. But does an ISA also specify what registers ...
1
vote
1answer
155 views

Intel Memory Addressing Form

I'm am trying to understand machine code memory addressing for x86, and I've encountered two opposing general forms for addressing (using the ModRM and SIB bytes). Most unofficial resources I consult ...
4
votes
2answers
202 views

When designing an ISA , is it a good design decision to permit a `pop` instruction that does not require an operand to receive the popped value?

A lot of ISAs including x86, x64, ARM, Itanium, have a pop instruction that requires an operand which is usually a register (or, in ARM's case, a register list). In fact, I can't think of an ISA off ...
-9
votes
1answer
3k views

Convert program in Java to Assembler? [closed]

I have to do a program to school in Assembler but we did just a few basic things. Is it possible to write code in Java and convert it to Assembler?
4
votes
2answers
208 views

Criteria for a language (Terra as a tricky example) to be usable for operating system development, and how to meet missing criteria

For example, a language that I was looking at recently- Terra. You can address the question in the context of any language, I'm just most comfortable with Lua so I'm starting from there. The Terra ...
0
votes
2answers
827 views

Difference between assembly code and disassembly listing

Is the disassembly listing generated by a disassembler exactly the same as the assembly code listing that is optionally generated by a compiler during the compilation of C code?
4
votes
2answers
612 views

How does a compiler know the machine language of targeted processor to which the source code has to be converted?

For ex: Two machines have the same compiler and the same operating system. But the two machines have different processors (different assembly instructions).As the compiler was downloaded with respect ...
1
vote
2answers
2k views

Understanding of the Carry Flag Bit

Intel 8085: In my textbook it is said: "Carry Flag - this flag is the carry out from the MSB of the A-register. CY is set after an ADD instruction if carry out was generated from the A-register." I ...
3
votes
1answer
1k views

Difficulties with Two's complement in Assembly

Everything discussed here will refer to Intel 8085 (8-bit architecture). When using two's complement number "conversion" : 1.) If we take SBI 0F (subtraction) for example; immediate value 0F(hex) or ...
3
votes
3answers
2k views

Source of loading value to the register or memory location

When we load a register or memory location with a value (e.g. MVI 3A or MVI 53), what initializes register or memory location with that specific value? It is the CPU who performs the initialization, ...
-1
votes
1answer
64 views

Multiprecision Arithmetic; The Carry Flag

Intel 8085: I'm having big troubles understanding addition or subtraction with more than 16-bit numbers in Intel 8085: 1.) If I execute ADC M instruction then this should happen: (A)<--(A)+((H)(L))...
5
votes
2answers
965 views

Data transfer in assembly language

Moving data in assembly language: MOV B, A If I move content from internal register A to register B, what happens to content of register A? Is it deleted? Stays unchanged?
0
votes
1answer
555 views

x86 lock instruction - simulator

I'm working on simple 8086 simulator. But I'm not sure how to implement lock prefix. I know this prefix used in semaphore implementations. 1) For now I have only 8086 core and no other cores like FPU....
1
vote
4answers
298 views

Is there a standard byte code interface for x86/x64 processors?

I guess the question is about PC based (Windows, Non-Macintosh) processor Architecture Design and open use. Is there a "Standard Interface" (byte-code) for PC machines, aside from processor specific ...
4
votes
1answer
133 views

What is a good way to debug when does a specific value is pushed onto stack in assembly code?

I am currently debugging a very old game (so there is no customer support) that keeps crashing under certain condition and I have found out it is because unsigned short to unsigned int conversion was ...
0
votes
1answer
224 views

assembly - function vs procedure

In assembly language, is there a difference between a function and a procedure? I use them interchangeably but I'm not sure this is appropriate a professional environment.
1
vote
1answer
851 views

Are there system calls like posix in assembly level using int number for windows

I want to write assembly program using windows syscall Interrupt number , so in order to use system call in assembly level using int of sys call, In windows are there kernel calls like posix ...
-2
votes
1answer
842 views

What is 16 bit word's equivalent in decimal?

Question: For a 16 bit word with 6 bits for an opcode How many different instructions could I fit into the instruction set? What is the largest number that I could use as data? Answer:...
10
votes
2answers
410 views

Apollo-11: Using inclusion instead of a linker

Recently digitized and turned into a repo, the original Apollo 11 guidance computer source code has been made available for viewing on Github. In MAIN.agc, the repo author comments that they ...
8
votes
6answers
16k views

“Write an Assembler in C.” Why writing a machine code translator for a low level language in a higher level language?

My Microprocessor class instructor gave us an assignment and said: "Write an Assembler in C." - My beloved Professor So it seemed a little bit illogical to me. If I'm not wrong Assembly Language ...
4
votes
4answers
535 views

Is C is a portable language for new architecture or it is specific for ISA?

How C language is portable to any instruction set (I mean for new architecture). Do we have to write again C compiler for new architecture?
5
votes
2answers
632 views

How does one structure an assembly-language project?

So, I'm taking a MIPS course after returning to school; and we're approaching the point where we begin on our final project. I've always been one for large, well-structured projects: lots of ...
0
votes
1answer
826 views

How assembler converts to machine code 1 and 0 [duplicate]

I know that assembler is the one which converts to machine code. So here in 8085 instruction set LDA has opcode "3A". My question is how assembler convert mnemonics to opcode and finally to machine ...
1
vote
2answers
402 views

What are microcontrollers programmed in most in industry? C or Assembly? [closed]

So recently in school we have started programming klm25z boards using ARM Assembly. I was wondering if in most industry jobs, microcontrollers are really programmed in assembly over C. It seems to ...
2
votes
3answers
186 views

Is there any low level way to get shifted or unshifted bits which results from bitwise operations?

I was playing with bitwise operations and a question about counting true bits of any positive integer value, so I solved the problem with bit shifting, so I just thought if there would be some way to ...
1
vote
3answers
1k views

Operation excution in terms of clock cycles

Typically for a single instrcution, 6 machine cycles are needed: FETCH instruction DECODE instruction EVALUATE ADDRESS fetch OPERANDS EXECUTE oepration STORE result My concern is regarding the fifth ...
0
votes
3answers
997 views

Memory addresses and Assembly

I recently started reading about programming in Assembly. To my knowledge, in Assembly, a programmer, when storing and retrieving their variables, has to specify the address their variables are stored ...
-1
votes
1answer
76 views

Finding register parameters for system calls

By consulting various scattered tutorials and books, I've been able to learn that the 64-bit Linux "exit" system call is 60, and the status value is moved to edi. Similarly, "write" has call number 1, ...
6
votes
1answer
657 views

Does unused code affects the assembly after startup (Memory for example)?

Disclaimer: I come from a PHP background. In PHP, I could have thousands files, which are never loaded, if not needed, due to the autoloader feature (If some code is needed, it would be loaded) How ...
7
votes
1answer
568 views

Unit Testing: Assembler code and different architectures

I am currently unit testing some C code and I am faced with a problem: Within the code there are called functions that contain inline assembler code for the SPARC 8 architecture. Since I am doing ...