├── .gitignore ├── LICENSE ├── README.md ├── bochsrc ├── ebin.img ├── main.asm └── spurdo.png /.gitignore: -------------------------------------------------------------------------------- 1 | bx_enh_dbh.ini -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2018 cmp (Ebin Corporation) 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Ebin 2 | 3 | # Ebin-DOS 4 | The very functional operating system\*. 5 | 6 | \* Technically it's just a bootloader, there's no kernel, there's nothing really. 7 | 8 | ## Prerequisites 9 | * nasm (building) 10 | * qemu (testing) 11 | * bochs (debugging) 12 | 13 | ## Building 14 | ``` 15 | $ nasm -f bin -o ebin.img main.asm 16 | ``` 17 | 18 | ## Don't want to build it 19 | The image is included, so no need. 20 | 21 | ## Testing 22 | ``` 23 | $ qemu-system-i386 -hda ebin.img 24 | ``` 25 | It's **not** a floppy image, even if it is 1.44 MB. The bootup procedure uses LBA, which requires a hard drive. ~~Fuck CHS.~~ 26 | 27 | However, if you do boot it up as a floppy, you'll get a very nice error message. 28 | 29 | ## Debugging 30 | `bochsrc` is included, but to be honest there's nothing to debug. Also, the CHS numbers don't match. Just hit continue. 31 | 32 | ## Hacking 33 | Read the source code. Don't consider this assembly learning material though, I barely know it myself. 34 | 35 | ## DOS? 36 | ~~It's an OS that runs from a hard drive, so, yes.~~ 37 | 38 | Technically it runs from a hard drive, it counts. It doesn't? Fuck you, I made the name. 39 | 40 | ## License 41 | ISC. See the [LICENSE](LICENSE) file. 42 | -------------------------------------------------------------------------------- /bochsrc: -------------------------------------------------------------------------------- 1 | cpu: count=1, reset_on_triple_fault=0 2 | 3 | display_library: x, options="gui_debug" 4 | 5 | megs: 256 6 | 7 | clock: sync=realtime, time0=local 8 | 9 | ata0-master: type=disk, path="ebin.img", mode=flat, cylinders=80, heads=2, spt=63 10 | 11 | boot: c 12 | 13 | mouse: enabled=0 14 | 15 | magic_break: enabled=1 -------------------------------------------------------------------------------- /ebin.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x-t/ebin-dos/add00059dfceb565dde00893b3ff3369044e2af3/ebin.img -------------------------------------------------------------------------------- /main.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (C) 2018 cmp 2 | ; Licensed under the ISC License 3 | ; Check the LICENSE file that 4 | ; was distributed with this copy. 5 | ;forked for the shirt lmao 6 | 7 | bits 16 ; x86 considered harmful 8 | org 0x7c00 ; We land here 9 | 10 | jmp short start ; Jump to the useful bit 11 | 12 | error: db "Something happened.", 0x0D, 0x0A, "Something happened.", 0x00 13 | 14 | ; print_srt 15 | ; Prints a 0x00 terminated string 16 | ; <- SI - string to print 17 | print_str: 18 | push si ; Yes 19 | push ax 20 | .loop: 21 | lodsb ; Load another character from si 22 | test al, al ; Test if al=0 23 | jz .exit ; If so, jump to .exit 24 | ; Otherwise, continue 25 | mov ah, 0x0E ; Calling BIOS print (0x10), ah=0E 26 | int 0x10 ; Print char from al (BIOS) 27 | jmp .loop ; Keep looping 28 | .exit: 29 | pop ax 30 | pop si 31 | ret ; Return from function 32 | 33 | ; halt 34 | ; Halts the shit 35 | halt: 36 | hlt ; Halt it all 37 | jmp halt ; Keep halting 38 | 39 | ; The DA packet used to load the rest of the "OS" 40 | align 4 41 | da_packet: 42 | db 0x10 ; Packet size 43 | db 0x00 ; ???????? 44 | dw 16 ; Number of sectors 45 | dw 0x7e00 ; Buffer 46 | dw 0x00 47 | dd 0x01 ; Read here ok 48 | dd 0x00 49 | 50 | ; Main bit 51 | start: 52 | xor ax, ax ; Clear ax 53 | cli 54 | jmp 0x0000:boiler_my_plates 55 | boiler_my_plates: 56 | mov ss, ax ; Segment bullshit 57 | mov ds, ax 58 | mov es, ax 59 | mov sp, 0x7bf0 ; Stack shit 60 | sti 61 | 62 | clc ; Clear carry 63 | mov dl, 0x80 ; The C drive 64 | mov si, da_packet ; The DA packet 65 | mov ah, 0x42 ; CHS BTFO 66 | int 0x13 67 | jc short .error ; Oh, shit... 68 | jmp shell_main ; Phew 69 | 70 | .error: 71 | mov si, error ; Something happened 72 | call print_str ; Something happened 73 | 74 | jmp halt 75 | 76 | 77 | times 0x0200 - 2 - ($ - $$) db 0 ; Fill it up 78 | dw 0x0AA55 ; Boot you son of a bitch 79 | 80 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 81 | 82 | intro: db "Ebin-DOS", 0x0D, 0x0A, "Copyright (C) Ebin Corporation", 0x0D, 0x0A, 0x00 83 | shell_ps: db ":DD\> ", 0x00 84 | endl: db 0x0D, 0x0A, 0x00 85 | deletchar: db 0x08, 0x20, 0x08, 0x00 86 | input: times 128 db 0x00 87 | p2: db "' detected to be ebin, aborting.", 0x00 88 | p1: db "'", 0x00 89 | spurdo: db "spurdo", 0x00 90 | absolute_ebin: db ":DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD EBINN", 0x00 91 | 92 | ; shell_main 93 | ; Boots up the shell 94 | shell_main: 95 | mov al, 0x02 ; Set video mode (clears the screen) 96 | xor ah, ah 97 | int 0x10 98 | 99 | mov si, intro ; Print intro 100 | call print_str 101 | 102 | mov si, endl ; Newline 103 | call print_str 104 | jmp shell ; Jump to the shell 105 | jmp halt ; (dead) Halt the system 106 | 107 | ; print_harmful 108 | ; Prints the harmful message 109 | print_harmful: 110 | push si 111 | 112 | mov si, input ; Put it here 113 | mov di, spurdo ; :DDDDD 114 | call strcmp ; Compare 115 | cmp dl, 0x01 ; Same? 116 | je .ebin ; YES, EBIN! 117 | 118 | mov si, p1 ; Print the first part of message 119 | call print_str 120 | mov si, input ; Print the input 121 | call print_str 122 | mov si, p2 ; Print the second part of the message 123 | call print_str 124 | jmp .average_ebin ; It's ok ebin 125 | 126 | .ebin: 127 | mov si, absolute_ebin ; :::::::DDDDDDDDDDDDDDDDDDD 128 | call print_str ; EBINN 129 | 130 | .average_ebin: 131 | mov si, endl ; Newline 132 | call print_str 133 | call clear_input ; Clear the input string 134 | pop si 135 | ret ; Return 136 | 137 | ; strcmp 138 | ; Compare string 139 | ; <- DS:SI; ES:DI = strings 140 | ; -> DL = 0x01 if equal, 0x00 if not 141 | strcmp: 142 | push ax ; save these 143 | push si 144 | push di 145 | .loop: 146 | lodsb ; Load character 147 | mov ah, byte [es:di] ; Move a byte from second string 148 | inc di ; Increment pointer 149 | cmp al, ah ; Compare characters from string 150 | jne .ne ; Not equal, get out 151 | test al, al ; We hit 0 152 | jz .e ; They're a match! <3 (gay) 153 | jmp .loop ; We jumped nowhere, continue 154 | .ne: 155 | xor dl, dl ; Clear dl 156 | jmp .done ; Out 157 | .e: 158 | mov dl, 0x01 ; Happy couple, still gay 159 | .done: 160 | pop di 161 | pop si 162 | pop ax 163 | ret 164 | 165 | ; clear_input 166 | ; Clears the input string 167 | clear_input: 168 | push di 169 | push cx 170 | mov di, input ; Move input to di 171 | xor al, al ; Set al to 0 172 | mov cx, 128 ; Set cx to 128 173 | cld ; Go forwards 174 | rep stosb ; Store zeroes until the end 175 | pop cx 176 | pop di 177 | ret ; Return 178 | 179 | ; shell 180 | ; Main part of the "shell" 181 | shell: 182 | push si 183 | push di 184 | push cx 185 | mov si, shell_ps ; Print the shell prompt 186 | mov di, input 187 | mov cx, 127 188 | call print_str 189 | .loop_inp: 190 | xor ah, ah ; Get char to al 191 | int 0x16 192 | cmp al, 0x0D ; Check for enter 193 | je .newline ; If so, it's a newline 194 | cmp al, 0x08 ; Check for backspace 195 | je .delet ; If so, delete last character 196 | test al, al ; Check if al was zero (special key) 197 | jz .loop_inp ; If so, just keep looping 198 | mov ah, 0x0E ; Print the input 199 | int 0x10 200 | test cx, cx ; Check for overflow 201 | jz .delet ; If so, do a backspace 202 | cld ; Go forwards 203 | stosb ; Store our character into input 204 | dec cx ; Decrement cx (char stored) 205 | jmp .loop_inp ; Keep looping 206 | .newline: 207 | mov si, endl ; 0x0D, 0x0A, 0x00 208 | call print_str ; Print the newline 209 | call print_harmful ; Print that it's harmful 210 | pop cx 211 | pop di 212 | pop si 213 | jmp shell ; Initialize shell again 214 | .delet: 215 | cmp cx, 127 ; Check if it's the start of string 216 | je .loop_inp ; If so, don't delete anything 217 | mov si, deletchar ; 0x08, 0x20, 0x08, 0x00 218 | call print_str ; Print the deleting character (wot) 219 | dec di ; Decrement the pointer 220 | xor al, al ; Store a zero in the input 221 | stosb 222 | dec di ; Decrement again 223 | inc cx ; Increment cx (char deleted) 224 | jmp .loop_inp ; Keep looping 225 | 226 | times 1474560 - ($ - $$) db 0 ; Stuff it up 227 | -------------------------------------------------------------------------------- /spurdo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/x-t/ebin-dos/add00059dfceb565dde00893b3ff3369044e2af3/spurdo.png --------------------------------------------------------------------------------