about summary refs log tree commit diff stats
path: root/baremetal
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2021-01-09 15:38:03 -0800
committerKartik Agaram <vc@akkartik.com>2021-01-09 18:20:28 -0800
commitdbd7082a0ed09ee06401d0af06ce24e89e87b189 (patch)
treef71f3886e0c99e7ea1e8a1c5bc6356501582683b /baremetal
parent952ccfc66e829f04978bb107407a1e97d49fc9e2 (diff)
downloadmu-dbd7082a0ed09ee06401d0af06ce24e89e87b189.tar.gz
7489 - include GNU Unifont
https://en.wikipedia.org/wiki/GNU_Unifont#The_.hex_font_format
http://unifoundry.com/unifont/index.html

Since GNU Unifont is covered under the GPL v2, so I believe is this repo.
Diffstat (limited to 'baremetal')
-rw-r--r--baremetal/README.md2
-rw-r--r--baremetal/boot.hex251
-rw-r--r--baremetal/ex1.hex4
-rw-r--r--baremetal/ex2.hex2
-rw-r--r--baremetal/ex3.hex2
5 files changed, 252 insertions, 9 deletions
diff --git a/baremetal/README.md b/baremetal/README.md
index 4d1c2876..96e7c900 100644
--- a/baremetal/README.md
+++ b/baremetal/README.md
@@ -30,7 +30,7 @@ operating systems. There's also currently no code/data segment separation,
 just labels and bytes. I promise not to write self-modifying code. Security
 and sandboxing is still an open question.
 
