Questions tagged [assembly]

17115 questions
1

votes
1

answer
1.1k

Views

What does Znwm and ZdlPv mean in assembly?

I'm new to assembly and I'm trying to figure out how C++ handles dynamic dispatch in assembly. When looking through assembly code, I saw that there were 2 unusual calls: call _Znwm call _ZdlPv These did not have a subroutine that I could trace them to. From examining the code, Znwm seemed to return...
user2999870
1

votes
1

answer
138

Views

What is the difference between calling “ret” vs calling the sys_exit number assembly gcc

In gcc assembly, the main function can either return or exit, where both work. Here I have two programs, where one exits with a syscall int $0x80, and the other simply calls ret. What is the difference? .data hello: .string 'Hello, World!' .globl main main: push %rbx movq $hello, %rdi call puts pop...
Riolku
1

votes
1

answer
468

Views

Assembly - How to set graphics mode in UEFI (No VGA, No BIOS, Nothing deprecated)

Tools I'm using: nasm, qemu-system-x86_64. Operating System I'm on: Windows 10. So I checked out the 'Real Mode OS Warning' at https://wiki.osdev.org/Real_Mode_OS_Warning What the article seems to imply is that everything can be done without using BIOS interrupts whatsoever. I know how to load Long...
Eagterrian Knight
0

votes
0

answer
15

Views

How can I modify or edit data type of DLL file?

I am using an opensource API SDK. I downloaded it and added the assembly code (DLL) into my project so I can use the SDK. However, the sdk has a flaw which is some data type is integer instead of double. So gives me error like below: ApiException: Input string '203.442' is not a valid integer. I can...
Seong E Kim
1

votes
1

answer
32

Views

Segment Base for moffs16/32

I was going through the different MOV instructions and had a doubt regarding one of them. The MOV moffs16/32, AX instruction. According to the Intel manual: 'The moffs8, moffs16, moffs32 and moffs64operands specify a simple offset relative to the segment base, where 8, 16, 32 and 64 refer to the siz...
D Kar
1

votes
1

answer
49

Views

error A2023 instruction operand must have size with LGDT instruction

I'm having this error mentioned above in the following assembly code and I couldn't find much on the net too regarding this error code. mov ax,main_data mov ds,ax mov bx,gdt_info lgdt [bx] main_data segment use16 gdt_start: c32_gdt GDT d32_gdt GDT gdt_info: dw gdt_info - gdt_start - 1 dd gdt_st...
Rajul
1

votes
1

answer
38

Views

NASM automatically escaping shellcode initialized in .data [duplicate]

This question already has an answer here: Assembly: printf not printing new line 2 answers I am attempting to write a piece of assembly code which will perform operations on some shell code I have initialized in .data My initialization is as as follows: section .data shellcode: db '\x31\xc9\xf7\xe1...
Hosty
1

votes
2

answer
135

Views

Implementation of a floating point library of any precision

I have to implement floating point library of any precision so the exponent and mantissa must be an infinitely positive integer. Later I have to create adding and subtracting functions etc. using the processor's x86 capabilities. I have to use C++/C (I can use assembly inserts) and I can use ready-...
dida1007
1

votes
1

answer
36

Views

What does a LD statement passed a single argument do when the HL register is used as a 16-bit accumulator?

I'm learning z80 assembly. I'm using the Zaks textbook 'Programming the Z80,' and he includes the following as an elementary example of 32-bit addition after introducing how to use the HL registers as an accumulator for 16-bit operations: LD HL,(ADR1) LD BC,(ADR2) ADD HL, BC LD (ADR3) LD HL,(ADR1+2)...
Duncan W
1

votes
1

answer
34

Views

How do the hex numbers after a jump instruction translate into a memory address?

I have this in my code disassembly: I see the jump instruction code E9, but how the numbers after E9 translate into the memory address shown?
Arush Agarampur
1

votes
1

answer
35

Views

Why does int 10h not work after reading sectors with int 13h?

I want to write a simple bootloader. However, after reading 2 sectors from disk my boot sector can't print strings with int 10h, ah=0Eh It works before I call int 13h, ah=02h My Code: ;------------------------------------------------------------------------------- ; boot.asm - First boot sector ;---...
Grevak
-1

votes
0

answer
17

Views

Calling an ELF object from x86 assembly

I'm trying to call an ELF from assembly I created an assembly file with a simple print code and assembled it into an ELF .o file I linked this file using ld to the my bootsect.asm file(with offset of 0x1000) ld -o kernel.tmp - Ttext 0x1000 kernel_entry.o objcopy - O binary kernel.tmp kernel.bin then...
IAS0601
1

votes
2

