real-mode

Switching to (un)real mode, reading disk and switching back to protected mode

最后都变了- 提交于 2020-01-06 06:08:25
问题 My question is quite a bit theoretical, but I want to implement disk r/w to my Operating system, while I know how to do it in protected mode, it would take too long to implement ATAPI+ATA+FDC drivers (to make my OS boot on any device). I took two ideas to consider: Make my OS bootable only from pendrive (so I can handle only pendrive for disk r/w and it wouldn't take as much time), and jump to real mode, read sector, and jump back to protected mode . But AFAIK i have to be in conventional

Loading second stage of a bootloader

一笑奈何 提交于 2019-12-30 06:49:06
问题 I'm trying to create a small operating system for x86 machines and started writing the code for a fairly minimal bootloader. The bootloader I created is quite simple, it loads a small second bootloader from the sector located directly after the master boot record and jumps to that code. The bootloader code in the master boot record seems to run fine, the problem occurs when it tries to jump to the second stage bootloader. This second stage bootloader is supposed to output a letter indicating

Printing out a number in assembly language?

这一生的挚爱 提交于 2019-12-28 02:06:19
问题 mov al,10 add al,15 How do I print the value of ' al '? 回答1: Have you tried int 21h service 2? DL is the character to print. mov dl,'A' ; print 'A' mov ah,2 int 21h To print the integer value, you'll have to write a loop to decompose the integer to individual characters. If you're okay with printing the value in hex, this is pretty trivial. If you can't rely on DOS services, you might also be able to use the BIOS int 10h with AL set to 0Eh or 0Ah . 回答2: Assembly language has no direct means

Weird Errors While Reading Disk

此生再无相见时 提交于 2019-12-24 07:31:16
问题 So, I've been working on a hobby project. Creating my own Operating System. I started a while back but dropped it until maybe a couple nights ago. I just fixed an oversight that caused nothing to be read from the sectors I want to read from. With that error out of the way, a new one has came about and I honestly don't even know where to begin debugging this one. I am coding a Master Boot Record and debugging it with GDB and QEMU, here is the code to my master boot record (It was assembled

(nasm x86 real mode) How to write/read strings in boot-loaded sector?

旧街凉风 提交于 2019-12-24 05:38:12
问题 I'm using NASM to write a minimal OS for x86 real mode for educational purposes. I want to use the 512-byte boot sector to load a larger sector that contains the rest of the OS. I've successfully created a boot sector that loads another sector, but I cannot seem to write/read strings within the loaded sector. Here is my code: bits 16 mov ax, 0x7c0 mov ds, ax jmp code ;; Write bootStr to boot sector. bootStr db "AAA" code: ;; for int 0x10 mov ah, 0x0e ;; Print first char of bootStr. mov di,

Write to address without segment register

ぃ、小莉子 提交于 2019-12-24 00:32:36
问题 I know this code will actually write data to ds:[100h] mov [100h], ax But how can I write to linear address 100H directly without using any segment register for a segment base? 回答1: There is no way to get around segment register; every memory access is relative to some segment register. If you want to write to an absolute address, first load a segment register with an appropriate segment: xor cx, cx mov es, cx ; es = 0000 mov [es:100h], ax ; [0000:0100] = ax To load a linear address larger

Is there a standard BIOS Int 10h video mode for 43 lines or more?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 20:07:21
问题 I'm writing code which runs in real mode before any OS is loaded. Part of my program involves a dump of information to the video display, and the standard 80x25 text mode is not cutting it. Many versions of Windows and other OSes seem to have no trouble switching to some larger text mode, 43 line I think, when they show kernel panics. I know larger text modes have been around a long time so I would expect there's at least one standard mode. There's a pretty large list of BIOS video modes here

Understanding of boot loader assembly code and memory locations

谁说我不能喝 提交于 2019-12-22 12:30:11
问题 I want to check my understanding of the following bootloader code: BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after this bootloader add ax, 288 ; (4096 + 512) / 16 bytes per paragraph mov ss, ax mov sp, 4096 mov ax, 07C0h ; Set data segment to where we're loaded mov ds, ax mov si, text_string ; Put string position into SI call print_string ; Call our string-printing routine jmp $ ; Jump here - infinite loop! text_string db 'This is my cool new OS!', 0 print_string: ; Routine: output

Simplest chainloading a boot manager

笑着哭i 提交于 2019-12-22 10:49:12
问题 In order to boot from flash memory drive we load disks using the BIOS interrupt 13h in real mode with specifying the disk 0x80. Another disks should be accessed by 0x81, 0x82... as mentioned over this link I am trying to make my simple GRUB . My very first step is to boot from flash memory drive (Load MBR into 0x7C00 and print a message as a proof of correct boot) and read the my main HDD (which I assume it is numbered 0x81 and that the first 15 sectors are needed for booting) again into

Is it possible to shutdown linux kernel and resume in Real Mode?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 07:55:15
问题 Let's say I'd like to start a small linux distro before my ordinary operating system start. BIOS load MBR and execute MBR. MBR locates the active partition which is my linux partition. Linux start and I perform what I need to do. Linux shut down and I switch to Real Mode again. The original partition boot sector is loaded and my ordinary OS start. AFAIK, step 4 will be the difficult task, restore the state on all devices prior to linux, will INT13h be functional? Do I need to restore the