Add Syscall: Exit, PutChar, GetCar, PutString, GetString
This commit is contained in:
parent
6f405265a5
commit
80fc250109
15 changed files with 359 additions and 17 deletions
13
code/test/getstring.c
Normal file
13
code/test/getstring.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include "syscall.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
//char s;
|
||||
//s = GetChar();
|
||||
//PutChar(s);
|
||||
char t[100];
|
||||
GetString(t, 100);
|
||||
PutString(t);
|
||||
PutChar('\n');
|
||||
PutString("Ceci est un test de grande ampleur");
|
||||
}
|
17
code/test/putchar.c
Normal file
17
code/test/putchar.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "syscall.h"
|
||||
void print(char c, int n)
|
||||
{
|
||||
int i;
|
||||
//#if 0
|
||||
for (i = 0; i < n; i++) {
|
||||
PutChar(c + i);
|
||||
}
|
||||
PutChar('\n');
|
||||
//#endif
|
||||
}
|
||||
int
|
||||
main()
|
||||
{
|
||||
print('a',4);
|
||||
Halt();
|
||||
}
|
15
code/test/putstring.c
Normal file
15
code/test/putstring.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include "syscall.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// PutString("Te\n");
|
||||
// PutString("Tes\n");
|
||||
// PutString("Tes t\n");
|
||||
// // les deux derniers ne fonctionnent pas car ila dépassent la taille du
|
||||
// // buffer: MAX_STRING_SIZE
|
||||
// //
|
||||
// // Maitenant que j'ai fais une boucle dans PutString, tout fonctionne bien
|
||||
PutString("BonjourTout\n");
|
||||
PutString("Bonjour tout le monde\n");
|
||||
Exit(4);
|
||||
}
|
|
@ -146,6 +146,43 @@ Yield:
|
|||
j $31
|
||||
.end Yield
|
||||
|
||||
#ifdef CHANGED
|
||||
.globl PutChar
|
||||
.ent PutChar
|
||||
PutChar:
|
||||
addiu $2,$0,SC_PutChar
|
||||
syscall
|
||||
j $31
|
||||
.end PutChar
|
||||
|
||||
|
||||
.globl PutString
|
||||
.ent PutString
|
||||
PutString:
|
||||
addiu $2,$0,SC_PutString
|
||||
syscall
|
||||
j $31
|
||||
.end PutString
|
||||
|
||||
.globl GetChar
|
||||
.ent GetChar
|
||||
|
||||
GetChar:
|
||||
addiu $2,$0,SC_GetChar
|
||||
syscall
|
||||
j $31
|
||||
.end PutChar
|
||||
|
||||
|
||||
.globl GetString
|
||||
.ent GetString
|
||||
GetString:
|
||||
addiu $2,$0,SC_GetString
|
||||
syscall
|
||||
j $31
|
||||
.end GetString
|
||||
#endif
|
||||
|
||||
/* dummy function to keep gcc happy */
|
||||
.globl __main
|
||||
.ent __main
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue