Skip to content

Commit

Permalink
Lecture 102 - Implementing system get key in stdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
nibblebits committed Dec 15, 2020
1 parent ea12254 commit a85e8f9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
8 changes: 7 additions & 1 deletion programs/blank/blank.c
Expand Up @@ -3,6 +3,12 @@ int main(int argc, char** argv)
{
print("Hello how are you!\n");

while(1) {}
while(1)
{
if (getkey() != 0)
{
print("key was pressed\n");
}
}
return 0;
}
13 changes: 11 additions & 2 deletions programs/stdlib/src/peachos.asm
@@ -1,6 +1,7 @@
[BITS 32]

global print:function
global getkey:function

; void print(const char* filename)
print:
Expand All @@ -10,6 +11,14 @@ print:
mov eax, 1 ; Command print
int 0x80
add esp, 4
pop ebp
ret
ret

; int getkey()
getkey:
push ebp
mov ebp, esp
mov eax, 2 ; Command getkey
int 0x80
pop ebp
ret
1 change: 1 addition & 0 deletions programs/stdlib/src/peachos.h
@@ -1,5 +1,6 @@
#ifndef PEACHOS_H
#define PEACHOS_H
void print(const char* filename);
int getkey();

#endif

0 comments on commit a85e8f9

Please sign in to comment.