opcode

execute binary machine code from C

痞子三分冷 提交于 2019-12-17 08:59:49
问题 following this instructions I have managed to produce only 528 bytes in size a.out (when gcc main.c gave me 8539 bytes big file initially). main.c was: int main(int argc, char** argv) { return 42; } but I have built a.out from this assembly file instead: main.s: ; tiny.asm BITS 64 GLOBAL _start SECTION .text _start: mov eax, 1 mov ebx, 42 int 0x80 with: me@comp# nasm -f elf64 tiny.s me@comp# gcc -Wall -s -nostartfiles -nostdlib tiny.o me@comp# ./a.out ; echo $? 42 me@comp# wc -c a.out 528 a

x86 assembly 16 bit vs 8 bit immediate operand encoding

穿精又带淫゛_ 提交于 2019-12-14 01:17:35
问题 I'm writing my own assembler and trying to encode the ADC instruction, I have a question about immediate values, especially when adding 8-bit value into the AX register. When adding 16-bit value: adc ax, 0xff33 gets encoded as 15 33 ff which is correct. But would it matter if adc ax, 0x33 gets encoded as 15 33 00 ? Nasm encodes this into 83 d0 33 which is obviously correct, but is my approach correct as well? 回答1: It's common for x86 to have more than 1 valid way of encoding an instruction. e

Finding Opcodes by length or something else

怎甘沉沦 提交于 2019-12-13 11:02:37
问题 Is it possibile, given a sequence of bytes x86 instructions into a stream of random bytes, to decode their instructions? Are opcodes of a fixed length or is there any way to detect those instructions? 回答1: Is it possibile, given a sequence of bytes x86 instructions into a stream of random bytes, to decode their instructions? Yes. Many kinds of processors do it. It is one of the easiest task they have. Are opcodes of a fixed length No. or is there any way to detect those instructions? The

Invalide OpCode and php sort function

折月煮酒 提交于 2019-12-13 06:01:20
问题 Didn't change anything lately but I started to get the infamouse PHP Fatal error: Invalid opcode 153/1/8 a small php -v showed: PHP 5.3.3-7+squeeze17 with Suhosin-Patch (cli) (built: Aug 23 2013 15:06:16) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with eAccelerator v1.0-dev, Copyright (c) 2004-2012 eAccelerator, by eAccelerator To be honest, I wasn't aware we used eAccelerator before. I think the hoster upgraded php or changed something

APC opcode caching on different file versions

旧时模样 提交于 2019-12-13 00:41:28
问题 We have a single server with several DIFFERENT versions of the SAME web application deployed on it. For instance : www.myserver.com rc.myserver.com alpha.myserver.com We fear that there might be collisions between versions of the same PHP Class. Do APC correctly handle this? If not, how to workaround this? Thanks for your help. 回答1: APC caches based on the path to the class, not just the class name. So as long as each of your versions have their own copy of the class you shouldn't have any

Why does C# compiler emit additional OpCodes in IL?

孤街醉人 提交于 2019-12-12 10:48:19
问题 If I've a method Multiply defined as: public static class Experiment { public static int Multiply(int a, int b) { return a * b; } } Then why does the compiler emit this IL: .method public hidebysig static int32 Multiply(int32 a, int32 b) cil managed { .maxstack 2 //why is it not 16? .locals init ( [0] int32 CS$1$0000) //what is this? L_0000: nop //why this? L_0001: ldarg.0 L_0002: ldarg.1 L_0003: mul L_0004: stloc.0 //why this? L_0005: br.s L_0007 //why this? L_0007: ldloc.0 //why this? L

Can someone explain this directly assembled x86 JMP opcode?

大城市里の小女人 提交于 2019-12-12 10:35:41
问题 At school we have been using a bootstrap program to run stand-alone programs without an operating system. I have been studying this program and when protected mode is enabled there is a far jump executed by directly assembling the opcode and operands as data within the program. This was for the GNU assembler: /* this code immediately follows the setting of the PE flag in CR0 */ .byte 0x66, 0xEA .long TARGET_ADDRESS .word 0x0010 /* descriptor #2, GDT, RPL=0 */ First of all, why would one want

Casting an unsigned int + a string to an unsigned char vector

五迷三道 提交于 2019-12-11 19:29:47
问题 I'm working with the NetLink socket library ( https://sourceforge.net/apps/wordpress/netlinksockets/ ), and I want to send some binary data over the network in a format that I specify. The format I have planned is pretty simple and is as follows: Bytes 0 and 1: an opcode of the type uint16_t (i.e., an unsigned integer always 2 bytes long) Bytes 2 onward: any other data necessary, such as a string, an integer, a combination of each, etc.. the other party will interpret this data according to

How I get the value from the Immediate part of a 32 Bit sequence in C?

谁说胖子不能爱 提交于 2019-12-11 11:58:09
问题 I built a virtual machine in C. And for this I have the Instruction pushc <const> I saved the command and the value in 32 Bit. The First 8 Bit are for the command and the rest for the value. 8 Bit -> Opcode 24 Bit -> Immediate value For this I make a macro #define PUSHC 1 //1 is for the command value in the Opcode #define IMMEDIATE(x) ((x) & 0x00FFFFFF) UPDATE: **#define SIGN_EXTEND(i) ((i) & 0x00800000 ? (i) | 0xFF000000 : (i))** Then I load for testing this in a unsigned int array: Update:

MIPS stack frame (and “addiu” instruction confusion)

巧了我就是萌 提交于 2019-12-11 07:00:35
问题 I'm new to MIPS and am trying to understand the disassembly of a function. (EDIT: it is dynamically linked to /lib/ld-uClib.so.0 and uses some usual libc functions, so I assume it was written in C using the uClibc toolchain, and should therefore have that calling procedure and stack frame, etc.). At the start of the function it does 00400824 <practice_crackme>: 400824: 3c1c0fc0 lui gp,0xfc0 ; ??? 400828: 279c673c addiu gp,gp,26428 ; ??? 40082c: 0399e021 addu gp,gp,t9 ; ??? 400830: 27bd8020