osdev

Protected Mode Keyboard Access on x86 Assembly

别等时光非礼了梦想. 提交于 2019-12-28 12:32:49
问题 I'm working on keyboard input for a very basic kernel that I'm developing and I'm completely stuck. I can't seem to find any information online that can show me the information I need to know. My kernel is running in protected mode right now, so I can't use the real mode keyboard routines without jumping into real mode and back, which I'm trying to avoid. I want to be able to access my keyboard from protected mode. Does anyone know how to do this? The only thing I have found so far is that it

How do I write a bin file (512 bytes) to the first sector (sector 0) of a floppy disk?

白昼怎懂夜的黑 提交于 2019-12-28 04:04:37
问题 How do I write a .bin file to be in the first sector of a floppy disk/virtual floppy disk/floppy image? I'm trying to boot a simple 512-byte bootloader. The size on everywhere says "512 bytes" so I should be good already. Additional Information: The bootloader simply displays a string, and I'm learning simple assembly. Some of the work is made in Windows and some in Ubuntu 14.04 (Trusty Tahr) (if this matters). It doesn't boot even though it has the bootloader sign. 回答1: If you are on Linux

Linker error setting loading GDT register with LGDT instruction using Inline assembly

≯℡__Kan透↙ 提交于 2019-12-25 18:49:29
问题 I was compiling my prototype of prototype of a kernel (sounds weird, but it really doesn't matter) and in the installation I need to link the ASM file to a C file compiled with gcc to get a executable that could be used as kernel. The problem is that, after implementing a swap to protected mode from real mode, I get this error at linking the kernel.c and loader.asm scripts: Code: kernel.c:(.text+0x1e1): undefined reference to `gdtr' I will explain how all process of installation is and I will

Jump to Protected Mode not working after linking the kernel

南笙酒味 提交于 2019-12-24 14:43:10
问题 I have been developing a Bootloader and have run into a problem when linking c++ code to my assembly stage2 code before I linked the files the second stage would jump to protected mode then to long mode without any problems but now after I have linked it there seems to be a problem when jumping to protected mode Here is the code I use to jump to protected mode: main: ;first stage of bootloader is loaded at the address 0x07c0:0 ;second stage of bootloader is loaded at address 0x200:0x0 cli xor

How to fix “os.asm:113: error: TIMES value -138 is negative” in assembly language

可紊 提交于 2019-12-24 08:03:19
问题 I'm developing an operating system in assembly language. At a certain time i get this error from NASM: os.asm:113: error: TIMES value -138 is negative I want to take this project to the end. Only the errors like that despair me! Here is the 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 call cls MOV AH, 06h ; Scroll up

x86 ASM: DD Being Used as an “Instruction”?

非 Y 不嫁゛ 提交于 2019-12-24 07:49:43
问题 In the following x86 assembly code: dd 0x1BADB002 dd 0x00 dd - (0x1BADB002+0x00) The values don't seem to be assigned to any variables. So what does this snippet of code do? I've heard something about it being stored in memory, but where exactly? 回答1: dd is a "pseudo-instruction" that assembles 4-byte constants into the output, the same way that add eax,eax assembles 0x01 0xc0 into the output. The NASM manual section 3.2 Pseudo-Instructions describes db / dw / dd and so on. In this case, as

Using BIOS int 13h to access sectors in different heads

夙愿已清 提交于 2019-12-24 05:37:26
问题 I have a disk with 63 sectors per track. (I assume, based on my observations) I want to read sectors on a 16 bit bootloader using int 13h. For example, if I want to read sector number 63, I would do the following: mov dl,0x80;Drive number mov dh,0 ;This is head number/platter number mov ch,0 ;This is cylinder number mov cl,63 ;Sector number mov ah,0x02 ;interrupt function mov al,1 ;Number of sectors to be read xor bx,bx mov es,bx ;Making es=0 mov bx,0x8000 ;Any random buffer address int 0x13

GCC Inline Assembly 'Nd' constraint

风格不统一 提交于 2019-12-23 12:59:47
问题 I'm developing a small toy kernel in C. I'm at the point where I need to get user input from the keyboard. So far, I have implemented inb using the following code: static inline uint8_t inb(uint16_t port) { uint8_t ret; asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port)); return ret; } I know that the "=a" constraint means that al/ax/eax will be copied to ret as output, but I'm still confused about the "Nd" constraint. Can anyone provide some insight on why this constraint is necessary? Or

GPF after far jump to protected mode

别说谁变了你拦得住时间么 提交于 2019-12-22 23:22:20
问题 After several weeks of work using GRUB as my bootloader I decided that I should roll my own so I can understand how they work. I found Brokenthorn's tutorials on the internet (currently on http://www.brokenthorn.com/Resources/OSDev9.html). When I try to switch to protected mode the cpu hardware resets after the far jump. I'm running bochs v. 2.6. this is my second stage bootloader( almost a copy of the tutorial because i thought it would fix my problems - it doesn't) bits 16 ; Remember the

Doing a indirect far jump/call in protected mode

老子叫甜甜 提交于 2019-12-22 10:58:13
问题 How do I perform an indirect far jump/call in protected mode? First I was thinking that doing this is allowable: jmp 0x10:eax; (Don't worry about the segment selector..the 2nd entry of my GDT is a valid code segment) But when nasm assembled it, it was a syntax error. Looking at the Book 2a of the Intel (instruction set reference) manual, it can only be done using jmp ptr16:32 , where the ptr16:32 is an immediate value, or using jmp m16:32 , where the m16:32 is a memory location containing the