assembly

"Assembly" vs. "Assembler"

I've been taught that "assembly" is what you write in your files, to have your "assembler" convert it into binary code. But I see these two terms mixed and matched in various works. I've even heard that you write "assembler", after which an "assemblator" makes it executable. Tell me, please, what's the right words to use? ...

How to use "GS:" in 64-bit Windows Assembly (eg, porting TLS code)

How can an user-space program configure "GS:" under 64-bit Windows (currently XP-64)? (By configure, set GS:0 at an arbitrary 64-bit linear address). I am trying to port a "JIT" environment to X86-64 that was originally developed for Win32. One unfortunate design aspect is that identical code needs to run on multiple user-space threa...

80x86 assembly question

I have this code : section .data Foos: mov ecx,7 mov edx,5 L: inc edx sub ecx,1 setZ al ; set al to 1 if zero flag, otherwise al=0 shl al,1 mov byte[L1+1],al L1: jmp L lmp L mov eax,edx ret The question is what will be in eax at the end of the code? I don't know why the answer is 12? ...

Graphic Adapter problem in Assembly with vista

When I want to switch to GA in Assembly with Vista it gives me a fatal error and it simply says "I don't support 16bit GA". What should I Do? ...

assembly 80x86 question

i have this question: in 80486 computer what is the worst case (include the FETCH) number of memory access of the instruction: add dword [x],0x123FA4 if it known that an opcode with no operands is 2 byte len ...

how to load the save the value and upload back when it turn on.

void Load(void) { unsigned char j,*flash,free; unsigned int bank,siz; asm lda 0xA100; asm sta flash_s; flash = &CT_r; bank = 0xA101; siz = 1; for(j=0;j<=siz;j++) { asm lda bank; asm sta free; free=*flash++; bank=bank+1; } asm lda 0xA103; asm sta Ln_s; asm lda 0xA104; asm s...

How linker resolves the symbol in assembly code

Hi, I wanted to know how linker resolves the printf symbol in the following assembly code. #include<stdio.h> void main() { printf("Hello "); } .file "test.c" .def ___main; .scl 2; .type 32; .endef .section .rdata,"dr" LC0: .ascii "Hello \0" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: ...

ARM carry flag on EOR/XOR and AND

I was looking up some ARM assembly and i notice EOR/XOR and AND all set the C and O flag. How does that work? Are they always cleared? what conditions are they set? ...

Why do boot loaders relocate in memory?

I am writing a boot loader, and I've got most of the details down, but I am not sure why some boot loaders relocate themselves in memory before they begin the bulk of their execution. Can anyone explain this? An example of this behavior is the original v0.01 Linux kernel bootloader which has the following comment in it: boot.s is load...

Syscall from inline asm in x86_64 Linux?

Hi, Why does this print garbage instead of exiting my program gracefully? I use system calls this way on BSD, and I wonder what would I need to make it work in Linux. int main(int argc, char **argv) { __asm ("movq $1,%rax; movq $0,%rdi; syscall"); /* exit(0) ? */ return 0; } Thanks. ...

How to fix a "[Lp002]: relocation failed with IAR ARM tools?

I created a small module in assembler for ARM, to be linked together with my bare-metal embedded application. Sometimes when I'm rebuilding the application, I get a "Error[Lp002]: relocation failed: valued out of range or illegal". What is even more puzzling is that I'm getting the error after commenting out some code in a C module. T...

C String literals not in machine code?

I need to slightly change a string in an exe which I dont have source code for anymore. It was writtin in C. I notice that C string literals do not seem to appear in the machine code listing at all - not in raw ASCII anyway, not in utf8/16/32 or anything like that. They seem to be encoded, I am guessing as part of 32bit op-codes. For ex...

Getting started with 32-bit assembly

I routinely compile my C code to assembly to read the output and learn about how the compiler interprets my code. While doing this, I often think, "maybe I should just write my software in assembly!" But in all honesty I don't know how to begin. I've written 16 bit assembly compiled with tasm before and it was sorta fun. But I want to s...

What is the difference between concrete RTN and abstract RTN?

I have been reading about RTN (Register Transfer Notation) and I have come upon abstract RTN. There is no explanation about the difference between concrete RTN and abstract RTN. Could anyone explain to me the difference between the two both in how you write the code and how it interacts with the machine? ...

How can I build a small operating system on an old desktop computer?

This might be in vain, as I know writing an operating system is unbearably complicated (especially by oneself). I don't expect to build the next linux, or windows. I know it will be horrible, and buggy, and won't work, but that's fine. I want to write everything myself, in assembly, C, and (some) C++. This is a future project, as I'm...

What's the most efficient way to multiply 4 floats by 4 floats using SSE ?

I currently have the following code: float a[4] = { 10, 20, 30, 40 }; float b[4] = { 0.1, 0.1, 0.1, 0.1 }; asm volatile("movups (%0), %%xmm0\n\t" "mulps (%1), %%xmm0\n\t" "movups %%xmm0, (%1)" :: "r" (a), "r" (b)); I have first of all a few questions: (1) if i WERE to a...

NASM Printing Out Time - Beginner Help

I'm just getting started with ASM (NASM), and need some help with the following snippet. I get no errors/warnings, it just doesn't output anything. What I was expecting was for it to get the time (13), then print that out (4), then exit (1). Also, does anyone know of some good (preferably NASM specific) ASM tutorials? section .bss ...

armasm visual studio 208

Hi I am trying to include ARM assembly file **.asm in static lib which I am building using visual studio 2008. When I try to build solution which contains the library the visual studio crashes. The assembly file is generated from c fiile by selecting assembly-only listing option (FA). I add this to the library project and in its propert...

Get GCC to preserve an SSE register throughout a function that uses inline asm

I'm writing a program in C that needs to do some fast math calculations. I'm using inline SSE assembly instructions to get some SIMD action (using packed double precision floating point numbers). I'm compiling using GCC on Linux. I'm in a situation where I need to loop over some data, and I use a constant factor in my calculations. I'd ...

how do procedure calls work in assembler?

I just started tinkering with ASM and I'm not sure if my understanding of procedure calls is correct. say at some point in the code there is a procedure call call dword ptr[123] and the procedure consists of only one command, ret: ret 0004 what would be the effect of this procedure call, and where would the return value be stored?...