assembly

Assembly language function template. - A simple lazy convention?

Hi geeks~ I am developing some functions in assembly language, at the beginning, my functions passing the parameters in the following 3 manners: registers global data in .data section through stack Now I found that the mix of the above 3 manners is making things complicated. And I always fall into the situation where I have to scrat...

Questions about the GNU linker editor "ld" ?

I have 2 obj files assembled with GNU as, they are: a.o : my major program b.o : some utility functions a.o doesn't have an entry point. The final linked file will be loaded into memory and the execution will jump to its very beginning loaded address, where is the first instrucion of a.o. Now I want to link them together with GNU ld...

Conditional move problem

Code fragment from Assembly exercise (GNU Assembler, Linux 32 bit) .data more: .asciz "more\n" .text ... movl $more, %eax # this is compiled cmova more, %eax # this is compiled cmova $more, %eax # this is not compiled Error: suffix or operands invalid for `cmova' I can place string address to %eax using movl...

Where did int 3 go?

Hi, In 32 bits mode programming I used to employ int 3 in my programs a lot for stopping at a given location with the debugger (embedding the instruction in the source). Now in 64 bits it seems to not be working, producing a very ordinary SIGSEGV under gdb and destroying the program beyond hope ("Program terminated with signal SIGSEGV,...

How to convert ASM to read-able code?

I have an exe which I have opened with PE Explorer Disassembler. Now I can see the asm code, which looks like that: push ebx push esi mov ebx,eax mov eax,[ebx+38h] push eax mov eax,[ebx+3Ch] push eax mov ecx,edx mov eax,ebx mov edx,[ebx+30h] mov esi,[eax] call [esi+7Ch] ...

explanation about push ebp and pop ebp instruction in assembly..

hi.... i used stack in assembly but i didn't got idea about push ebp and pop ebp. .intel_syntax noprefix .include "console.i" .text askl: .asciz "Enter length: " askb: .asciz "Enter breadth: " ans: .asciz "Perimeter = " _entry: push ebp # establishing stack-frame mov ebp, esp sub esp, 12 Promp...

How do I stop this Variant memory leak?

I'm using an old script engine that's no longer supported by its creators, and having some trouble with memory leaks. It uses a function written in ASM to call from scripts into Delphi functions, and returns the result as an integer then passes that integer as an untyped parameter to another procedure that translates it into the correct...

in following code showing output 0 instead of 8.

.intel_syntax noprefix .include "console.i" .data ask1: .long 0 ask2: .long 0 ans : .long 0 .text ask: .asciz "Enter number: " ans1: .asciz "multiplication= " _entry: Prompt ask GetInt ask1 Prompt ask GetInt ask2 mov eax, ask1 mov...

Mixing assembler code with c/c++

Why is assembly language code often needed along with C/C++ ? What can't be done in C/C++, which is possible when assembly language code is mixed? I have some source code of some 3D computer games. There are a lot of assembler code in use. ...

Why is this an invalid operand?

I have the following ASM file generated by a compiler I'm writing: ; This code has been generated by the 7Basic ; compiler <http://launchpad.net/7basic&gt; ; Uninitialized data SECTION .bss v_0 resb 4 v_4 resb 4 v_8 resb 4 ; Code SECTION .text push 1 pop eax mov v_0, eax push 2 pop eax mov v_4, eax mov eax, v_0 push eax ...

How to print string in OS-neutral way?

I am trying to print a string in a way that's OS-neutral. For example, the program should run the same on Windows as it does on *nix. Is this even possible? I'm assuming that since the underlying architecture is the same (x86) that the method would be the same. Is it as simple as calling an interrupt? The reason for this is I'm trying ...

impossible constraint in 'asm'

Hi, I'm using third party library which compiled one week ago. Today I sat down at the desk again, i pushed build again, then my head blown out. I've been shot with this error: impossible constraint in 'asm' The code is: static inline unsigned ROLc(unsigned word, const int i) { asm ("roll %2,%0" :"=r" (word) :"0...

Help me understand the assembly code

I am trying to understand the assembly level code for a simple C program by inspecting it with gdb's disassembler. Following is the C code: #include <stdio.h> void function(int a, int b, int c) { char buffer1[5]; char buffer2[10]; } void main() { function(1,2,3); } Following is the disassembly code for both main and functio...

How do I compile .s assembly code in UNIX SPARC 64bit correctly?

Greetings all. Having problem trying to compile and run this "hello, wold" .s code in sparc UNIX 64bit environment and got $: "hello.s", line 1: error: invalid character (0xef) and etc. on other lines and addresses. Thought it was ANSI UTF issues, changed and saved and tried both types. Then tried to save file with ECO conversion to UNIX...

Why does CPU access memory on a word boundary?

Hi experts~ I heard a lot that data should be properly aligned in memory for better access efficiency. CPU access memory on a word boundary. So in the following scenario, the CPU has to make 2 memory accesses to get a single word. Supposing: 1 word = 4 bytes ("|" stands for word boundary. "o" stands for byte boundary) |----o----o...

64 bit Assembly introduction

I am looking for an articles which introduce Intel 64 bit processor and Assembly: list of x64 registers, commands syntax etc. for programmers familiar with 32 bit Assembly. Kind of "What's new" for 64 bit processor. ...

Can't modify memory using 32bit assembler

Hello. I am using NASM to assemble my assembler code. The code I assembled looks like this: [BITS 32] [ORG 0] jmp 07c0h:start testvar db 0, 0, 0, 0, 0, 0, 4, 8, 15, 16, 23, 42 start: mov byte [testvar], 47 hang: jmp hang times 510-($-$$) db 0 dw 0AA55h I had problems with another piece of code, I noticed that I cou...

Architecture: Pipelining concepts

Learning architecture and assembly language Can someone please explain in plain english what this is suppose to do? First one: Pipeline register containing source instruction: EX/MEM Opcode of Source instruction: Register-register ALU Pipeline register containing destination instruction: ID/EX Opcode of destination instruction: Regist...

GCC C++ and inline assembly code?

Anyone know a nice way to do that? This does not look too friendly: __asm("command 1" "command 2" "command 3"); Do I really have to put a doublequote around every line? Am I the only one who thinks this is a MAJOR partypooper? Also... since multiline string literals does not work in GCC, i could not cheat with that eit...

can someone help me translate this c programm to MIPS assembly?

int x=0; int A[50,100]; main() { j=bin_search (*A , item, Nelem){ temp=0; temp=Nelem/2; if(Nelem==1) return *x; else (*x<item) return bin_search(*x , item , temp) else return bin_search(*x+temp , item , temp) ...