assembly

How is return address specified in stack?

This is what I see by disassemble for the statement function(1,2,3);: movl $0x3,0x8(%esp) movl $0x2,0x4(%esp) movl $0x1,(%esp) call 0x4012d0 <_Z8functioniii> It seems the ret address is not pushed into stack at all,then how does ret work? ...

What does X mean in EAX,EBX,ECX ... in assembly?

Google doesn't show the result, Anyone knows? ...

How to get information from objdump

I encounter a problem when reading information dumped out from an executable file in linux. The information is as follows: 804a0ea: 04 08 add $0x8, %al ... 804a0f4: a6 cmpsb %es:(%edi),%ds:(%esi) I have two questions: what does the address 804a0ea and 804a0f4 mean? the virtual address in the process's...

How to analysis how many bytes each instruction takes in assembly?

0x004012d0 <main+0>: push %ebp 0x004012d1 <main+1>: mov %esp,%ebp 0x004012d3 <main+3>: sub $0x28,%esp If the address is not available,can we calculate it ourselves? I mean we only have this: push %ebp mov %esp,%ebp sub $0x28,%esp ...

output byte value in assembler

I'm a bit ashamed about asking this, but how do i output the value of a byte in assembler? Suppose I have the number 62 in the AL register. I'm targeting an 8086. There seem to be available only interrupts that output it's ascii value. Edit: Thank you Nick D, that was what i was looking for. To answer a couple of questions, i'm actually...

shortest way to do a fetch in X86 assembler?

What is the shortest way to fetch a value from memory in X86 Assembler? ...

random number generation

How to generate random numbers using assembly code in the range 1--4 ? ...

"call" instruction that seemingly jumps into itself

I have some C++ code #include <cstdio> #include <boost/bind.hpp> #include <boost/function.hpp> class A { public: void do_it() { std::printf("aaa"); } }; void call_it(const boost::function<void()> &f) { f(); } void func() { A *a = new A; call_it(boost::bind(&A::do_it, a)); } which gcc 4 compiles into the following as...

Ret Failure with SDL using FASM on Win32

I'm using SDL with FASM, and have code that's minimally like the following: format ELF extrn _SDL_Init extrn _SDL_SetVideoMode extrn _SDL_Quit extrn _exit SDL_INIT_VIDEO equ 0x00000020 section '.text' public _SDL_main _SDL_main: ccall _SDL_Init, SDL_INIT_VIDEO ccall _SDL_SetVideoMode, 640, 480, 32, 0 ccall _SDL_Quit...

What is register %eiz?

In the following assembly code that I dumped out using objdump: lea 0x0(%esi,%eiz,1),%esi What is register %eiz? What does the preceding code mean? ...

The priority of operator * in AT&T assembly language

Hi, there: Here I have a question. What is the priority of the operator * in assembly language? For example: *0x804983c(,%eax,4) Does it mean ( %eax * 4 ) + *0x804983c or *( %eax * 4 + 0x804983c )? Thanks! ...

Why pop takes a parameter in assembly?

popl %ebp It seems the %ebp is unnecessary because the pop operation of stack doesn't need a parameter. Why does it make sense? ...

Intrinsics Vs inline ASM for SSE coding in VC++ 2K8

I've done some inline ASM coding for SSE before and it was not too hard even for someone who doesn't know ASM. But I note MS also provide intrinsics wrapping many such special instructions. Is there a particular performance difference, or any other strong reason why one should be used above the other? To repeat from the title, this is ...

How to keep unreachable code?

I'd like to write a function that would have some optional code to be executed or not depending on user settings. The function is cpu-intensive and having ifs in it would be slow since the branch predictor is not that good. My idea is making a copy in memory of the function and replace NOPs with a jump when I don't want to execute some ...

delete a file in protected mode env(like windows xp)

hi I write a program to delete a file from somewhere of my harddisk in 8086 but when i use int 21h (ah=41h) an error happens and carry set to 1.and I cannot delete that. does anyone know what can I do? I think it should be from protected mode which does not allow my program to delete another file.I want the answer and language is not mat...

Fastest way to calculate a 128-bit integer modulo a 64-bit integer

I have a 128-bit unsigned integer A and a 64-bit unsigned integer B. What's the fastest way to calculate A % B - that is the (64-bit) remainder from dividing A by B? I'm looking to do this in either C or assembly language, but I need to target the 32-bit x86 platform. This unfortunately means that I cannot take advantage of compiler sup...

Subroutine & GoTo design

I have a strange question concerning subroutines: As I'm creating a minimal language and I don't want to add high-level loops like while or for I was planning on just adding gotos to keep it Turing-Complete. Now I thought, eww - gotos - I wouldn't want to program in that language if I had to use gotos so often. So I thought about adding...

How to use c library function fgets in assembly language?

Hi, everyone: As the title described, how to use c library function fgets in assembly language? Indeed, I want to know how to get the file pointer to stdin. Thanks for your reply. ...

Determine 32/64 bit architecture in assembly

I was reading over this question and wondered if the accepted answer might also be a way to determine the architecture. For instance, in asm could I push a WORD onto the stack and then check SP. Compare the new SP to the old SP: Diff of 4 means 32 bit Diff of 8 means 64 bit Am I correct in this thinking? ...

GoogleAppEngine : JAR for enhancer not found, yet ASM is on the classpath

When deploying my application to GoogleAppEngine I'm getting the following message after the upload Exception in thread "Thread-0" You have selected to use ClassEnhancer "ASM" yet the JAR for that enhancer does not seem to be in the CLASSPATH! org.datanucleus.enhancer.NucleusEnhanceException: You have selected to use ClassEnhancer "ASM"...