real-mode

Grub and getting into Real Mode (low-level assembly language programming)

本秂侑毒 提交于 2019-12-21 12:38:50
问题 I've been working on a toy OS and have been using grub as my boot loader. Recently when trying to use VGA I found that I couldn't use hardware interrupts. This I found was because I had been slung into protected mode by grub. Does anybody know how to get back into real mode without having to get rid of grub? 回答1: If you are using GRUB as your boot loader you could use the intcall (as specified in the COMBOOT API) to call BIOS function int 0x10 in your case to access the VESA VBE. But this

Switch from protected mode to real mode in a DOS EXE program

≯℡__Kan透↙ 提交于 2019-12-19 18:54:02
问题 I learned to switch to protected mode with a simple DOS based bootloader. This loader loads kernel.bin into a buffer and copies the buffer to 100000h (kernel is 8KiB). Control is then transferred to the kernel. When I return from the kernel and attempt to switch to real mode I encounter a problem. My FASM assembly code (Similar to my previous Stackoverflow question) is as follows: format MZ push cs pop ds mov eax,cs shl eax,4 mov [AdresSegmentuProgramu_32],eax ;Calculating real mode segment

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

故事扮演 提交于 2019-12-18 12:38:44
问题 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

Code works on bochs but does not on real computer, x86 real mode

被刻印的时光 ゝ 提交于 2019-12-13 16:19:45
问题 This small piece of code works fine on bochs 2.6, but doesn't seem to work on 'real' computers (I've tried several of them). It seems like lodsb is causing the problem, since it worked fine, when I did hello world by printing the string "manually" character by character. .code16 .text .globl _start _start: movw $0, %ax jmp main ### DATA AND BUFFERS ### welcome: .asciz "welcome" main: movw $welcome, %si call print_string hang: jmp hang print_string: lodsb cmp $0, %al je done mov $0x0e, %ah int

(assembly x86 real mode) Data gets “cut off” at the end of the program?

情到浓时终转凉″ 提交于 2019-12-12 15:06:04
问题 This is a follow-up from (nasm x86 real mode) How to write/read strings in boot-loaded sector?. I'm working on a toy OS for x86 real mode in NASM. The 512B boot sector loads another sector with the rest of the code. The problem is that I seem to run out of space at the end of the program. Here's the beginning of the source file: ;;; nasm -f bin -o boot.bin os.asm ;;; qemu-system-x86_64 boot.bin bits 16 section boot, vstart=0x0000 ;; Load next sector. ;; adapted from: ;; https://blog.benjojo

How to use real mode BIOS / VESA calls from GRUB?

我只是一个虾纸丫 提交于 2019-12-12 06:04:21
问题 I am developing a simple Grub module which would enable some additional video settings/initializations at the early stage of the boot process. My actual best idea would be to use some VESA calls for the task. Unfortunately, recently I've found real mode calls are unavailable from the Grub. But the GRUB can do really complex operations which are probably unimaginable without the help of the BIOS. How is it possible? How could I call the bios from the grub? 回答1: As far as I can see, grub uses

Updating variable that lives in the data segment from the stack and its segment

ⅰ亾dé卋堺 提交于 2019-12-12 02:18:19
问题 I currently have three segments of memory, my main data segment, stack segment and the segment where my API lives. The following instructions are executed from the data segment, they push the address of cursorRow and welcomeMsg then do a far call to the function in my API segment. The cursorRow variable lives in the main data segment that is calling the API function. The call looks like this: push cursorRow push welcomeMsg call API_SEGMENT:API_printString How can I alter cursorRow, inside of

What's the purpose of PUSH CS / POP DS before a REP MOVSW?

萝らか妹 提交于 2019-12-11 03:09:38
问题 Why in below code we push code segment (PUSH CS) and then popping it into the data segment (POP DS)? I am giving these lines explicitly as line1 and line2. Please let me know how MOVSW is working here. IF HIGHMEMORY PUSH DS MOV BX, DS ADD BX, 10H MOV ES, BX PUSH CS. ;line1 POP DS. ;line2 XOR SI, SI MOV DI, SI MOV CX, OFFSET SYSSIZE + 1 SHR CX, 1 REP MOVSW. ;line3 POP DS PUSH ES MOV AX, OFFSET SECONDRELOCATION PUSH AX AAA PROC FAR RET AAA ENDP SECONDRELOCATION: more code here.............. 回答1

16 bit C code for real mode kernel

你离开我真会死。 提交于 2019-12-10 16:03:18
问题 I don't know how to compile my C kernel for 16 bit real mode. I have tried a variety of compilers with no luck. My bootloader simply loads raw sectors from the floppy (my kernel lives right after the first sector on the disk) to the physical memory address 1000h:0000h then jumps to it. How can I compile my C kernel to work in 16 bit real mode? my basic kernel: void OSmain() { unsigned char *videoram = (unsigned char *) 0xb8000; videoram[0] = 65; /* character 'A' */ videoram[1] = 0x07; /*

Why do interrupts need to be disabled before switching to protected mode from real mode?

為{幸葍}努か 提交于 2019-12-10 13:36:59
问题 I saw in many many oses (and some bootloader), they all disable interrupt ( cli ) before switch to protected mode from real mode. Why we need do that? 回答1: BIOSes use PIT interrupt (IRQ0) to track time. As soon as you enter protected mode, real mode interrupt handling is no longer valid; CPU in protected mode requires protected mode IDT (Interrupt Descriptor Table). Upon entering protected mode, IDT limit in IDTR (IDT Register) is set to 0 (any interrupt number makes CPU generate an exception