Last change
on this file since 16 was 2, checked in by Mattia Monga, 14 years ago |
Importazione sorgenti
|
File size:
451 bytes
|
Rev | Line | |
---|
[2] | 1 | section .text
|
---|
| 2 | global enter_section
|
---|
| 3 | extern printf
|
---|
| 4 |
|
---|
| 5 | enter_section:
|
---|
| 6 | enter 0, 0 ; 0 bytes of local stack space
|
---|
| 7 | mov ebx,[ebp+8] ; first parameter to function
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | spin: mov ecx, 0
|
---|
| 11 | lock bts dword [ebx], 0
|
---|
| 12 | jc save
|
---|
| 13 | print: push busy
|
---|
| 14 | call printf
|
---|
| 15 |
|
---|
| 16 | cmp ecx, 1
|
---|
| 17 | je spin
|
---|
| 18 |
|
---|
| 19 | save: mov ecx, 1
|
---|
| 20 | jmp print
|
---|
| 21 |
|
---|
| 22 | leave ; mov esp,ebp / pop ebp
|
---|
| 23 | ret
|
---|
| 24 |
|
---|
| 25 | section .rodata
|
---|
| 26 | busy: db "Busy waiting!",10,0
|
---|
Note:
See
TracBrowser
for help on using the repository browser.