Yes, x86 is 32 bit. Wrote a small kernel for VGA, keyboard IO, and mouse IO. But, x86_64 is 64 bit. The main difference is that the registers are extended to 64 bit and there are more of them. The x86_64 instruction set has a few more instructs along with x86. But here's the thing - is the memory map the same as x86? If no, can i have the specs?
Asked
Active
Viewed 281 times
1
-
2You mean physical memory, like where MMIO registers are, and which regions are backed by DRAM vs. nothing? It's the same on any given system regardless of what mode you switch one of the CPU cores into. But it can vary between systems, so you should ask the BIOS where things are. – Peter Cordes Sep 19 '21 at 06:49
-
2And BTW, x86-64 in 64-bit mode has *fewer* instructions than in compat or legacy modes. Instructions like `aam` and `lds` were removed for x86-64, freeing up their opcodes. The number of new 64-bit-only instruction mnemonics like `movsxd` and `cqo` is I think smaller than the number of removed instructions, whether you're counting mnemonics or opcodes. (If you count different *forms* of the instructions like `popcnt r64` as separate from `popcnt r32` differentiated by REX prefix, then yeah long mode has many more). Otherwise most extensions added instructions that work in both modes. – Peter Cordes Sep 19 '21 at 06:52
-
no no, i mean like the io ports of "IN OUT" instructions and video ram etc. – user135142 Sep 19 '21 at 08:35
-
5Those things are hard-wired outside the CPU. They don't depend on CPU operating mode. – rustyx Sep 19 '21 at 08:54
-
so it is with the motherboard, not the cpu? – user135142 Sep 19 '21 at 09:16
-
2IO address space isn't memory, it's IO space. That's why you have to use the "address" with special instructions (`in` / `out`, not `mov`). And yeah, devices don't care what mode the CPU is in when it executes `in` / `out`. Legacy IBM-PC IO port stuff is fixed for backwards compat. On modern PCI devices, you query the PCI device to find out where PCI autoconfig put its IO ports. – Peter Cordes Sep 19 '21 at 09:25
-
1As for device memory like VGA, yes that is part of physical address space, so yeah you'll need to map it to a virtual address with your page tables. (long mode requires paging). But the physical address doesn't depend on the CPU mode either, and again legacy IBM-PC / VGA stuff is at fixed locations, unless you write graphics drivers for the specific hardware you actually have, in which case after a mode switch you'd know where you told it to put the framebuffer. – Peter Cordes Sep 19 '21 at 09:28