MY friend told me that this was something neat so I've been working on it for a while but I can't see it. He gave a set of machine code, told me it'd be interesting in MIPS instruction set (The...
Type: Posts; User: clag
MY friend told me that this was something neat so I've been working on it for a while but I can't see it. He gave a set of machine code, told me it'd be interesting in MIPS instruction set (The...
Hi, I wanted to convert this code into assembly but I'm having trouble. Here's what I got :]
int b = 0, x;
while (x != 0) {
b += ((x & 03) == 2);
x >>= 1;
Basically I want to convert this into C.
addi $s3, $0, 1
add $t0, $s2, $s3
lw $t1, 0($t0)
add $t2, $s1, $t1
lw $s4, 0($t2)
($s0 = A, $s1 = B, $s2 = C and so on..)
This could...
void printOnes (int x)
{
int i;
int numOnes = 0;
for (0 = i; i < 32; i++) {
if ((x & 0x1) = 1)
numOnes++;
x = x >> 1;
}
printf("The number of ones is %c\n",...
ooops, thanks for pointg that out :)
is this right now?
void clrbuf (int character)
{
if(character == '\n') /* if stdin is already clear */
{
the purpose of the clrbuf function is to remove any characters in stdin by repeatedly calling fgetc until a newline character is detected. Here's what I have..
I check to see if the incoming ...
//base-conversion algorithm
while(number != 0)
{
converted[index] = number % base;
number = number / base;
index++;
}
// back up to last entry
...
delete
void decout (unsigned long number, FILE * stream)
{
int converted[64];
long digit_count = 0;
int base = 10;
int index = 0;
while(digit_count != 0)
{
delete
delete
delete
delete
cause Values of message are expected to be a NULL terminated character arrays.
if I just use fputc, it compiles fine, but is the program erroneous?
delete
what should I return if I use fputs...will mine still be valid?
so i can just replace 64 with base right? cause I also have a hexout function.
but i feel like 64 is a magical number..but that's the only way I got it to work.. what does it represent?
how is this?
void decout (unsigned long number, FILE * stream)
{
int converted[64];
long digit_count = 0;
int base = 10;
int index = 0;
while(digit_count != 0)
{
i understand in Java that code would be trivial.. can you give me an example in C, how I would implement that not directly (since it just gives it away) but something similar? thank you!
the array is incorrect ahh..
i drew out a pseudo-code to try and figure it out but it seems like there will always be an error if there is a zero and it will always read it incorrectly.
ignore...