Given the following x86 assembly instructions:
mov esi, offset off_A
cmp esi, offset off_B
how would I get the offsets (the second operand) at runtime ? This is the scenario: A program (injected into the process at runtime) replaces the offsets with a few of its own, resulting in:
mov esi, offset off_X
cmp esi, offset...
Hi there:
I have a question as described: how to perform rotate shift in C without embedded assembly. To be more concrete, how to rotate shift a 32-bit int.
I'm now solving this problem with the help of type long long int, but I think it a little bit ugly and wanna know whether there is a more elegant method.
Kind regards.
...
I'm browsing through OpenJDK sources and cannot find the place where optimized code is replaced.
I wonder how this can be done in protected mode, isn't it some kind of selfmodifing code which should be prevented by the OS?
...
I'm writing a performance-critical, number-crunching C++ project where 70% of the time is used by the 200 line core module.
I'd like to optimize the core using inline assembly, but I'm completely new to this. I do, however, know some x86 assembly languages including the one used by GCC and NASM.
All I know:
I have to put the assemble...
Hi, I have 2 simple, but maybe tricky questions. Let´s say I have assembler instruction:
MOV EAX,[ebx+6*7] - what I am curious is, does this instruction really actually translates into opcode as it stands,so computation of code in brackets is encoded into opcode, or is this just pseudo intruction for compiler, not CPU, so that compiler ...
This is probably trivial, but for some reason I can't it to work. Its supposed to be a simple function that changes the last byte of a dword to 'AA' (10101010), but nothing happens when I call the function. It just returns my original dword.
__declspec(naked) long
function(unsigned long inputDWord, unsigned long *outputDWord)
{...
In assembler:
.globl _test
_test:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
pushl %eax
call printf
popl %ebp
ret
Calling from c
main()
{
_test("Hello");
}
Compile:
gcc -m32 -o test test.c test.s
This code gives me illegal instruction sometimes and segment fault other times.
In gdc i always get illegal instruction, this ...
How can I convert a number contained in a string from any base to any other base?
Bases can be anything i.e.: 2, 16, 10, 4, 8, 9.
I'm expecting the user to enter the base number. The user will enter the output base (the base to be converted to). The user will enter the number he wants to convert.
Pre thoughts:
I will save the input b...
Everything I've seen on *nix has been a set of abstractions off hardware, but I'm curious as to how the hardware works.
I've programmed in assembly, but that's still only a set of abstractions.
How does a processor understand assembly opcodes (as bytecode)?
How do device drivers work (with an explanation at a lower level (of abstracti...
If a large number is subtracted from a smaller number then borrow is needed. The carry flag plays the role of borrow during the subtraction operation.
Now suppose we want to subtract 56 from 66, obviously the borrow is needed and carry flag will be set. Now how this subtraction is performed to get the result -10, how computer will distin...
Write an Assembly Language program named “count letters” that counts the occurrences of all small and capital letters in given below string and then prints the result in the format (Caps, count:: Small, count). String is “bcAdBDeCEad” and it should print this result (Caps, 5:: Small, 6). The program should take address of the source stri...
Hi everyone:
I'm puzzled by this problem when writting an ARM assembly simulator in C. I've found some similar questions in the forum, but none of them explain how to set the carry flag just using the relationship between two operands and the result.
Any reply is appreciated. Thanks in advance.
Regard.
...
I'm in middle of rewriting my assembler. While at it I'm curious about implementing disassembly as well. I want to make it simple and compact, and there's concepts I can exploit while doing so.
It is possible to determine rest of the x86 instruction encoding from opcode (maybe prefix bytes are required too, a bit). I know many people ha...
Let's say we use NASM as they do in this answer: how to write hellow world in assembly under windows.
I got a couple of thoughts and questions regarding assembly combined with c# or any other .net languages for that matter.
First of all I want to be able to create a library that has the following function HelloWorld that takes this par...
Hi, I played around with buffer overflows on Linux (amd64) and tried exploiting a simple program, but it failed. I disabled the security features (address space layout randomization with sysctl -w kernel.randomize_va_space=0 and nx bit in the bios). It jumps to the stack and executes the shellcode, but it doesn't start a shell. The execv...
How do I get Intel and AT&T assembly syntax highlighting in TextMate?
...
Hy there,
I've a problem in assembly language that i got to access element of an array... suppose an array contains weeks day... like sun,mon,tues,wed.... i have to access 2nd index of the array... pls help me...
...
I want to know what is the standard way for writing a -simple- kernel to be compiled on NASM?
To get it clearer:
I was able to define the code block with all the following ways:
[segment code]
[segment .code]
segment code
segment .code
[section code]
[section .code]
section code
section .code
I need to know what is the standard way ...
What is the assembly language variable bl? How many bits does it hold? Is it a part of a larger variable like EBX?
...
I need to write a tool that lists the classes that call methods of specified interfaces. It will be used as part of the build process of a large java application consisting of many modules. The goal is to automatically document the dependencies between certain java modules.
I found several tools for dependency analysis, but they don't w...