assembly

Converting Assembly Code To Machine Code

Hi everybody.. My Question is How can I know the exchangeable machine code of the instructions of the assembly code? And how to write a binary file that can be executed? Thanks. ...

Read then conditional write vs. write

Which is, on average, faster - check the value then, if needed, assign, or simply assign? Or, in C++ terms: bool b; if(b) b = false; or b = false; Assume that the if() condition is true with 50% probability. The answer will be, most likely, highly architecture dependent - please voice your low-level considerations. Writing alwa...

.word directives in MIPS assembly

.data VALS: .half 0xbead, 0xface RES: .space 4 .text la $t0,VALS lh $t1,($t0) lhu $t2,2($t0) sll $t2,$t2,16 or $t2,$t1,$t2 jal AVG .word -2 .word -6 la $t4,RES sw $v0,($t4) li $v0,10 syscall AVG: lw $v0,($ra) lw $t3,4($ra) add ...

Force visual studio to always 'rebuild all' when debugging

Edit: Basically what I need is for visual studio to always rebuild all when I hit debug. I'm currently using visual studio to compile my assembly programs, using MASM and in general it's working fine. However I've run into an annoying issue: If I include a file (say, a file with functions) like this Include functions.inc and comp...

Which assembler to target?

I'm building a toy compiler as a learning project, and I'm hovering around the code generation phase right now. I found this page describing a host of different assemblers that I could target, and I'd like some recommendations on which to choose. My goal is to optimize my learning experience - to that end, I've tried to make decisions ...

What are CPU registers and how are they used, particularly WRT multithreading?

This question and my answer below are mainly in response to an area of confusion in another question. At the end of the answer, there are some issues WRT "volatile" and thread synchronisation that I'm not entirely confident about - I welcome comments and alternative answers. The point of the question primarily relates to CPU registers a...

understanding memory address

I am having problems with memory addressing in MIPS. It says that the addressing is word aligned... in the text below I don't understand why it's looking at the 2 least significant bits of the address? why? can someone give me an example to clarify/illustrate the point made here... so is it saying that a valid halfword address are all wh...

What does this assembly code mean?

Recently, i am looking into some assembly codes generated by GCC. But I dont understand some of them: movl $0x2d, 0x4(%esp) In the second operand, what does 0x4 stands for? offset address? And what the use of register EAX? ...

Help understanding part of this generated assembly code

Can anyone explain to me the assembly generated by GCC of the following C++ codes? espeically, the meaning of setg and test in the codes. thx! .cpp codes: 1 /*for loop*/ 2 int main() 3 { 4 int floop_id; 5 for(floop_id=100;floop_id>=1;floop_id--) 6 {} 7 return 0; 8 } assembly codes: 3 p...

Microsof Assembler to GNU Assembler conversion

I have an ARM assembly code that compiles well with Visual Studio. I would like to now use the same ARM assembly code and compile it with GNU Assembler. As you know the syntax of both assemblers are different. I was wondering if there is any tool that can convert from these Assembly syntaxes. ...

What is the proper way to replace very small portions of a binary file programmatically?

I have a game code (from ioquake3 project) that compiles part of gameplay binaries on the fly (the qvm system). Now, one could potentially speed it up by loading previously saved binaries of this operation (with any change-of-files precautions in place). But, pointers to functions saved in these binaries are not persistent through sess...

Delphi label and asm weirdness?

I written an asm function in Delphi 7 but it transforms my code to something else: function f(x: Cardinal): Cardinal; register; label err; asm not eax mov edx,eax shr edx, 1 and eax, edx bsf ecx, eax jz err mov eax, 1 shl eax, cl mov edx, eax add edx, edx or eax, edx ret err: xor eax, eax end; // compiled ...

MOV src dest (or) MOV dest src?

MOV is probably the first instruction everyone learns while learning ASM. Just now I encountered a book Assembly Language Programming in GNU/Linux for IA32 Architectures By Rajat Moona which says: But I learnt that it is MOV dest, src. Its like "Load dest with src". Even Wiki says the same. I'm not saying that the author is wrong. I...

assembly on windows 7

how can i make a device input and output control program on windows 7?? Previously there was an option called debug where we wrote our programs. but as far as i know this feature is no more in windows 7. how can i do assembly on windows7?? ...

why gcc 4.x default reserve 8 bytes for stack on linux when calling a method?

as a beginner of asm, I am checking gcc -S generated asm code to learn. why gcc 4.x default reserve 8 bytes for stack when calling a method? func18 is the empty function with no return no param no local var defined. I can't figure out why 8 bytes is reserved here (neither any forum/site mention for the reason, ppl seems take it for g...

help understanding differences between #define, const and enum in C and C++ on assembly level.

recently, i am looking into assembly codes for #define, const and enum: C codes(#define): 3 #define pi 3 4 int main(void) 5 { 6 int a,r=1; 7 a=2*pi*r; 8 return 0; 9 } assembly codes(for line 6 and 7 in c codes) generated by GCC: 6 mov $0x1, -0x4(%ebp) 7 mov -0x4(%ebp), %edx 7 mov %edx, %ea...

Which Computer Organization & Architecture book is good for me?

I'm always interested in learning the inner working of things. I started with C programming and then learnt Operating systems (from stallings) and then linkers & loaders and then assembly language after reading these now I want to go into little more depth. Computer Architecture. I feel that makes everything clear. As per SO archives t...

Combining prefixes in SSE

In SSE the prefixes 066h (operand size override) 0F2H (REPNE) and 0F3h (REPE) are part of the opcode. In non-SSE 066h switches between 32-bit (or 64-bit) and 16-bit operation. 0F2h and 0F3h are used for string operations. They can be combined so that 066h and 0F2h (or 0F3h) can be used in the same instruction, because this is meaning...

Running out of label names in assembly

Heyo, My class at college has us writing programs in assembly. I have never truly appreciated the ease of C until now. Now, when I program in assembly, I often have to make while/for/if loops and conditionals with labels eg: SKIP: ... COMP:ADD R1, R1, #0 ;Check for equality BRZ WHILEEND ... ;code inside the w...

assembly registers beginner

So I've been getting into a bit of assembly lately and I'm a beginner so i was wondering if someone could clarify something. I take it every process has it's own set of registers, and each thread can modify these registers right?. How then do multiple threads use the same registers without causing clashes? Or does each thread have its ow...