-Most programs here assume `main` starts at address 0x8800 (3KB or 6 disk
+Most programs here assume `main` starts at address 0x9000 (7KB or 14 disk
 sectors past the BIOS entrypoint). See baremetal/boot.hex for details.
 
 So far the programs have only been tested in Qemu and Bochs emulators.
diff --git a/baremetal/boot.hex b/baremetal/boot.hex
index f6ded4aa..3f78ca7a 100644
--- a/baremetal/boot.hex
+++ b/baremetal/boot.hex
@@ -1,4 +1,4 @@
-# Code for the first 2 disk sectors, that all programs in this directory need:
+# Code for the first disk sector that all programs in this directory need:
 #   - load sectors past the first (using BIOS primitives) since only the first is available by default
 #     - if this fails, print 'D' at top-left of screen and halt
 #   - initialize a minimal graphics mode
@@ -31,7 +31,7 @@
 #   - can't use any syscalls
 #   - can't print text to video memory (past these boot sectors)
 #   - must only print raw pixels (256 colors) to video memory (resolution 1024x768)
-#   - must store their entry-point at address 0x8800
+#   - must store their entry-point at address 0x9000
 
 ## 16-bit entry point
 
@@ -64,7 +64,7 @@
   b5 00  # ch <- 0  # cylinder 0
   b6 00  # dh <- 0  # track 0
   b1 02  # cl <- 2  # second sector, 1-based
-  b0 10  # al <- 16  # number of sectors to read; all sectors must be in a single track
+  b0 20  # al <- 32  # number of sectors to read; all sectors must be in a single track
   # address to write sectors to = es:bx = 0x7e00, contiguous with boot segment
   bb 00 00  # bx <- 0
   8e c3  # es <- bx
@@ -205,7 +205,7 @@ e9 fb ff  # loop forever
 
   # initialization is done; enable interrupts
   fb
-  e9 01 0b 00 00  # jump to 0x8800 [label]
+  e9 01 13 00 00  # jump to 0x9000 [label]
 
 # padding
 # ff:
@@ -428,7 +428,10 @@ e9 fb ff  # loop forever
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 
+## the rest of this file has data
+
 # offset 400 (address 0x8000):
+# translating keys to ASCII {{{
 # keyboard normal map:
 00
 #  es
@@ -585,6 +588,246 @@ e9 fb ff  # loop forever
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# }}}
+
 # offset c00 (address 0x8800)
+# Bitmaps for some ASCII characters (soon Unicode) {{{
+# Part of GNU Unifont
+# 8px wide, 16px tall
+# Based on http://unifoundry.com/pub/unifont/unifont-13.0.05/font-builds/unifont-13.0.05.hex.gz
+# See https://en.wikipedia.org/wiki/GNU_Unifont#The_.hex_font_format
+# Website: http://unifoundry.com/unifont/index.html
+# License: http://unifoundry.com/LICENSE.txt (GPL v2)
+# Each line below is a bitmap for a single character.
+#   Each byte is a bitmap for a single row of 8 pixels.
+
+# some unprintable ASCII chars
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# 0x20 = space
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# !
+  00 00 00 00 08 08 08 08 08 08 08 00 08 08 00 00
+# "
+  00 00 22 22 22 22 00 00 00 00 00 00 00 00 00 00
+# 0x23 = '#'
+  00 00 00 00 12 12 12 7e 24 24 7e 48 48 48 00 00
+# $
+  00 00 00 00 08 3e 49 48 38 0e 09 49 3e 08 00 00
+# %
+  00 00 00 00 31 4a 4a 34 08 08 16 29 29 46 00 00
+# &
+  00 00 00 00 1c 22 22 14 18 29 45 42 46 39 00 00
+# '
+  00 00 08 08 08 08 00 00 00 00 00 00 00 00 00 00
+# (
+  00 00 00 04 08 08 10 10 10 10 10 10 08 08 04 00
+# )
+  00 00 00 20 10 10 08 08 08 08 08 08 10 10 20 00
+# *
+  00 00 00 00 00 00 08 49 2a 1c 2a 49 08 00 00 00
+# +
+  00 00 00 00 00 00 08 08 08 7f 08 08 08 00 00 00
+# ,
+  00 00 00 00 00 00 00 00 00 00 00 00 18 08 08 10
+# -
+  00 00 00 00 00 00 00 00 00 3c 00 00 00 00 00 00
+# .
+  00 00 00 00 00 00 00 00 00 00 00 00 18 18 00 00
+# /
+  00 00 00 00 02 02 04 08 08 10 10 20 40 40 00 00
+# 0x30 = '0'
+  00 00 00 00 18 24 42 46 4a 52 62 42 24 18 00 00
+# 1
+  00 00 00 00 08 18 28 08 08 08 08 08 08 3e 00 00
+# 2
+  00 00 00 00 3c 42 42 02 0c 10 20 40 40 7e 00 00
+# 3
+  00 00 00 00 3c 42 42 02 1c 02 02 42 42 3c 00 00
+# 4
+  00 00 00 00 04 0c 14 24 44 44 7e 04 04 04 00 00
+# 5
+  00 00 00 00 7e 40 40 40 7c 02 02 02 42 3c 00 00
+# 6
+  00 00 00 00 1c 20 40 40 7c 42 42 42 42 3c 00 00
+# 7
+  00 00 00 00 7e 02 02 04 04 04 08 08 08 08 00 00
+# 8
+  00 00 00 00 3c 42 42 42 3c 42 42 42 42 3c 00 00
+# 9
+  00 00 00 00 3c 42 42 42 3e 02 02 02 04 38 00 00
+# :
+  00 00 00 00 00 00 18 18 00 00 00 18 18 00 00 00
+# ;
+  00 00 00 00 00 00 18 18 00 00 00 18 08 08 10 00
+# <
+  00 00 00 00 00 02 04 08 10 20 10 08 04 02 00 00
+# =
+  00 00 00 00 00 00 00 7e 00 00 00 7e 00 00 00 00
+# >
+  00 00 00 00 00 40 20 10 08 04 08 10 20 40 00 00
+# ?
+  00 00 00 00 3c 42 42 02 04 08 08 00 08 08 00 00
+# 0x40 = @
+  00 00 00 00 1c 22 4a 56 52 52 52 4e 20 1e 00 00
+# A
+  00 00 00 00 18 24 24 42 42 7e 42 42 42 42 00 00
+# B
+  00 00 00 00 7c 42 42 42 7c 42 42 42 42 7c 00 00
+# C
+  00 00 00 00 3c 42 42 40 40 40 40 42 42 3c 00 00
+# D
+  00 00 00 00 78 44 42 42 42 42 42 42 44 78 00 00
+# E
+  00 00 00 00 7e 40 40 40 7c 40 40 40 40 7e 00 00
+# F
+  00 00 00 00 7e 40 40 40 7c 40 40 40 40 40 00 00
+# G
+  00 00 00 00 3c 42 42 40 40 4e 42 42 46 3a 00 00
+# H
+  00 00 00 00 42 42 42 42 7e 42 42 42 42 42 00 00
+# I
+  00 00 00 00 3e 08 08 08 08 08 08 08 08 3e 00 00
+# J
+  00 00 00 00 1f 04 04 04 04 04 04 44 44 38 00 00
+# K
+  00 00 00 00 42 44 48 50 60 60 50 48 44 42 00 00
+# L
+  00 00 00 00 40 40 40 40 40 40 40 40 40 7e 00 00
+# M
+  00 00 00 00 42 42 66 66 5a 5a 42 42 42 42 00 00
+# N
+  00 00 00 00 42 62 62 52 52 4a 4a 46 46 42 00 00
+# O
+  00 00 00 00 3c 42 42 42 42 42 42 42 42 3c 00 00
+# 0x50 = P
+  00 00 00 00 7c 42 42 42 7c 40 40 40 40 40 00 00
+# Q
+  00 00 00 00 3c 42 42 42 42 42 42 5a 66 3c 03 00
+# R
+  00 00 00 00 7c 42 42 42 7c 48 44 44 42 42 00 00
+# S
+  00 00 00 00 3c 42 42 40 30 0c 02 42 42 3c 00 00
+# T
+  00 00 00 00 7f 08 08 08 08 08 08 08 08 08 00 00
+# U
+  00 00 00 00 42 42 42 42 42 42 42 42 42 3c 00 00
+# V
+  00 00 00 00 41 41 41 22 22 22 14 14 08 08 00 00
+# W
+  00 00 00 00 42 42 42 42 5a 5a 66 66 42 42 00 00
+# X
+  00 00 00 00 42 42 24 24 18 18 24 24 42 42 00 00
+# Y
+  00 00 00 00 41 41 22 22 14 08 08 08 08 08 00 00
+# Z
+  00 00 00 00 7e 02 02 04 08 10 20 40 40 7e 00 00
+# [
+  00 00 00 0e 08 08 08 08 08 08 08 08 08 08 0e 00
+# \
+  00 00 00 00 40 40 20 10 10 08 08 04 02 02 00 00
+# ]
+  00 00 00 70 10 10 10 10 10 10 10 10 10 10 70 00
+# ^
+  00 00 18 24 42 00 00 00 00 00 00 00 00 00 00 00
+# _
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 7f 00
+# 0x60 = backtick
+  00 20 10 08 00 00 00 00 00 00 00 00 00 00 00 00
+# a
+  00 00 00 00 00 00 3c 42 02 3e 42 42 46 3a 00 00
+# b
+  00 00 00 40 40 40 5c 62 42 42 42 42 62 5c 00 00
+# c
+  00 00 00 00 00 00 3c 42 40 40 40 40 42 3c 00 00
+# d
+  00 00 00 02 02 02 3a 46 42 42 42 42 46 3a 00 00
+# e
+  00 00 00 00 00 00 3c 42 42 7e 40 40 42 3c 00 00
+# f
+  00 00 00 0c 10 10 10 7c 10 10 10 10 10 10 00 00
+# g
+  00 00 00 00 00 02 3a 44 44 44 38 20 3c 42 42 3c
+# h
+  00 00 00 40 40 40 5c 62 42 42 42 42 42 42 00 00
+# i
+  00 00 00 08 08 00 18 08 08 08 08 08 08 3e 00 00
+# j
+  00 00 00 04 04 00 0c 04 04 04 04 04 04 04 48 30
+# k
+  00 00 00 40 40 40 44 48 50 60 50 48 44 42 00 00
+# l
+  00 00 00 18 08 08 08 08 08 08 08 08 08 3e 00 00
+# m
+  00 00 00 00 00 00 76 49 49 49 49 49 49 49 00 00
+# n
+  00 00 00 00 00 00 5c 62 42 42 42 42 42 42 00 00
+# o
+  00 00 00 00 00 00 3c 42 42 42 42 42 42 3c 00 00
+# 0x70 = p
+  00 00 00 00 00 00 5c 62 42 42 42 42 62 5c 40 40
+# q
+  00 00 00 00 00 00 3a 46 42 42 42 42 46 3a 02 02
+# r
+  00 00 00 00 00 00 5c 62 42 40 40 40 40 40 00 00
+# s
+  00 00 00 00 00 00 3c 42 40 30 0c 02 42 3c 00 00
+# t
+  00 00 00 00 10 10 10 7c 10 10 10 10 10 0c 00 00
+# u
+  00 00 00 00 00 00 42 42 42 42 42 42 46 3a 00 00
+# v
+  00 00 00 00 00 00 42 42 42 24 24 24 18 18 00 00
+# w
+  00 00 00 00 00 00 41 49 49 49 49 49 49 36 00 00
+# x
+  00 00 00 00 00 00 42 42 24 18 18 24 42 42 00 00
+# y
+  00 00 00 00 00 00 42 42 42 42 42 26 1a 02 02 3c
+# z
+  00 00 00 00 00 00 7e 02 04 08 10 20 40 7e 00 00
+# {
+  00 00 00 0c 10 10 08 08 10 20 10 08 08 10 10 0c
+# |
+  00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08
+# }
+  00 00 00 30 08 08 10 10 08 04 08 10 10 08 08 30
+# ~
+  00 00 00 31 49 46 00 00 00 00 00 00 00 00 00 00
+# 0x7f = del (unused)
+  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+# }}}
+
+# offset 1400 (address 0x9000)
 
 # vim:ft=subx
diff --git a/baremetal/ex1.hex b/baremetal/ex1.hex
index 8dadf0e2..49f6e446 100644
--- a/baremetal/ex1.hex
+++ b/baremetal/ex1.hex
@@ -13,7 +13,7 @@
 # Or:
 #   bochs -f baremetal/boot.bochsrc  # boot.bochsrc loads disk.img
 
-# main:  (address 0x8800)
-e9 fb ff ff ff  # jump to address 0x8800
+# main:  (address 0x9000)
+e9 fb ff ff ff  # jump to main, hanging indefinitely
 
 # vim:ft=subx
diff --git a/baremetal/ex2.hex b/baremetal/ex2.hex
index 52150b7f..439a0e03 100644
--- a/baremetal/ex2.hex
+++ b/baremetal/ex2.hex
@@ -13,7 +13,7 @@
 # Expected output:
 #   html/baremetal.png
 
-# main:  (address 0x8800)
+# main:  (address 0x9000)
 
 # ecx <- LFB
 8b  # copy *rm32 to r32
diff --git a/baremetal/ex3.hex b/baremetal/ex3.hex
index 92664a23..694de37d 100644
--- a/baremetal/ex3.hex
+++ b/baremetal/ex3.hex
@@ -11,7 +11,7 @@
 # Or:
 #   bochs -f baremetal/boot.bochsrc  # boot.bochsrc loads disk.img
 
-# main:  (address 0x8800)
+# main:  (address 0x9000)
 
 # eax <- LFB
 8b  # copy *rm32 to r32