8086 programming without OS; segmentation

Well guys, this is a tricky question as it deals with a lot of hardware specifics, so I thought about putting it in EE.SE, but it focuses on programming, so I decided to leave it here.

I recently got a big bang of nostalgia (as well as itching to get back to the internal functions of the processor), so I decided to overcome the 8086 microcomputer board. It is provided that I am familiar with the x86 assembly (to some extent, as you will see), and I already I know how to get my code on a computer board to get a real problem. For information purposes, I use NASM, although I am not yet fully prepared for the syntax.

Obviously, an 8086 operating in real-time mode (which is not yet called in real-time mode) has the first 1024 bytes allocated at the beginning for 255 2 + 2 byte interrupt vectors, so the actual command lists start with 0x3FF,

The problem here is related to the quirks of segmenting system memory, as well as the fact that I could write BIOS as it relates to the system. Should segment registers be set, and if so, how can I determine what to put there? Suppose I use EEPROM or some form of Flash to store my code, so I have something like:

section .text
org 0x0000
    ; Interrupt vectors reserved
    ivt: times 1024 db 0
main:
    cli      ; Clear out interrupts because no addresses are defined yet
             ; Problems HERE.
             ; Set up interrupt addresses

, - , , , , . , - mov CS, blahblahblah, , , / ?

, , Googling, 8086. , , , .. , , .

+4
3

, , .

, reset, CS ( ) :

  • : 0ffffh
  • base: 0ffff0h

IP ( ), 00000h.

CS.base IP 0ffff0h.

, - 16 , , , , .

+2

8086 , , CS, DS, SS ES. , , , . , 16 16- , 20- . , Intel.

CS . , IP. , CS:IP FFFF:0000 , FFFF0h, EEPROM - . , , , .

- , . DS, , , . , , SS ( SP) . SS DS, . ES - , (MOVS, SCAS, CMPS). , "" , , CS, DS SS.

, , Intel 8086 80186. 80286 , , . - 8086, , , - .

+3

... Googling, 8086 ...

OS-less, BIOS 8086 BIOS. :

http://bochs.sourceforge.net/cgi-bin/lxr/source/bios/rombios.c#L11661

...
// (C) 2002 MandrakeSoft S.A.
...
//ROM BIOS Bochs/Plex86/QEMU
...

.org 0xfff0 ; Power-up Entry Point
  jmp 0xf000:post
  ...
post:
  xor ax, ax
   ...
normal_post:
; case 0: normal startup

  cli
  mov  ax, #0xfffe
  mov  sp, ax
  xor  ax, ax
  mov  ds, ax
  mov  ss, ax
  ...

. :

  • Intelยฎ 64 IA-32

    • 9.1.4

      , reset, FFFFFFF0H. 16 . EPROM, , ...

    • 9.7

      reset ( , RESET#) FFFFFFF0H. , IDT . ...

      ...

+1

Source: https://habr.com/ru/post/1568958/


All Articles