answer
1.4k

Views

How can I find physical address of my files on hard disc

Suppose, I save a file on my hard disc drive(for example c:\abc.txt) that system file of my drive is in system file FAT32 or NTFS, I want to find physical address of this file for example sector number XXXXX to sector number yyyyy. please help me.
Ehsan
0

votes
0

answer
5

Views

Writing simple MAL microprogram

I need help writing a simple MAL microprogram that will push values 1, 2, and 3 to the stack. Am using Mic1MMV.jar as emulator to write a simple .mal file for that program.
key.m
1

votes
2

answer
288

Views

Targeted architecture of .NET assembly using Mono.Cecil

Can I find whether a .NET assembly has been specifically build for 32 or 64 bits using Mono.Cecil? Or any other way of finding out without having to load the assembly first.
David Rutten
0

votes
0

answer
9

Views

Generated assembly code contains a series of jump commands to next memory location, what is the purpose

I was looking through the generated assembly from my compiler and noticed a series of jump commands that just go to the next memory address listed. I was wondering what the heck the purpose of that is. 0000000100000c95 cvtsd2ss %xmm0, %xmm0 0000000100000c99 callq 0x100000ee0 000000010000...
jergp
1

votes
2

answer
1.3k

Views

Wait for keypress Assembly NASM, Linux

I'm working on a Hello World in Assembly for x86-64. I have managed to create one that finishes when Enter key is pressed, but I have to finish it when ANY key is pressed. This is the code for waiting the ENTER Key: mov rax, 0 mov rdi, 0 mov rdx, 1 syscall I can't use any int xh or something like t...
Guolf3377
1

votes
1

answer
1.2k

Views

How to package multi module in a zip file?

I have a multi module project. Each module is packaged in a jar/war file in his own /target folder. I want to take every module jar/war files and some config files, and put everything in a zip. How to do that? I try with assembly plugin, but all i've managed to do so far is a zip of each module in...
Lempkin
1

votes
2

answer
234

Views

What is meant by memory-mapped video?

What does memory-mapped video means? For example, on a x8086 Intel CPU, it has a 20 bit address line. Does this memory-mapped means some of the x8086 address lines are hardwired to the video adapter card?
thirstForKnowledge
1

votes
1

answer
304

Views

Is it good or bad to use BIOS interrupts for protected mode?

I have made a very basic boot loader based on MikeOS boot loader ( Link ). I'm using NASM and QEMU for assembling and testing. And I'm trying to enable protected mode for my OS. So, I started searching web for more details and to know more about BIOS interrupts. I came across wikipedia and read an a...
1

votes
2

answer
557

Views

BGE Instruction ARM

This test asks to branch under the condition 'BGE' branch to a label. The values stored in my registers being compared are: LDR r0,=0X3 LDR r1,=0X8F CMP r0,r1 BGE a_label SUBS r1,r1, #0XC9 I expected it to branch but somehow 0X8F isn't greater than 0X3. Emulating my code on Keil proves this. Im wond...
MangoKitty
1

votes
1

answer
48

Views

How to keep assembly files with --save-temps when multiple targets use the same source file?

If I compile the C++ program /tmp/src/main.cc #include int main() { #ifdef demo1 std::cout
Erik Sjölund
1

votes
1

answer
51

Views
1

votes
1

answer
70

Views

Direction flag usage in 8086

I have read in my book that when the SI register is less than the DI register (in string manipulation), then the direction flag equals 0 else the direction flag equals 1. But I have also read that instructions normally don't change the direction flag, so what is the exact usage of it? Should we set...
jack.math
1

votes
1

answer
149

Views

How to get lower and higher 32 bits of a 64-bit integer for gcc inline asm? (ARMV5 platform)

