Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jtauber committed Apr 9, 2012
0 parents commit 3fdf158
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@
Copyright (c) 2012 James Tauber and contributors.

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
@@ -0,0 +1,8 @@
# An Operating System for the DCPU-16

See https://github.com/jtauber/dcpu16py for a Python-based emulator,
assembler, disassembler, debugger for the DCPU-16.

## Features

* some basic video functions for clearing the screen and printing.
68 changes: 68 additions & 0 deletions dcpu16os.asm
@@ -0,0 +1,68 @@
; simple operating system for the DCPU-16

; until we have something like EQU, we'll just document memory locations here

; vidmem = 0x8000
; cursor = 0x1000
; termwidth = 0x1001
; termheight = 0x1002

SET PC, start

:banner DAT "DCPU-16 Operating System", 0

:clear_screen
SET I, 0x8000
SET Z, [0x1001]
MUL Z, [0x1002]
ADD Z, 0x8000 ; z = (termwidth * termheight) + vidmem
:clear_screen_loop ; loop i through video memory
SET [I], 0x20 ; clearing screen
ADD I, 1
IFE I, Z
SET PC, clear_screen_done
SET PC, clear_screen_loop
:clear_screen_done
SET [0x1000], 0 ; set cursor to top left
SET PC, POP ; return

:println
JSR print
JSR newline
SET PC, POP ; return

:print ; prints string starting at X
SET I, X
:print_loop ; loop through string at A
IFE [I], 0 ; if hit NULL
SET PC, POP ; return
SET A, [I]
JSR print_char
ADD I, 1
SET PC, print_loop

; doesn't scroll when at end yet
:print_char ; print character in A
SET Y, [0x1000] ; set Y to cursor
SET [0x8000 + Y], A
ADD [0x1000], 1 ; move cursor
SET PC, POP ; return

:newline ; clears to end of line
SET Y, [0x1000]
MOD Y, [0x1001] ; y = cursor
IFE Y, 0
SET PC, POP
SET [0x8000 + Y], 0x20
ADD [0x1000], 1
SET PC, newline

:start
SET [0x1001], 80 ; terminal width
SET [0x1002], 24 ; terminal height
JSR clear_screen
SET X, banner
JSR println

:halt
SET PC, halt

0 comments on commit 3fdf158

Please sign in to comment.