Skip to content
Snippets Groups Projects
Commit a996f5b7 authored by Strozzi's avatar Strozzi
Browse files

Fix main to final version \(\!\?\)

parent e731c9c4
No related branches found
No related tags found
No related merge requests found
Pipeline #
#include<stdio.h> #include "cMIPS.h"
#include "vetorFib.h" #include "vetorFib.h"
#define MAXPOW 7 #define MAXPOW 7
typedef struct UARTdriver {
int rx_hd ; // reception queue head index
int rx_tl ; // reception queue tail index
char rx_q [16]; // reception queue
int tx_hd ; // transmission queue head index
int tx_tl ; // transmission queue tail index
char tx_q [16]; // transmission queue
int nrx ; // number of characters in rx_queue
int ntx ; // number of spaces in tx_queue
} UARTdriver ;
extern UARTdriver Ud ;
int Strlen(char *c) int Strlen(char *c)
{ {
int i= 0; int i= 0;
while(c[i++]); while(c[i++]-10);
return i-1; return i-1;
} }
...@@ -51,21 +63,48 @@ int int2hex(char *c, int i) ...@@ -51,21 +63,48 @@ int int2hex(char *c, int i)
c[j++] = 'a'+ (val-10); c[j++] = 'a'+ (val-10);
p/=16; p/=16;
} }
c[j] = 0; c[j] = 10;
return j-1; return j-1;
} }
int main() int main()
{ {
char n[16], f[16]; char n[16], f[16], c;
int fib; int fib, j, s;
while (scanf("%s", n) && n[0]) { // trocar scanf por getc() while (1) {
j= 0;
while ((n[j++]= getFila()) != '\n');
n[j] = '\n'
if (n[0] == 10) // critério de fim de transmissão
break;
fib= hex2int(n); fib= hex2int(n);
if (fib < BUF_SZ) { if (fib < BUF_SZ) {
fib = buf[fib]; fib = buf[fib];
int2hex(f, fib); s= int2hex(f, fib); //retorna strlen de f
printf("%d(%s)\n", fib, f); // trocar printf por putc() for (j= 0; j< s; j++)
} else putc(f[j]);
printf("Valor fora dos limites!\n"); } else {
to_stdout('v');
to_stdout('a');
to_stdout('l');
to_stdout('o');
to_stdout('r');
to_stdout(' ');
to_stdout('m');
to_stdout('u');
to_stdout('i');
to_stdout('t');
to_stdout('o');
to_stdout(' ');
to_stdout('g');
to_stdout('r');
to_stdout('a');
to_stdout('n');
to_stdout('d');
to_stdout('e');
to_stdout('\n');
}
} }
// sleep??
return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment