parent
d57498a4fd
commit
b400cbe058
20 changed files with 140 additions and 118 deletions
@ -1,5 +1,5 @@ |
||||
#include <sub.h> |
||||
|
||||
int main() { |
||||
return sub(); |
||||
return sub(); |
||||
} |
||||
|
@ -1,5 +1,5 @@ |
||||
#include "sub.h" |
||||
|
||||
int sub() { |
||||
return 0; |
||||
return 0; |
||||
} |
||||
|
@ -1,5 +1,5 @@ |
||||
#include <sub.h> |
||||
|
||||
int main() { |
||||
return sub(); |
||||
return sub(); |
||||
} |
||||
|
@ -1,5 +1,5 @@ |
||||
#include "sub.h" |
||||
|
||||
int sub() { |
||||
return 0; |
||||
return 0; |
||||
} |
||||
|
@ -1,4 +1,3 @@ |
||||
int main(int argc, char *argv[]) |
||||
{ |
||||
return 77; |
||||
int main(int argc, char *argv[]) { |
||||
return 77; |
||||
} |
||||
|
@ -1,3 +1,3 @@ |
||||
int first() { |
||||
return 1001; |
||||
return 1001; |
||||
} |
||||
|
@ -1,5 +1,5 @@ |
||||
int first(void); |
||||
|
||||
int main() { |
||||
return first() - 1001; |
||||
return first() - 1001; |
||||
} |
||||
|
@ -1,27 +1,27 @@ |
||||
; hello.asm a first program for nasm for Linux, Intel, gcc |
||||
; |
||||
; assemble: nasm -f elf -l hello.lst hello.asm |
||||
; link: gcc -o hello hello.o |
||||
; run: hello |
||||
; output is: Hello World |
||||
; assemble: nasm -f elf -l hello.lst hello.asm |
||||
; link: gcc -o hello hello.o |
||||
; run: hello |
||||
; output is: Hello World |
||||
|
||||
%include "config.asm" |
||||
|
||||
SECTION .data ; data section |
||||
msg: db "Hello World",10 ; the string to print, 10=cr |
||||
len: equ $-msg ; "$" means "here" |
||||
; len is a value, not an address |
||||
SECTION .data ; data section |
||||
msg: db "Hello World",10 ; the string to print, 10=cr |
||||
len: equ $-msg ; "$" means "here" |
||||
; len is a value, not an address |
||||
|
||||
SECTION .text ; code section |
||||
global main ; make label available to linker |
||||
main: ; standard gcc entry point |
||||
SECTION .text ; code section |
||||
global main ; make label available to linker |
||||
main: ; standard gcc entry point |
||||
|
||||
mov edx,len ; arg3, length of string to print |
||||
mov ecx,msg ; arg2, pointer to string |
||||
mov ebx,1 ; arg1, where to write, screen |
||||
mov eax,4 ; write sysout command to int 80 hex |
||||
int 0x80 ; interrupt 80 hex, call kernel |
||||
mov edx,len ; arg3, length of string to print |
||||
mov ecx,msg ; arg2, pointer to string |
||||
mov ebx,1 ; arg1, where to write, screen |
||||
mov eax,4 ; write sysout command to int 80 hex |
||||
int 0x80 ; interrupt 80 hex, call kernel |
||||
|
||||
mov ebx,HELLO ; exit code, 0=normal |
||||
mov eax,1 ; exit command to kernel |
||||
int 0x80 ; interrupt 80 hex, call kernel |
||||
mov ebx,HELLO ; exit code, 0=normal |
||||
mov eax,1 ; exit command to kernel |
||||
int 0x80 ; interrupt 80 hex, call kernel |
||||
|
@ -1,3 +1,3 @@ |
||||
int main() { |
||||
return 0; |
||||
return 0; |
||||
} |
||||
|
@ -1,3 +1,3 @@ |
||||
int main() { |
||||
return 0; |
||||
return 0; |
||||
} |
||||
|
@ -1,3 +1,3 @@ |
||||
int main() { |
||||
return 0; |
||||
return 0; |
||||
} |
||||
|
@ -1,5 +1,5 @@ |
||||
extern int test (); |
||||
|
||||
public int main (string[] args) { |
||||
return test (); |
||||
return test (); |
||||
} |
||||
|
@ -1,43 +1,43 @@ |
||||
extern int get_ret_code (); |
||||
|
||||
public class MyThread : Object { |
||||
public int x_times { get; private set; } |
||||
|
||||
public MyThread (int times) { |
||||
this.x_times = times; |
||||
} |
||||
|
||||
public int run () { |
||||
for (int i = 0; i < this.x_times; i++) { |
||||
stdout.printf ("ping! %d/%d\n", i + 1, this.x_times); |
||||
Thread.usleep (10000); |
||||
} |
||||
|
||||
// return & exit have the same effect |
||||
Thread.exit (get_ret_code ()); |
||||
return 43; |
||||
} |
||||
public int x_times { get; private set; } |
||||
|
||||
public MyThread (int times) { |
||||
this.x_times = times; |
||||
} |
||||
|
||||
public int run () { |
||||
for (int i = 0; i < this.x_times; i++) { |
||||
stdout.printf ("ping! %d/%d\n", i + 1, this.x_times); |
||||
Thread.usleep (10000); |
||||
} |
||||
|
||||
// return & exit have the same effect |
||||
Thread.exit (get_ret_code ()); |
||||
return 43; |
||||
} |
||||
} |
||||
|
||||
public static int main (string[] args) { |
||||
// Check whether threads are supported: |
||||
if (Thread.supported () == false) { |
||||
stderr.printf ("Threads are not supported!\n"); |
||||
return -1; |
||||
} |
||||
|
||||
try { |
||||
// Start a thread: |
||||
MyThread my_thread = new MyThread (10); |
||||
Thread<int> thread = new Thread<int>.try ("My fst. thread", my_thread.run); |
||||
|
||||
// Wait until thread finishes: |
||||
int result = thread.join (); |
||||
// Output: `Thread stopped! Return value: 42` |
||||
stdout.printf ("Thread stopped! Return value: %d\n", result); |
||||
} catch (Error e) { |
||||
stdout.printf ("Error: %s\n", e.message); |
||||
} |
||||
|
||||
return 0; |
||||
// Check whether threads are supported: |
||||
if (Thread.supported () == false) { |
||||
stderr.printf ("Threads are not supported!\n"); |
||||
return -1; |
||||
} |
||||
|
||||
try { |
||||
// Start a thread: |
||||
MyThread my_thread = new MyThread (10); |
||||
Thread<int> thread = new Thread<int>.try ("My fst. thread", my_thread.run); |
||||
|
||||
// Wait until thread finishes: |
||||
int result = thread.join (); |
||||
// Output: `Thread stopped! Return value: 42` |
||||
stdout.printf ("Thread stopped! Return value: %d\n", result); |
||||
} catch (Error e) { |
||||
stdout.printf ("Error: %s\n", e.message); |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
@ -1,7 +1,7 @@ |
||||
namespace Foo |
||||
{ |
||||
public int bar () |
||||
{ |
||||
return 0; |
||||
} |
||||
public int bar () |
||||
{ |
||||
return 0; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue