﻿1
00:00:00,060 --> 00:00:06,210
‫Hello and welcome in in this lecture, we are going to prepare our bootloader for being booted on a

2
00:00:06,210 --> 00:00:07,190
‫real machine.

3
00:00:07,560 --> 00:00:11,800
‫Now, in most cases, this current bootloader will run just fine.

4
00:00:12,120 --> 00:00:19,230
‫However, some biosphere's, including my boss, will tamper with your data if you put your bootloader

5
00:00:19,230 --> 00:00:20,670
‫from a USB stick.

6
00:00:21,090 --> 00:00:25,790
‫Now, the reason this happens is because of the bio's parameter block.

7
00:00:25,980 --> 00:00:33,090
‫Some bosses expect this while most Bias's will not corrupt your data and will work just fine with the

8
00:00:33,090 --> 00:00:39,510
‫code that we have here, some will actually stop filling in information and it's important this doesn't

9
00:00:39,510 --> 00:00:40,010
‫happen.

10
00:00:40,020 --> 00:00:46,380
‫So here you can see things like number of sectors per cluster, number of reserve sectors and so on.

11
00:00:47,350 --> 00:00:54,580
‫My bias actually replaces these numbers in memory with numbers of its own, because when we boot from

12
00:00:54,580 --> 00:00:59,350
‫a USB stick, we're actually doing something known as USB emulation.

13
00:01:00,040 --> 00:01:08,340
‫The bias is treating our USB stick as a hard drive or hard disk and allowing us to talk to it as such.

14
00:01:08,560 --> 00:01:12,580
‫So you don't really need to know too much about the bias parameter block right now.

15
00:01:13,000 --> 00:01:18,460
‫You just need to know that some biases assume it's there and we'll start writing data overwriting your

16
00:01:18,460 --> 00:01:20,890
‫code, which can lead to problems.

17
00:01:21,220 --> 00:01:24,200
‫For example, our little program here will boop for me.

18
00:01:24,580 --> 00:01:31,720
‫However, this jump instruction here is corrupted, so it causes my system to just keep running code

19
00:01:31,720 --> 00:01:32,280
‫and ram.

20
00:01:32,650 --> 00:01:33,730
‫It never stops.

21
00:01:35,490 --> 00:01:42,870
‫So we get around this problem by implementing the bias parameter block, we don't we don't have to have

22
00:01:42,870 --> 00:01:43,860
‫real values.

23
00:01:43,860 --> 00:01:49,210
‫It can just be all zeros and we can just have a fake one just to get around this problem.

24
00:01:49,590 --> 00:01:55,680
‫So the first thing we do is, is we add up the size of the bias parameter block, except these three

25
00:01:55,680 --> 00:02:03,510
‫bytes because these three bytes are short jump and no operation and some biases will look for this as

26
00:02:03,510 --> 00:02:03,880
‫well.

27
00:02:03,900 --> 00:02:08,340
‫So we're actually going to write that in, but the rest will be all fake.

28
00:02:08,350 --> 00:02:12,560
‫So I've added those up and I've come up with the value of 33.

29
00:02:12,960 --> 00:02:15,780
‫So that's the size of it, apart from our shot.

30
00:02:16,980 --> 00:02:19,560
‫Also note, this is Osterberg.

31
00:02:19,560 --> 00:02:26,100
‫It's a fantastic resource for people wanting to develop Col's and operating systems is very detailed.

32
00:02:26,280 --> 00:02:28,740
‫Some stuff's out of date, so make sure you check.

33
00:02:28,770 --> 00:02:35,100
‫So if you ever decide to use this website, make sure you check multiple sources if you run into problems.

34
00:02:35,610 --> 00:02:36,010
‫Right.

35
00:02:36,060 --> 00:02:40,470
‫So we need to actually basically just make 33 bytes.

36
00:02:40,500 --> 00:02:46,710
‫Now, bootloader so that if your bias is like mine when it comes in overwrite stuff, it isn't actually

