Switch to the new locking API.
[monolithium.git] / tests / hello.asm
1 ;
2 ; hello.asm
3 ;
4 ; Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
5 ;
6 ; This program is free software: you can redistribute it and/or modify
7 ; it under the terms of the GNU Affero General Public License as
8 ; published by the Free Software Foundation, either version 3 of the
9 ; License, or (at your option) any later version.
10 ;
11 ; This program is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ; GNU Affero General Public License for more details.
15 ;
16 ; You should have received a copy of the GNU Affero General Public License
17 ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 ;
19
20 SYSCALL_ALLOC_MEMORY              EQU 0
21 SYSCALL_CLOCK_GET_TIME            EQU 1
22 SYSCALL_CLOCK_SET_TIME            EQU 2
23 SYSCALL_CLOSE_OBJECT              EQU 3
24 SYSCALL_COMMIT_MEMORY             EQU 4
25 SYSCALL_CREATE_MEMORY_SECTION     EQU 5
26 SYSCALL_CREATE_PROCESS            EQU 6
27 SYSCALL_CREATE_SEMAPHORE          EQU 7
28 SYSCALL_CREATE_THREAD             EQU 8
29 SYSCALL_CREATE_USER               EQU 9
30 SYSCALL_DELETE_FILE               EQU 10
31 SYSCALL_DELETE_USER               EQU 11
32 SYSCALL_DEVICE_IOCTL              EQU 12
33 SYSCALL_DUPLICATE_HANDLE          EQU 13
34 SYSCALL_ENUM_PROCESSES            EQU 14
35 SYSCALL_FLUSH_MEMORY_SECTION      EQU 15
36 SYSCALL_FREE_MEMORY               EQU 16
37 SYSCALL_GET_EXCEPTION_INFO        EQU 17
38 SYSCALL_GET_MILLISECONDS          EQU 18
39 SYSCALL_GET_NANOSECONDS           EQU 19
40 SYSCALL_GET_PROCESS_ID            EQU 20
41 SYSCALL_GET_THREAD_ID             EQU 21
42 SYSCALL_GET_USER_ID               EQU 22
43 SYSCALL_LIST_DIRECTORY            EQU 23
44 SYSCALL_LOGON_USER                EQU 24
45 SYSCALL_MAP_MEMORY_SECTION        EQU 25
46 SYSCALL_MOUNT                     EQU 26
47 SYSCALL_OPEN_FILE                 EQU 27
48 SYSCALL_OPEN_MEMORY_SECTION       EQU 28
49 SYSCALL_OPEN_PIPE                 EQU 29
50 SYSCALL_OPEN_PROCESS              EQU 30
51 SYSCALL_OPEN_THREAD               EQU 31
52 SYSCALL_POWER_CONTROL             EQU 32
53 SYSCALL_QUERY_FILE                EQU 33
54 SYSCALL_QUERY_HANDLE              EQU 34
55 SYSCALL_QUERY_PROCESS             EQU 35
56 SYSCALL_QUERY_THREAD              EQU 36
57 SYSCALL_QUERY_USER                EQU 37
58 SYSCALL_RAISE_EXCEPTION           EQU 38
59 SYSCALL_READ_FILE                 EQU 39
60 SYSCALL_READ_MEMORY               EQU 40
61 SYSCALL_READ_PIPE                 EQU 41
62 SYSCALL_RELEASE_SEMAPHORE         EQU 42
63 SYSCALL_RESTORE_EXCEPTION_HANDLER EQU 43
64 SYSCALL_REVERT_USER               EQU 44
65 SYSCALL_SAVE_EXCEPTION_HANDLER    EQU 45
66 SYSCALL_SET_MEMORY_FLAGS          EQU 46
67 SYSCALL_SET_USER_ID               EQU 47
68 SYSCALL_SLEEP                     EQU 48
69 SYSCALL_TERMINATE                 EQU 49
70 SYSCALL_TERMINATE_THREAD          EQU 50
71 SYSCALL_UNCOMMIT_MEMORY           EQU 51
72 SYSCALL_UNMOUNT                   EQU 52
73 SYSCALL_WAIT_PROCESS              EQU 53
74 SYSCALL_WAIT_SEMAPHORE            EQU 54
75 SYSCALL_WAIT_THREAD               EQU 55
76 SYSCALL_WRITE_FILE                EQU 56
77 SYSCALL_WRITE_MEMORY              EQU 57
78 SYSCALL_WRITE_PIPE                EQU 58
79 SYSCALL_YIELD_QUANTUM             EQU 59
80
81 bits 32
82
83 section .text
84
85 start:                  push 0
86                         push 0
87                         push handle
88                         push name
89                         push SYSCALL_OPEN_FILE
90                         call syscall
91                         add esp, 20
92                         push 4
93                         push address
94                         push 12
95                         push framebuffer
96                         push 0xC9000004
97                         push dword [handle]
98                         push SYSCALL_DEVICE_IOCTL
99                         call syscall
100                         add esp, 28
101                         or eax, eax
102                         jnz .stop
103                         mov edi, dword [address]
104                         lea esi, [edi + 160]
105                         mov ecx, 960
106                         cld
107                         rep movsd
108                         mov eax, 0x07200720
109                         mov ecx, 40
110                         rep stosd
111                         sub edi, 160
112                         mov esi, message
113                         mov ecx, 13
114                         rep movsw
115 .stop:                  xor eax, eax
116                         not eax
117                         push eax
118                         push eax
119                         push SYSCALL_SLEEP
120                         call syscall
121                         add esp, 12
122                         jmp .stop
123
124 %include "../library/src/syscall.asm"
125
126 section .data
127
128 handle:                 DD 0
129 name:                   DB '@Video0', 0
130 framebuffer:            DD 0x10000000
131                         DD 0
132                         DD 80 * 25 * 2
133 address:                DD 0
134 message:                DB 'H', 7, 'e', 7, 'l', 7, 'l', 7, 'o', 7, ',', 7, ' ',
135                         DB  7, 'w', 7, 'o', 7, 'r', 7, 'l', 7, 'd', 7, '!', 7