This question already has answers here:
How to write multiple condition if else statement mips
(2 answers)
Mutiple conditions in if in MIPS
(2 answers)
How can I implement if(x >= '0' && x <= '9') range checks like isdigit in MIPS?
(1 answer)
Double condition in a for loop in MIPS assembly
(1 answer)
Closed 11 days ago.
I was trying to learn MIPS assembly and trying to learn how to convert different programming languages into mips assembly. Then I cam across this sample c code snippet. I was looking for how to convert this and cant find any solution on how to convert the if-then condition with logical or as the condition.
if ( i==j || i==k )
i++ ;
else
j-- ;
j = i + k ;
I know how to convert
if ( i==j )
but not with the logical or.
Related
This question already has answers here:
Rookie Assembly Bomb Defusal cmp Operator
(1 answer)
How do we test the return values from the scanf() function?
(2 answers)
usage of the return value of scanf
(3 answers)
How does scanf(" %[^\n]", str); work in C Programming?
(2 answers)
Closed 5 months ago.
Doing some basic reverse engineering of x86 assembly code into C, but I am struggling to understand what this particular function, named phase2, is doing at the start.
Click here to see the assembly code (sorry cant post images yet)
Specifically this part right here:
call 0x5555555550b0 <<__isoc99_sscanf#plt>>
cmp $0x2,%eax
jne 0x555555555761 <phase2+86>
my best guess is that this translates to
if (scanf() == 2) {
At first I thought that maybe this was checking if the return value of scanf() == 2 but that doesn't really make sense in this context since the result never seems to be 2.
This question already has answers here:
How to print exact value of the program counter in C
(3 answers)
Closed 6 years ago.
Is there any trick to write a function for ARM Cortex M series ICs that returns the PC value before function calling. Without using assembly language.
You can use the __current_pc intrinsic, e.g.
int main()
{
printf("Current PC = %u\n", __current_pc());
return 0;
}
This question already has answers here:
Why are these constructs using pre and post-increment undefined behavior?
(14 answers)
Closed 6 years ago.
I am trying the following code:
#include <stdio.h>
int main()
{
int c =0;
c -= --c - c++;
printf("%d \n",c);
return 0;
}
When I compiled and run it using a online c complier (https://www.tutorialspoint.com/compile_c_online.php) the result is -1. But I expected it to be 0.
So, I try it on my local Dev C++ (Windows) and the result is 0.
Should the result be 0 ?
If so, why 2 gcc compilers (ok they are in different plataform) gives me 2 different results ?
I ve been looking for some kind of automatic flag otimization which could produce a different result but I had no success.
THIS IS UNDEFINED BEHAVIOR (3 modifications without sequence points inbetween to the same variable)
This question already has answers here:
To the power of in C? [duplicate]
(7 answers)
Closed 7 years ago.
void sommeascf(n)
for(i=1; i<=n; i++){
result= result+ 1/i^n
}
}
the problem I'm facing is :
result = result + 1/i^n
How can I put the power function into this arithmetic operation ?
^ this is bitwise XOR operator in C . You can write that expression using pow function like this -
result= result+ 1/(pow(i,n));
Note - You need to include header <math.h>
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)
Consider, following 2 coding lines in C
int a=0;
printf("%d%d%d%d",++a,a+1,a++,++a);
in visual C++, it gives
output:3431
But in Turbo C++
gives:
output:3311
This is also compiler dependent?
The C specification does not specify the order that the arguments to your function will be evaluated, so there's no guarantee what output you will get.