makefile: compile, assemble and link
[swan-dev] / src / init.s
1 ;; File              : init.s
2 ;; Author            : Robin Krens <robin@robinkrens.nl>
3 ;; Date              : 02.06.2022
4 ;; Last Modified Date: 02.06.2022
5 ;; Last Modified By  : Robin Krens <robin@robinkrens.nl>
6
7         ;;org 0x0000
8         cpu 186
9         bits 16
10
11 extern _main
12
13 section .data
14         %include "init.inc"  
15
16 section .text
17
18 init:
19         cli                     ; disable interrupts
20         cld                     ; offset in increment mode
21         
22         xor     ax,ax           ; clear all registers
23         mov     bx,ax
24         mov     cx,ax
25         mov     dx,ax
26         mov     si,ax
27         mov     di,ax
28         mov     ds,ax           ; clear Segments
29         mov     es,ax
30         
31         mov     bp,ax           ; setup stack
32         mov     ss,ax
33         mov     sp,WS_STACK
34         
35         in      al,IO_HARDWARE_TYPE     ; check wonderswan mono or color
36         test    al,WS_COLOR
37 .mono:  jz      .mono           ;loop forever if mono
38
39         mov     sp,WSC_STACK    ; new stack
40
41 clear_ram:
42         xor     ax,ax           ; clear Ram
43         mov     di,0x100
44         mov     cx,0x7E80
45         rep     stosw
46
47         ; call to _main
48         call    _main