Due to its ever-changing nature, my code is kind of a mess. Kind of awkward at times, I guess. The only copy has been that which I have written to my floppy's boot sector.
Here is the most recent version of it. To keep it small, I hard-coded all register values (after first confirming them). Below, all such values have been replaced with question marks. At least, I attempted to replace all of them...
To aid in reading it, I have translated it into assembly. It is still probably not the easiest thing to read, but maybe you guys can find any problems in/with it.
Code: Select all
FA ... CLI
31 C0 ... XOR AX, AX
8E D8 ... MOV DS, AX
66 B8 04 ?? ?? 80 ... MOV EAX, 80????04 (bits 23:8 are bus, device, and function)
BA F8 0C ... MOV DX, 0CF8
66 EF ... OUT DX, EAX
BA FC 0C ... MOV DX, 0CFC
66 B8 05 00 00 00 ... MOV EAX, 00000005
66 EF ... OUT DX, EAX
B9 00 10 ... MOV CX, 1000
- start of loop-
66 BB 00 80 00 00 ... MOV EBX, 00008000 (the base of my frame list)
66 67 C7 03 00 7D 00 00 ... MOV [EBX], 00007D00 (location of TD)
81 C3 04 ... ADD BX, 04
E2 F3 ... LOOP "start of loop"
BA ?? ?? ... MOV DX, ???? (legacy support register, base + C0)
B8 40 8F ... MOV AX, 8F40
EF ... OUT DX, AX
FB ... STI
66 B9 08 00 00 00 ... MOV ECX, 00000008
- waiting loop one -
F4 ... HLT
E2 FD ... LOOP "waiting loop one"
FA ... CLI
BA ?? ?? ... MOV DX, ???? (command register, base)
B8 02 00 ... MOV AX, 0002
EF ... OUT DX, AX
FB ... STI
66 B9 08 00 00 00 ... MOV ECX, 00000008
- waiting loop two -
F4 ... HLT
E2 FD ... LOOP "waiting loop two"
FA ... CLI
BA ?? ?? ... MOV DX, ???? (frame list base address register, base + 8)
66 B8 00 80 00 00 ... MOV EAX, 00008000
66 EF ... OUT DX, EAX
BA ?? ?? ... MOV DX, ???? (frame number register, base + 6)
B8 00 00 ... MOV AX, 0000
EF ... OUT DX, AX
FB ... STI
66 B9 08 00 00 00 ... MOV EAX, 00000008
- waiting loop three -
F4 ... HLT
E2 FD ... LOOP "waiting loop three"
FA ... CLI
BA ?? ?? ... MOV DX, ???? (status and control register, base + 10)
B8 00 02 ... MOV AX, 0200
EF ... OUT DX, AX
BA ?? ?? ... MOV DX, ???? (port 2 status and control register, base + 12)
B8 00 02 ... MOV AX, 0200
EF ... OUT DX, AX
FB ... STI
66 B9 08 00 00 00 ... MOV ECX, 00000008
- waiting loop four -
F4 ... HLT
E2 FD ... LOOP "waiting loop four"
FA ... CLI
BA ?? ?? ... MOV DX, ???? (port 1 status and control register, base + 10)
B8 00 00 ... MOV AX, 0000
EF ... OUT DX, AX
BA ?? ?? ... MOV DX, ???? (port 2 status and control register, base + 12)
B8 00 00 ... MOV AX, 0000
EF ... OUT DX, AX
FB ... STI
66 B9 08 00 00 00 ... MOV ECX, 00000008
- waiting loop five -
F4 ... HLT
E2 FD ... LOOP "waiting loop five"
FA ... CLI
BA ?? ?? ... MOV DX, ???? (port 2 status and control register, base + 12)
B8 4E 00 ... MOV AX, 004E
EF ... OUT DX, AX
FB ... STI
66 B9 08 00 00 00 ... MOV ECX, 00000008
- waiting loop six -
F4 ... HLT
E2 FD ... LOOP "waiting loop six"
FA ... CLI
BA ?? ?? ... MOV DX, ???? (interrupt enable register, base + 4)
B0 00 00 ... MOV AX, 0000
EF ... OUT DX, AX
FB ... STI
66 B9 08 00 00 00 ... MOV ECX, 00000008
- waiting loop seven -
F4 ... HLT
E2 FD ... LOOP "waiting loop seven"
FA ... CLI
BA ?? ?? ... MOV DX, ???? (command register, base)
B8 01 00 ... MOV AX, 0001
EF ... OUT DX, AX
FB ... STI
66 B9 08 00 00 00 ... MOV ECX, 00000008
- waiting loop eight -
F4 ... HLT
E2 FD ... LOOP "waiting loop eight"
FA ... CLI
E4 61 ... IN AL, 61
0C 03 ... OR AL, 03
E6 61 ... OUT 61, AL
- status loop -
B4 0A ... MOV AH, 0A
A0 06 7D ... MOV AL, [7D06]
BB 07 00 ... MOV BX, 0007
B9 01 00 ... MOV CX, 0001
CD 10 ... INT 10
EB F1 ... LOOP "status loop"
01 00 00 00 00 00 80 00 2D 00 E0 00 20 7D 00 00 = TD (located at byte 100)
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 01 00 05 00 = SET_ADDRESS request
55 AA ... boot signature
I am currently looking back over that tatOS source code to see if I can find any differences that might be causing whatever the problem is.
As you can see, my timing mechanism is very crude right now. Though, please note that this computer causes way more than one interrupt per second (hence why I loop eight times for each halt loop). The entire code takes no more than maybe two to three seconds to complete.
I have tried it with different lengths of timing loops. From no timing loops to ridiculously long ones, the end result is the same. So, I do not think that my timing is the problem. Unless the timing of everything needs to be unbelievably precise, that is.