Questions tagged [real-mode]

x86 real mode is where a CPU begins execution. It has a 20-bit memory address space and unlimited direct software access to all addressable memory, I/O addresses and peripheral hardware. It has no concept of virtual memory, paging or memory protection as in protected-mode and long-mode. Use this tag for programming questions related to real mode.

Real mode, also called real address mode, is an operating mode of all x86-compatible CPUs.

Real mode is characterized by

  • a 20-bit segmented memory address space (giving exactly 1 MiB of addressable memory) and
  • unlimited direct software access to all addressable memory, I/O addresses and peripheral hardware, it
  • provides no support for memory protection, multitasking, or code privilege levels.

Before the release of the 80286, which introduced real mode was the only available mode for x86 CPUs. In the interests of backwards compatibility, all x86 CPUs start in real mode when reset, though its possible to emulate real mode on other systems when starting on other modes.

281 questions
4
votes
1 answer

How to execute another file in Assembly 16-bits

I was developing a simple BIOS reseter, just for learning. So I have the principal file, that's the Menu, called Reseta.com, yes, it's a model tiny without stack. And I have a A.com, where's the code to reset, So I need to execute A.com with my main…
4
votes
2 answers

Invalid base/index expressions

Trying to use base-index expressions to manipulate memory in 16-bit real mode results in compilation errors: movw $0xd000, -2(%sp) movw $0, -4(%sp) movw $1, -6(%sp) Compiled with gcc -c -Wa,--32 $(DIR_BS_SRC)/mbr.S -o…
Maxim Blinov
  • 886
  • 9
  • 33
4
votes
1 answer

some clang-generated assembly not working in real mode (.COM, tiny memory model)

First, this is kind of a follow-up to Custom memory allocator for real-mode DOS .COM (freestanding) — how to debug?. But to have it self-contained, here's the background: clang (and gcc, too) has an -m16 switch so long instructions of the i386…
user2371524
3
votes
3 answers

How does the segment:offset addressing scheme work?

I've read that in the days of the Intel 8086 CPU the biggest registers were 16-bits and everyone were looking for a way to access more than 65536 bytes of linear memory but instead of expanding the CPU registers they invented the segment:offset…
Benjamin
  • 541
  • 1
  • 9
  • 17
3
votes
1 answer

Did I correctly set up the stack segment in real mode?

Im writing a bootloader and I set up my stack up as such... STACK_SEGMENT equ 0x0050 STACKP_OFFSET equ 0x03FF mov ax, STACK_SEGMENT mov ss, ax mov sp, STACKP_OFFSET Am I allocating 1024 bytes of stack space by doing this? and is it appropriate to…
TheFuzz
  • 2,607
  • 6
  • 29
  • 48
3
votes
0 answers

Where in this code does the switch to 32bit protected mode happen

I read about how to switch from default real mode to protected mode and I wonder where the switch in my code happens. Theres one part that I copied and dont fully understand, which is this: global loader global stack_ptr extern main MODULEALIGN…
3
votes
1 answer

call in x86 real mode does not save return address

I'm trying to write a real mode bootloader and I'm currently having problems trying to enable the A20 line. Here's my code so far, I'm assembling with NASM: [bits 16] [global _start] jmp _start bios_print: lodsb test al, al jz bios_print_done …
Peter
  • 2,919
  • 1
  • 16
  • 35
3
votes
2 answers

What is causing this bootloader to fail on hardware but not in DOSBOX? It displays all registers

I recently wrote an x86 'bootloader' program that shows the values of the hardware registers after the BIOS jumps to my program. For the purpose of testing, I set the AX register to a known value to ensure that the program runs correctly. BITS…
はるき
  • 141
  • 1
  • 9
3
votes
2 answers

Why does my bootloader not load a byte from memory correctly?

I have the following x86 program: mov ah, 0x0e ; Set up call to BIOS routine to print character mov al, [character] ; Stick the byte at label "character" int 0x10 ; Display character in al jmp $ ; Loop…
Jack M
  • 4,769
  • 6
  • 43
  • 67
3
votes
1 answer

In GDB (real mode, attached to QEMU), at a specific point under specific conditions stepo and nexti seem to break the breakpoint mechanism

Minimal working example source: use16 org 0x7c00 jmp 0x0000:@start @start: cli mov ax,cs mov ds,ax mov es,ax mov ss,ax mov sp,0x7c00 sti mov bp,sp call @fails jmp @start @fails: …
NULLx
  • 61
  • 5
3
votes
1 answer

Are Extended general-purpose and special-purpose registers supported in x86_32 virtual 8086 and real mode?

Is it possible to use EAX,EBX,... in x86_32 virtual 8086 or real mode? I know, that these registers have the size of 32 bits (and, that of course their non-Extended parts are 16 bits wide), however it is not explained in class, that in which modes…
3
votes
1 answer

What happens when the physical address corresponding to CS:IP is more than 20 bits in 8086?

In 8086 microprocessor, suppose CS is FFFFH and IP is FAB0H Then the physical memory address would be computed by multiplying CS by 16 and adding IP. i.e. Add = FFFF0 + FAB0 This sum gives an overflow as the sum cannot be stored in 20 bits. What…
Raghav Arora
  • 148
  • 1
  • 14
3
votes
1 answer

Does writing a value to the BX register have an effect on the ES register?

[org 0x7c00] mov bp, 0x8000 ; set the stack safely away from us mov sp, bp mov bx, 0x9000 ; es:bx = 0x0000:0x9000 = 0x09000 As you can see in the comment it says: es:bx = 0x0000:0x9000 = 0x09000. Is there any relationship between…
Henok Tesfaye
  • 8,287
  • 13
  • 47
  • 84
3
votes
2 answers

Why are this many bytes written to the standard output device?

I have the following data declarations, and the data segment and code segment registers are all correctly initialized: d1 db 1,2 d2 dw 3 d3 db 'ABC' d4 db 'DE' d5 db 'F' d6 db '$' I run this set of instructions on DOSbox: mov dx, offset…
user10335564
  • 133
  • 3
  • 16
3
votes
2 answers

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

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,…
Vstbutwhy
  • 73
  • 1
  • 5