<- previous    index    next ->

Lecture 8 Boot programs and 16-bit

Some history to see how we got here.

Manual switches on first digital computers.
Then teletype input and output.
LGP 30
Punched cards
IBM 650 drum  before magnetic core memory, before RAM
IBM 704 magnetic tape  36 bit words, 6 bit characters
PC 5 1/4 inch floppy disc
PC 3 1/2 inch disc
Compact Disc CD
DVD
USB flash drive

1969 Dennis Ritchie developed the C programmin language then Ken Thompson 
and Dennis Ritchie wrote the first Unix operating system in C.
 Ken and Dennis with their computer

Modern computers are made with a BIOS  Built In Operating System
that is in rom  read only memory. Much smaller and simpler
than Windows, Linux, or MacOSX. Then an assembler must be
created on another computer, then a compiler is created
using the assembler. Then an operating system is created
using the compiler.
To get started, we use the BIOS.

A sample of a basic stand alone bootable program is boot1.asm

; boot1.asm   stand alone program for floppy boot sector
; Compiled using            nasm -f bin boot1.asm
; Written to floppy with    dd if=boot1 of=/dev/fd0
	
; Boot record is loaded at 0000:7C00,
	ORG 7C00h
; load message address into SI register:
	LEA SI,[msg]
; screen function:
	MOV AH,0Eh
print:  MOV AL,[SI]         
	CMP AL,0         
	JZ done		; zero byte at end of string
	INT 10h		; write character to screen.    
     	INC SI         
	JMP print

; wait for 'any key':
done:   MOV AH,0       
    	INT 16h		; waits for key press
			; AL is ASCII code or zero
			; AH is keyboard code

; store magic value at 0040h:0072h to reboot:
;		0000h - cold boot.
;		1234h - warm boot.
	MOV  AX,0040h
	MOV  DS,AX
	MOV  word[0072h],0000h   ; cold boot.
	JMP  0FFFFh:0000h	 ; reboot!

msg 	DB  'Welcome, I have control of the computer.',13,10
	DB  'Press any key to reboot.',13,10
	DB  '(after removing the floppy)',13,10,0
; end boot1

This program could be extended to find or verify the keycodes
that are input (not all keys have ASCII codes).

One keyboard has the following ASCII and keycodes ascii.txt

Before ASCII
BCD Binary Coded Decimal 6 bit characters, only upper case
EBCD  EBCDIC             digits 0 to 9, special + - * / etc
Many computers had 36 bit words with 6 characters per word.
Then 32 bit words with 4 characters per word
Now  64 bit words with 8 ASCII characters per word

American Standard Code for Information Interchange, ASCII
(with keycodes for a particular 104 key keyboard)
  dec is decimal value
  hex is 8-bit hexadecimal value
  key is 104-key PC keyboard keycode in hexadecimal
  type means how to type character (shift not shown) C- for hold control down
  def  is control character definition, e.g. LF line feed, FF form feed,
       CR carriage return, BS back space,
                                          
