;native.asm ;the device loading code needs some changes ;needs to have a text mode version use16 org 7C00h hackos: if VIDEO = 1 mov ax,4F02h mov bx,114h OR 4000h ;800x600x16 video int 10h else mov ax,1112h mov bl,0 int 10h ;80x50 text end if mov ax,4F0Ah sub bx,bx int 10h push es sub eax,eax pop ax shl eax,4 add eax,edi mov dword [.voff],eax movzx ecx,cx mov word [.vsize],cx cli in al,70h or al,80h out 70h,al in al,92h or al,02h out 80h,al out 92h,al lgdt [.gdt] mov eax,cr0 or al,1 mov cr0,eax jmp 8:.flush use32 .flush: mov eax,10h mov ds,eax mov es,eax mov ss,eax call .rdhdr call .rdimage jmp dword [hackos.base] .rdhdr: mov edi,7E00h sub eax,eax inc eax mov ecx,eax call .hdread mov edi,hackos.magic cmp dword [edi],"aWc " jnz .invalid_image ret .rdimage: mov edi,dword [hackos.base] mov eax,dword [hackos.size] shr eax,09h ;size/512 mov ecx,02h ;start sector call .hdread ret .invalid_image: mov edi,0B8000h mov eax,0A31h stosw jmp $ .hdread: ;this is not available as mov ebx,eax ;a word until this loads it mov edx,1F2h out dx,al mov eax,0E0000000h add eax,ecx inc edx out dx,al shr eax,8 inc edx out dx,al shr eax,8 inc edx out dx,al shr eax,8 inc edx out dx,al inc edx mov al,20h out dx,al call .idle .read: test al,8 jz .idle mov ecx,256 rep insw dec bl jnz .read ret .idle: mov edx,1F7h in al,dx test al,80h jnz .idle sub edx,07h ret align 8 struc segment a,b,c,d,e,f { .length dw a .base0_15 dw b .base16_23 db c .flags db d .access db e .base24_31 db f } .voff dd 0 .vsize dd 0 .gdt: dw .gdtend-.fo dd .fo .fo segment 0,0,0,0,0,0 .cs segment 0FFFFh,00000h,00h,9Ah,0CFh,00h .ds segment 0FFFFh,00000h,00h,92h,0CFh,00h .ss segment 0000Fh,00000h,00h,92h,0C0h,00h .gdtend: times 510-($-hackos) db 0 dw 0AA55h ;sector2 struc intrpt a { .offset0_15 dw a .selector dw 0008h .flags dw 8E00h .offset16_31 dw 0001h } align 8 .magic dd "aWc " .base dd BASE .size dd imagesize .stamp dd "HACK" idt: dw .end-.00-1 dd .00 .00 intrpt ivt.03 .01 intrpt ivt.01 .02 intrpt ivt.03 .03 intrpt ivt.03 .04 intrpt ivt.03 .05 intrpt ivt.03 .06 intrpt ivt.03 .07 intrpt ivt.03 .08 intrpt ivt.03 .09 intrpt ivt.03 .0A intrpt ivt.03 .0B intrpt ivt.03 .0C intrpt ivt.0C .0D intrpt 0 .0E intrpt 0 .0F intrpt 0 .10 intrpt 0 .11 intrpt 0 .12 intrpt 0 .13 intrpt 0 .14 intrpt 0 .15 intrpt 0 .16 intrpt 0 .17 intrpt 0 .18 intrpt 0 .19 intrpt 0 .1A intrpt 0 .1B intrpt 0 .1C intrpt 0 .1D intrpt 0 .1E intrpt 0 .1F intrpt 0 .20 intrpt ivt.20 .21 intrpt ivt.21 .end: times 512-($-(7C00h+512)) db 0 ;sector3+ org BASE image: mov edi,10000h ;this is purely to easily distinguish mov esi,ivt ;interrupt space from main system mov ecx,(ivt.size/4)+1 rep movsd lidt [idt] jmp cold BASE = 20000h VIDEO = 1 EXIT = "`" NEWLINE = 0Ah BACKSPACE = 08h macro rstdata { mov eax,10000h-4h mov ebp,eax add ebp,4 mov dword [_sp0],eax } macro rstret { push 10000h-200h-4 pop esp } macro rstctrl { mov eax,10000h-400h-4 mov dword [_cp@],eax mov dword [_cp0],eax } include 'inc/macros.inc' include 'host/native/ivt.asm' include 'host/native/dictionary' times 511-($+511) mod 512 db 0 imagesize = $-image