I have a project on armv5te platform, and I have to rewrite some functions and use assembly code to use enhancement DSP instructions. I use a lot of int64_t type for accumulators, but I do not have an idea how to pass it for arm instruction SMULL (http://www.keil.com/support/man/docs/armasm/armasm_d...
Yevhen Tsyba
1

votes
2

answer
52

Views

What does “#APP” in the assembly file generated by compiler mean?

I wrote the following code: // a.c #include #include #include _Noreturn void _start() { register int syscall_num asm ('rax') = __NR_exit; register int exit_code asm ('rdi') = 0; // The actual syscall to exit asm volatile ('syscall' : /* no output Operands */ : 'r' (syscall_num), 'r' (exit_code)...
JiaHao Xu
1

votes
3

answer
167

Views

How does an the ARM branch instruction address work?

I know that an ARM instruction is 32 bits in size and therefore in memory it take up 4 memory locations (each location can store 8 bits) But am confused on how a branch instruction address works When using e.g. a Branch instruction 4 bits are used for the operation 4 bits for the condition 24 bits...
ryandaniels
1

votes
1

answer
102

Views

About data hazard and forwarding with beq in MIPS?

Why the first add needs forwarding? # stage: add $1, $2, $3 # WB add $4, $5, $6 # MEM nop # EX beq $1, $4, target # ID Since beq needs the $1, if the first add is about to execute WB-stage, isn't that no forwarding needed since beq at ID-stage, which is about to read the r...
BinaryTreeee
1

votes
2

answer
72

Views

optimisation advice on value clamping in a loop

I have a tight loop exactly like what Chandler Carruth presented in CPP CON 2017: https://www.youtube.com/watch?v=2EWejmkKlxs at 25 mins in this video, there is a loop like this: for (int& i:v) i = i>255?255:i; where v is a vector. This is exactly the same code used in my program which after profili...
james
1

votes
1

answer
149

Views

How is C cross platform?

C language is ultimately compiled to machine specific assembly language. Then how can C be cross platform if every processor has its own assembly language syntax? If I write an operating system kernel in C then how can I make it run across a variety of processors?
Abhishek Sharma
1

votes
1

answer
60

Views

What is the Irvine32 library and why do we use it?

I want to know that the Irvine32 assembly language library is. I want a definition and also why we use this library.
My Themes Cafe
1

votes
2

answer
64

Views

How can I compare the first character of a string with another character in x86-64 assembly?

I have an initialized string 'Hello, World!' from which I would like to extract the first character (i.e. 'H') and comapre it a character that is passed into a register at run time. I have tried comparing the first character of 'Hello, World!' with 'H' through the following code: global start sectio...
mooncow
1

votes
1

answer
46

Views

gcc mingw gives garbage output when combining with assembly

My gcc:Thread model: posix gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) I'm trying to create a simple application which sums two numbers with two files saberi.c and saberi.s using gcc and intel syntax where saberi means sum. saberi.c #include int saberi(int a, int b); int m...
kingW3
1

votes
2

answer
76

Views

NASM floating point - invalid combination of opcode and operands

I am trying to compile the following code sample (NASM syntax) from this article on x86 assembly floating point: ;; c^2 = a^2 + b^2 - cos(C)*2*a*b ;; C is stored in ang global _start section .data a: dq 4.56 ;length of side a b: dq 7.89 ;length of side b ang: dq 1.5 ;opposite angle to side c (a...
Jet Blue
1

votes
1

answer
47

Views

Previously faulting unaligned calls now working?

I'm not sure if I'm delusional, but I'm near certain calls used to fail on System V Linux x86_64 if they weren't aligned upon entry (i.e. you'd purposely disalign the stack before a call so it's aligned upon entry). For example (this now works): .data str: .asciz 'string literal' .text .globl main m...
oldjohn1994
1

votes
2

answer
60

Views

Combining two assembly files together with both text and data section

I have two assembly files, a.s and b.s I want to combine both of them and create a new assembly file c.s The file c.s should have all the code in .text of a.s and then all then code in .text of b.s I want to do the same thing with .data section # File a.s VSUB.F32 S4, S5, S6 .data .word 0x10000000 #...
Amardeep reddy
1

votes
1

answer
39

Views

Could you explain what mmap function do?

What does it do this assembly code? I've analyzed code and stopped at this moment. EDX is arg prot. ECX is arg length. ESI is arg flags. Am i right? But anyway i can't understand what does it do. seg000:00000057 push ebp seg000:00000058 xor ebp, ebp seg000:000...
LOGA
1

votes
1

answer
52

Views

Linking a program using printf with ld?

I'm getting a undefined reference to _printf when building an assembly program that defines its own _start instead of main, using NASM on x86-64 Ubuntu Build commands: nasm -f elf64 hello.asm ld -s -o hello hello.o hello.o: In function `_start': hello.asm:(.text+0x1a): undefined reference to `_print...
Fred Rogers
1

votes
1

answer
36

Views

Is the difference between programming model wrt Program Counter and Stack Pointer in case of Assembly?

Processor model I ● Registers  PC – Program Counter  Single data register (accumulator) without name  We will use symbol A to describe operations on this register ● Stack with an unspecified implementation ● Data specified by name or value  More realistic model will...
user366312
1

votes
1

answer
100

Views

Is there no stack segment? Is it simply a concept?

I have been doing some tests and realized that it is wrong to say that the stack segment exists, because when I analyze a binary, I realized that any data type, which is neither in the register nor in static, global or constant, is in the text segment. Do you agree with me about this? I'm really in...
Yuri Albuquerque

View additional questions