Updated hello.c to print the program's PID. Add getPID syscall.

This commit is contained in:
Xnoe 2021-12-08 18:48:24 +00:00
parent 02e0bcd70e
commit ca131c71e8
Signed by: xnoe
GPG Key ID: 45AC398F44F0DAFE
3 changed files with 16 additions and 1 deletions

View File

@ -28,6 +28,10 @@ uint32_t filesize(char* filename) {
asm volatile ("mov $6, %%eax; mov %0, %%esi; int $0x7f" : : "m" (filename) : "esi");
}
uint32_t getPID() {
asm volatile ("mov $8, %%eax; int $0x7f" : : :);
}
int int_to_decimal(unsigned int number, char* string_buffer) {
for (int i=0; i<11; i++)
string_buffer[i] = 0;

View File

@ -11,6 +11,8 @@ void* localalloc(uint32_t size);
void localdelete(void* ptr);
uint32_t filesize(char* filename);
uint32_t getPID();
int int_to_decimal(unsigned int number, char* string_buffer);
int int_to_hex(unsigned int number, char* string_buffer);

View File

@ -1,7 +1,16 @@
#include "../common/common.h"
int main() {
uint32_t counter = 0;
uint32_t PID = getPID();
char intbuffer[32];
uint32_t index = int_to_decimal(PID, intbuffer);
while (1) {
// print("Hello");
counter++;
if (counter == 312500) {
print(intbuffer+index);
print(" ");
counter = 0;
}
}
}