37
00:02:46,710 --> 00:02:47,670
‫damaging your code.

38
00:02:47,670 --> 00:02:50,960
‫It's just writing into your fake BIOS parameter block.

39
00:02:51,300 --> 00:02:53,430
‫So we go back to Visual Studio Code.

40
00:02:54,270 --> 00:02:56,850
‫What we're going to start by making our.

41
00:02:59,320 --> 00:03:03,280
‫Short jump here that expects this three bites in size, right?

42
00:03:03,310 --> 00:03:05,160
‫So it's a short jump in and no operation.

43
00:03:05,890 --> 00:03:11,190
‫So we're going to start by doing that and we do that by creating another label.

44
00:03:11,200 --> 00:03:18,160
‫We'll just go under scroll start and then we're just going to go jump shot start, OK?

45
00:03:18,790 --> 00:03:25,390
‫And then we're just going to go up by here and this this line of code that we have here.

46
00:03:27,650 --> 00:03:29,060
‫We'll need to be copied.

47
00:03:37,660 --> 00:03:39,820
‫And we'll need to place that here.

48
00:03:42,290 --> 00:03:48,440
‫OK, and we're just going to replace the star with step two, something like that, and then we're just

49
00:03:48,440 --> 00:03:49,850
‫going to put step two by there.

50
00:03:50,360 --> 00:03:54,800
‫So I know that's a mouthful, but then our bias parameter block will go in the middle by here.

51
00:03:54,800 --> 00:03:55,100
‫Right.

52
00:03:55,910 --> 00:04:03,830
‫So just to clarify what we've done here, we've created a new label, Underscore Start, that just jumps

53
00:04:03,830 --> 00:04:05,210
‫to our star label here.

54
00:04:05,360 --> 00:04:07,320
‫And this is also a short term project.

55
00:04:07,790 --> 00:04:11,690
‫And we have a new operation here as required for our bias crime to block as well.

56
00:04:12,200 --> 00:04:16,800
‫So then what happens is the problem comes in here, jumps to our star label here, OK?

57
00:04:16,940 --> 00:04:18,710
‫And then we jump to step two.

58
00:04:18,890 --> 00:04:22,600
‫But we we specify the segment zero seven zero.

59
00:04:22,850 --> 00:04:26,420
‫So the code segment register gets replaced with zero seven zero.

60
00:04:26,420 --> 00:04:26,710
‫Right.

61
00:04:27,110 --> 00:04:31,260
‫And then it'll start executing step two, which will print our message.

62
00:04:31,670 --> 00:04:35,240
‫So in here, then we need to go time's.

63
00:04:37,620 --> 00:04:42,000
‫And the value was, I think it was 33 times 33.

64
00:04:44,570 --> 00:04:45,780
‫DB zero.

65
00:04:46,310 --> 00:04:53,420
‫So all this will do then is it will create 33 bytes just after our short jump here and that is our bias

66
00:04:53,420 --> 00:04:54,360
‫parameter block.

67
00:04:54,770 --> 00:04:59,500
‫So if your bias does stop filling in these values, it doesn't corrupt your code.

68
00:04:59,510 --> 00:05:02,390
‫It just fills in these no bytes.

69
00:05:02,840 --> 00:05:04,120
‫So it's perfectly safe.

70
00:05:05,490 --> 00:05:09,930
‫OK, let's just assemble that and see if that works as expected.

71
00:05:14,320 --> 00:05:23,290
‫So we just go, Nazeem Dasch have been booted, Assem, Das Show, Boot Dobbyn, and then we're going

72
00:05:23,290 --> 00:05:24,490
‫to run Kumu.

73
00:05:25,980 --> 00:05:28,990
‫And we see how global, so that works fine on the emulator.

74
00:05:29,760 --> 00:05:33,240
‫And I think now we're ready to test it on your real machine.

