real-mode

Loading second stage of a bootloader

旧时模样 提交于 2019-11-30 21:02:04
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 success (the letter S) so I can tell the code is being executed. The problem is nothing ever appears on

Displaying text video memory at 0xb8000 without using the C library

情到浓时终转凉″ 提交于 2019-11-30 07:39:05
I have been writing kernel in C. I've been using the GCC cross-compiler, writing on a Windows system and targeting 16bit Real Mode. I don't have the C library available to write the kernel. I have started with some code which is suppose to print a character directly to the screen. Here is a function from kernel.c : int main() { char *src = (char *)0xB8000000L; *src = 'M'; src += 2; *src = 'D'; return 0; } I compiled my code using GCC with the parameter -m16 to generate code that will run in real mode. I use these commands to generate my kernel.bin : gcc -ffreestanding -c -m16 kernel.c -o

How to reboot in x86 assembly from 16 bit real mode?

天大地大妈咪最大 提交于 2019-11-29 16:35:39
APM shutdown has been covered at X86 instructions to power off computer in real mode? How to reboot instead of shutting down the computer? Please quote and explain the relevant documentation / standard in your answer. I've understood that APM and ACPI are the two main methods, and I'm interested in both. Let me know if there are others. I have found the ACPI spec is at http://uefi.org/specifications but it's taking too much brainpower to parse it that I found it worthy of a question. I could not find the URL for the APM spec, only a Google cache of a Microsoft RTF here . If you need a way to

Looking for 16-bit c compiler for x86 [closed]

天涯浪子 提交于 2019-11-29 03:56:27
I am working on porting uc/OS-II from DOS to x86 (real mode). I need: A compiler to generate real mode 16-bit x86 assembly An assembler to assemble the generated assembly into an object file A linker to link the object files together and output an executable (raw binary, COFF, PE, or ELF formats are fine) A standard library without invoking any DOS services ( int 21h ), only depend on BIOS service. I am wondering whether there is any tool-chain could do it. Check out the FreeDOS project. They have developer tools that include compilers, assemblers, and linkers. You'll probably have to modify

Segment size in x86 real mode

百般思念 提交于 2019-11-28 13:45:58
I have one doubt regarding the size of segments in real mode as they can't be more than 64K but can be less than that. My question is how these segment size and base address is initialized ? Like there are GDT's and LDT's in protected mode. Real mode segments can also overlapped,disjoint or adjacent. Like BIOS has some reserved area for specific things like boot code,video buffer etc does assembly programs need to do something like that ? In real mode segmented addresses are hardwired into memory. To get a physical address you can use this equation: physical address = segment * 16 + offset

How to reboot in x86 assembly from 16 bit real mode?

谁说胖子不能爱 提交于 2019-11-28 09:33:05
问题 APM shutdown has been covered at X86 instructions to power off computer in real mode? How to reboot instead of shutting down the computer? Please quote and explain the relevant documentation / standard in your answer. I've understood that APM and ACPI are the two main methods, and I'm interested in both. Let me know if there are others. I have found the ACPI spec is at http://uefi.org/specifications but it's taking too much brainpower to parse it that I found it worthy of a question. I could

Printing out a number in assembly language?

拟墨画扇 提交于 2019-11-27 04:36:53
mov al,10 add al,15 How do I print the value of ' al '? 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 . Assembly language has no direct means of printing anything. Your assembler may or may not come with a library that supplies such a facility, otherwise

What are the segment and offset in real mode memory addressing?

☆樱花仙子☆ 提交于 2019-11-27 04:32:58
I am reading about memory addressing. I read about segment offset and then about descriptor offset. I know how to calculate the exact addresses in real mode. All this is OK, but I am unable to understand what exactly offset is? Everywhere I read : In real mode, the registers are only 16 bits, so you can only address up to 64k. In order to allow addressing of more memory, addressקד are calculated from segment * 16 + offset. Here I can understand the first line. We have 16 bits, so we can address up to 2^16 = 64k. But what is this second line? What the segment represent? Why we multiply it with

Looking for 16-bit c compiler for x86 [closed]

我只是一个虾纸丫 提交于 2019-11-27 03:26:28
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I am working on porting uc/OS-II from DOS to x86 (real mode). I need: A compiler to generate real mode 16-bit x86 assembly An assembler to assemble the generated assembly into an object file A linker to link the object files together and output an executable (raw binary, COFF, PE, or ELF formats are fine) A

Second stage of bootloader prints garbage using Int 0x10/ah=0x0e

时光毁灭记忆、已成空白 提交于 2019-11-26 14:49:14
问题 I am trying to learn assembly and to write a bootloader. The following code loads the contents of a floppy drive to memory and jumps to it (starts loading at address 0x1000). This code is supposed to print "X" on the screen, but for some reason it prints a space. Can somebody please tell me what is wrong? [bits 16] jmp reset reset: ;Resets floppy drive xor ax,ax ;0 = Reset floppy disk mov dl,0 ;Drive 0 is floppy int 0x13 jc reset ;If carry flag was set, try again mov ax,0x1000 ;When we read