x86

ICEBP assembly instruction

坚强是说给别人听的谎言 提交于 2021-01-29 05:19:41
问题 As a workaround with x86 instructions, I used an opcode looks like .byte 0xf1, 0xc1 and tried to execute that inside gdb. the disassembly of that line shows f1 icebp So, when first byte which is F1 is fetched it is recognized as an instruction called icebp . This is known to be an undocumented instruction. The only thing I found in the SDM, is a footnote in INT sections saying The mnemonic ICEBP has also been used for the instruction with opcode F1 Continuing with gdb, it says Cannot access

Passing parameters to a function — push or registers [duplicate]

半腔热情 提交于 2021-01-29 05:14:00
问题 This question already has answers here : What are the calling conventions for UNIX & Linux system calls (and user-space functions) on i386 and x86-64 (4 answers) Where is the x86-64 System V ABI documented? (3 answers) Why does Windows64 use a different calling convention from all other OSes on x86-64? (4 answers) Closed 5 months ago . I want to write a function that does something like: def addme(x, y): return x + y I know there is already an instruction for this, but I'm practicing how to

Flush iCache in x86

让人想犯罪 __ 提交于 2021-01-29 04:59:15
问题 Is there anyway I can flush iCache in x86 architecture ? Like WBINVD which will invalidate and flush all the cachelines in data cache. 回答1: According to the docs, wbinvd flushes and invalidates all caches , not just data and unified caches. (I'm not sure if that includes TLBs if you ran it with paging enabled.) What are you trying to test? L1i miss / L2 hit for code-fetch? I don't think it's possible to purposely flush just the I-cache without also flushing all levels of cache. You could

How do I negate a 64-bit integer stored in a 32-bit register pair?

允我心安 提交于 2021-01-29 03:14:56
问题 I've stored a 64-bit integer in the EDX:EAX register pair . How can I correctly negate the number? For example: 123456789123 → -123456789123 . 回答1: Ask a compiler for ideas: compile int64_t neg(int64_t a) { return -a; } in 32-bit mode. Of course, different ways of asking the compiler will have the starting value in memory, in the compiler's choice of registers, or already in EDX:EAX. See all three ways on the Godbolt compiler explorer, with asm output from gcc, clang, and MSVC (aka CL). There

How to convert ld -Ttext option to a linker script?

一个人想着一个人 提交于 2021-01-29 03:02:58
问题 I've found this tutorial on creating an operating system, and I'm trying to convert the linking part in the make file into a linker script. Here is the tutorial: https://github.com/ghaiklor/ghaiklor-os-gcc Here is the make file: SOURCES = $(shell find cpu drivers include kernel libc -name '*.c') HEADERS = $(shell find cpu drivers include kernel libc -name '*.h') OBJ = ${SOURCES:.c=.o cpu/interrupt.o} ASM = nasm CC = gcc LD = ld -m elf_i386 CFLAGS = -g -ffreestanding -Wall -Wextra -fno

How to convert ld -Ttext option to a linker script?

大城市里の小女人 提交于 2021-01-29 03:02:15
问题 I've found this tutorial on creating an operating system, and I'm trying to convert the linking part in the make file into a linker script. Here is the tutorial: https://github.com/ghaiklor/ghaiklor-os-gcc Here is the make file: SOURCES = $(shell find cpu drivers include kernel libc -name '*.c') HEADERS = $(shell find cpu drivers include kernel libc -name '*.h') OBJ = ${SOURCES:.c=.o cpu/interrupt.o} ASM = nasm CC = gcc LD = ld -m elf_i386 CFLAGS = -g -ffreestanding -Wall -Wextra -fno

Assembly: JA and JB work incorrectly

若如初见. 提交于 2021-01-29 02:45:27
问题 Since my main OS is linux and have project on visual studio, I decided to use online compilers to achieve it. I found this which was suggested by many. So here is my code: #include <iostream> using namespace std; int main(void) { float a = 1; float b = 20.2; float res = 0; float res1 = 0; _asm { FLD a FCOM b JA midi JMP modi midi: FST res JMP OUT modi: FST res1 JMP OUT } OUT: cout << "res = " << res << endl; cout << "res1 = " << res1 << endl; return 0; } My goal is simple, if a is greater

Factorial function in x86 NASM assembly goes wrong

会有一股神秘感。 提交于 2021-01-29 01:54:26
问题 I'm learning assembly language using x86 NASM. I wanted to write a simple recursive factorial function to which I am passing one parameter using EAX register. After that, I want to print my result on the screen but nothing happens. After sitting and staring on my computer I don't have any clue what is wrong with my code. Can you guys help newbie with this problem? I know that the prologue and epilogue of factorial funtion is not required due I'm not using stack but for me code is more

EIP register value goes over 100 bytes

前提是你 提交于 2021-01-28 19:34:53
问题 Hey I am having hard time solving my homework. Then x86 processor executes commands EIP register(counter) value increases by 1 byte or by a few bytes depending on command's type. Which instructions we have to use so EIP value may go over 100 bytes? Answers are: JMP | ADD | SUB | PUSH | JNZ | MUL | CALL | JZ As I get the idea, EIP is special case register which we can't use. It's called Extended Instruction Pointer. And to increase it's value over 100 bytes, we need to find how much each

How does 32-bit MASM mode differ from 64-bit?

十年热恋 提交于 2021-01-28 11:15:06
问题 To write a complete program in 32-bit assembly language using MASM one may start like this, .686 .model flat,c .stack 100h .data number sdword 5 .code main proc mov eax,number ret main endp end main whereas in 64-bit mode the code is written as .data number sdword 5 .code main proc mov eax,number ret main endp end The settings are set to default which led to occur an error while assembling in a 64-bit mode not because the platform is set to Win32, but instead the default entry point