assembly

Debugging a multi-thread programe with "Disassembly view" in visual studio

When I continuously do "step into",it switches between different threads. But how's that scheduled in visual studio,how does it know which thread to activate for next instruction? ...

Process command line in Linux 64 bit

I have problems accessing the process command line from Linux 64 bit Assembly program. To reproduce this with minimal code, I made this 32-bit program which prints first 5 characters of the program name: .section .text .globl _start _start: movl %esp, %ebp movl $4, %eax # write movl $1, %ebx # stdout movl 4(%ebp), ...

How can I set a min value in .Net without using a lock?

I have multiple threads accessing variables. I know how to write spinlocks and use the Threading.Interlocked methods to increment etc. variables. However, I want to perform the equivalent of: a = Math.Min(a, b) or a = a | 10 ... but without using a critical section. Is this possible? I know the 2nd line is possible in assembler, but ...

Get java.lang.IllegalAccessError when accessing the private field of a outside class via ASM Java Bytecode

Hi, in reflection, the private field can be access via getDeclaredField() and setAccessible(true). How to access the private field of a outside class via Objectweb ASM bytecode API? I set to get the private field from something like, via Field current = sourceObject.getDeclaredField(privateFieldName); Field.setAccessible(true); Type so...

Decide if number is negative (in URM machine like language)

Hello! So I'm learning to program in an assembly language for an abstract machine wich is very similar to an URM Machine. An URM machine has 3 basic instructions (or 4 in some literature): To zero a register: Z(r) To increment a register: S(r) To Jump to a line or label if registers r1 and r2 contain the same val...

How to completely suspend the processor?

I'm writing a small bootloader for an x86 based PC. The problem is that the CPU is somehow still active after executing these instructions: sti hlt sti is supposed to disable interrupts for the next instruction hlt is supposed to completely halt the processor Since they're used together, I assumed they would just 'freeze' the compute...

INT 3 (0xCC) - x86 ASM

I've read that the INT 3 (0xCC) is used for software breakpoints. It is set by (for instance) a debugger by overwriting the actual program code in memory. I've also read that INT 3 is a "trap" not "fault" exception meaning the address pushed on the stack is the address of the instruction following the INT3 instruction. How does the debug...

A2004 Problem With MASM32

Hi, I have a problem with the MASM32 assembler The following code is a Hello World example that I copied from the MASM32 tutorial: .model small .stack .data message db "Hello world!", "$" .code _main proc mov ax,seg message mov ds,ax mov ah,09 lea dx,message int 21h mov ax,4c00h int ...

SP (Stack Pointer) Anti-debug Trick - x86

Listing 7.1 The Decryptor of the Cascade Virus lea si, Start ; position to decrypt (dynamically set) mov sp, 0682 ; length of encrypted body (1666 bytes) Decrypt: xor [si],si ; decryption key/counter 1 xor [si],sp ; decryption key/counter 2 inc si ; increment one counter dec sp ; decrement the other jnz De...

GDB: how to see what memory addresses are accessible?

Suppose, in a debugging session I have an address which unfortunately points to some rubbish. And I want to examine memory around it to see what's located near. As expected, the following error occurs: (gdb) x/64 $t5 0x842da7ac: Cannot access memory at address 0x842da7ac So, the question is: is there any way to read a range of add...

how to restrict invoke method

I wonder if there is a way to restrict invoke call to a function? Let me make it clear. [Assembly:a1] Class A { function Af(); } [Assembly:a2] Class B { function Bf(){ //load Assembly a1 //InvokeMember to Af } } After compilation I will have 2 assemblies. Now if I distribute to client, anyone can copy assembly...

Counting the number of bits that are set

I want to count the number of bits in a binary number that are set. For example, user enter the number 97 which is 01100001 in binary. The program should give me that 3 bits are set using MIPS ISA. I am able to achieve this in C, but I don't know how to achieve it using assembly code. Any ideas? Thanks in advance for all the help. ...

Does file extension case matter on assembly source files with .asm extensions?

My goal is to have a rule that file.asm should be built exactly the same as file.ASM (or similar variations e.g. file.[aA][sS][mM]). I would like to avoid stepping on a convention that I'm unaware of. Case-sensitive File Extension Convention Examples: Assembly Files with .S and .s extensions are treated differently under GNU Assembler...

How does file sysem information get stored in memory?

Computers recognize different file systems. My question is, where exactly does this information get stored in a memory device (the specific location if any). Or does it not get stored anywhere & rather an operating system tests the system (memory device) against a known set of file systems (like ext3, ntfs, etc) ? With reference to the ...

What are some tips for optimizing the assembly code generated by a compiler?

I am currently in the process of writing a compiler and I seem to have run into some problems getting it to output code that executes in a decent timeframe. A brief overview of the compiler: 7Basic is a compiler that aims to compile 7Basic code directly into machine code for the target architecture / platform. Currently 7Basic gener...

Is there a way to use expressions evaluated at compile-time with inline asm in gcc?

I have some code that basically needs to use a small expression in an assembly statement, where the expression is fairly trivial like i*4, but GCC doesn't seem to realize that at compile time (tried no -O flag, and -O3). Neither "i" nor "n" constraints work in the following snippet for the third usage. #include <stdint.h> #include <st...

Speed difference between global and object variable

Is it faster to access a global or object variable? In C++, I'm referring to the difference between ::foo and this->foo In x86 assembler, this basically translates to mov eax, offset foo vs mov eax, dword ptr[edx+foo] All data in both cases is expected to be in cache. (I know the difference if any will be tiny, and one shou...

Help understanding x86-64 function preamble

I am experiencing a crash, and while investigating I found myself totally blocked by the following code: 0000000000000a00 <_IO_vfprintf>: a00: 55 push %rbp a01: 48 89 e5 mov %rsp,%rbp a04: 41 57 push %r15 a06: 41 56 push %r14 a08: ...

Are there any good, modern, online guides to hand optimizing assembly code?

I'm working on some code which contains some (compiler generated) chunks of assembly code that we've identified are speed bottle necks. I know enough about assembly to muddle through and look for manual optimizations - I'm wondering, though, if there are any good, online guides that offer reusable techniques to be used in hand-optimizi...

why does this give a segmentation fault? it should just exit

Hi, I am trying to learn low-level development. By putting 0 in ebx and 1 in eax (for exit() syscall) and calling int 0x80, it should exit the program. I have a simple c program that runs fine, but when I paste this in, instead of exiting as expected, I get a segmantation fault. Why does this happen? THANK YOU! __asm__ ("xor %ebx, ...