* cormen book
[mascara-docs.git] / i86 / mtx-16-bit / mtx / samples / LAB3 / s.s
blobffd0a1b8b7192587a85a048abcb9db5bc52d788b
1 .globl begtext, begdata, begbss ! needed by linker
3 .globl _tswitch,_getc,_putc ! EXPORT these
4 .globl _main,_running,_scheduler,_proc,_procSize ! IMPORT these
6 .text ! these tell as:
7 begtext: ! text,data,bss segments
8 .data ! are all the same.
9 begdata:
10 .bss
11 begbss:
12 .text
14 start:
15 mov ax,cs ! establish segments
16 mov ds,ax ! Let DS,SS,ES = CS=0x1000.
17 mov ss,ax
18 mov es,ax
20 mov sp,#_proc ! sp -> proc[0]
21 add sp,_procSize ! sp -> proc[0]'s HIGH END
23 call _main ! call main() in C
25 dead: jmp dead ! loop if main() ever returns
28 _tswitch:
29 SAVE: push ax
30 push bx
31 push cx
32 push dx
33 push bp
34 push si
35 push di
36 pushf
37 mov bx, _running
38 mov 2[bx], sp
40 FIND: call _scheduler
42 RESUME: mov bx, _running
43 mov sp, 2[bx]
44 popf
45 pop di
46 pop si
47 pop bp
48 pop dx
49 pop cx
50 pop bx
51 pop ax
52 ret
55 _getc:
56 xorb ah,ah
57 int 0x16
58 ret
60 _putc:
61 push bp
62 mov bp,sp
63 movb al,4[bp]
64 movb ah,#14
65 mov bx,#0x000B ! CYAN color
66 int 0x10
67 pop bp
68 ret