dec hex key type def   dec hex key type   dec hex key type   dec hex key type
  0  00  13 C-@  NULL   32  20  5E space   64  40  13 @       96  60  11 `
  1  01  3C C-A  SOH    33  21  12 !       65  41  3C A       97  61  3C a
  2  02  50 C-B  STX    34  22  46 "       66  42  50 B       98  62  50 b
  3  03  4E C-C  ETX    35  23  14 #       67  43  4E C       99  63  4E c
  4  04  3E C-D  EOT    36  24  15 $       68  44  3E D      100  64  3E d
  5  05  29 C-E  ENQ    37  25  16 %       69  45  29 E      101  65  29 e
  6  06  3F C-F  ACK    38  26  18 &       70  46  3F F      102  66  3F f
  7  07  40 C-G  BEL    39  27  46 '       71  47  40 G      103  67  40 g
  8  08  41 C-H  BS     40  28  1A (       72  48  41 H      104  68  41 h
  9  09  2E C-I  HT     41  29  1B )       73  49  2E I      105  69  2E i
 10  0A  42 C-J  LF     42  2A  19 *       74  4A  42 J      106  6A  42 j
 11  0B  43 C-K  VT     43  2B  1D +       75  4B  43 K      107  6B  43 k
 12  0C  44 C-L  FF     44  2C  53 ,       76  4C  44 L      108  6C  44 l
 13  0D  52 C-M  CR     45  2D  1C -       77  4D  52 M      109  6D  52 m
 14  0E  51 C-N  SO     46  2E  54 .       78  4E  51 N      110  6E  51 n
 15  0F  2F C-O  SI     47  2F  55 /       79  4F  2F O      111  6F  2F o
 16  10  30 C-P  DLE    48  30  1B 0       80  50  30 P      112  70  30 p
 17  11  27 C-Q  DC1    49  31  12 1       81  51  27 Q      113  71  27 q
 18  12  2A C-R  DC2    50  32  13 2       82  52  2A R      114  72  2A r
 19  13  3D C-S  DC3    51  33  14 3       83  53  3D S      115  73  3D s
 20  14  2B C-T  DC4    52  34  15 4       84  54  2B T      116  74  2B t
 21  15  2D C-U  NAK    53  35  16 5       85  55  2D U      117  75  2D u
 22  16  4F C-V  SYN    54  36  17 6       86  56  4F V      118  76  4F v
 23  17  2E C-W  ETB    55  37  17 7       87  57  28 W      119  77  28 w
 24  18  4D C-X  CAN    56  38  19 8       88  58  4D X      120  78  4D x
 25  19  2C C-Y  EM     57  39  1A 9       89  59  2C Y      121  79  2C y
 26  1A  4C C-Z  SUB    58  3A  45 :       90  5A  4C Z      122  7A  4C z
 27  1B  31 C-[  ESC    59  3B  45 ;       91  5B  31 [      123  7B  31 {
 28  1C  33 C-\  FS     60  3C  53 <       92  5C  33 \      124  7C  33 |
 29  1D  32 C-]  GS     61  3D  3D =       93  5D  32 ]      125  7D  32 }
 30  1E  17 C-^  RS     62  3E  54 >       94  5E  17 ^      126  7E  11 ~
 31  1F  1C C-_  US     63  3F  55 ?       95  5F  1C _      127  7F  34 delete

Additional key codes (most have no ASCII)[must track shift-up, shift-down etc.]
  key type        key type          key type             key type
  01  ESCAPE      10  PAUSE          39 keypad 9 PAGE UP  5D LEFT ALT
  02  F1          1E  BACKSPACE      3A keypad +          5E SPACE
  03  F2          1F  INSERT         3B CAPS LOCK         5F RIGHT ALT
  04  F3          20  HOME           47 ENTER             60 RIGHT CTRL
  05  F4          21  PAGE UP        48 keypad 4 LEFT     61 LEFT ARROW
  06  F5          22  NUM LOCK       49 keypad 5          62 DOWN ARROW
  07  F6          23  keypad /       4A keypad 6 RIGHT    63 RIGHT ARROW
  08  F7          24  keypad *       4B LEFT SHIFT        64 keypad 0 INS
  09  F8          25  keypad -       56 RIGHT SHIFT       65 keypad . DEL
  0A  F9          26  TAB            57 UP ARROW          66 LEFT WINDOWS
  0B  F10         34  DELETE         58 keypad 1 END      67 RIGHT WINDOWS
  0C  F11         35  END            59 keypad 2 DOWN     68 APPLICATION
  0D  F12         36  PAGE DOWN      5A keypad 3 PAGE DN  7E SYS REQ
  0E  PRT SCRN    37  keypad 7 HOME  5B keypad ENTER      7F BREAK
  0F  SCROLL LOCK 38  keypad 8 UP    5C LEFT CTRL


For Project 1, ASCII conversion  Proj1 

 
Now you may wish to download another self booting program,
memtest.bin a binary program.
If you can get this file, undamaged, onto your computer, running
linux, then you can write a floppy disk:

  dd if=memtest.bin of=/dev/fd0

Then do a safe shutdown.
Reboot your computer from the power off state.
You should see information about your computer.
e.g. clock speed, type of CPU, cache sizes, RAM size,
and it will run a very thurough memory test on your RAM.

You will not be able to run a bootable floppy on a UMBC
Intel PC because the BIOS should be set to not boot from
a floppy and the BIOS should be password protected, so you
can not change the BIOS. The machine is probably secured
so you can not get in and change the BIOS chip. 

More on bootable floppies is at nasm boot info

Tower of Bable, many programming languages

Top 9 most used programming languages in 2015 
From IEEE rating
    
2018 most used

learn many programming languages

    <- previous    index    next ->

Other links

Go to top