что означает "seg fs" в файле bootsect.s ядра Linux - PullRequest
3 голосов
/ 06 марта 2019

Когда я читал ранний код ядра Linux, я столкнулся с проблемой в boot / bootsect.s, которая была трудна для понимания. "Seg fs", Что это делает? Если я хочу перейти на синтаксис сборки AT & T, как мне это сделать!

    go: mov ax,cs       
    mov dx,#0x4000-12   ! 0x4000 is arbitrary value >= length of
                ! bootsect + length of setup + room for stack
                ! 12 is disk parm size

! bde - changed 0xff00 to 0x4000 to use debugger at 0x6400 up (bde).  We
! wouldn't have to worry about this if we checked the top of memory.  Also
! my BIOS can be configured to put the wini drive tables in high memory
! instead of in the vector table.  The old stack might have clobbered the
! drive table.

    mov ds,ax
    mov es,ax
    mov ss,ax       ! put stack at INITSEG:0x4000-12.
    mov sp,dx
/*
 *  Many BIOS's default disk parameter tables will not 
 *  recognize multi-sector reads beyond the maximum sector number
 *  specified in the default diskette parameter tables - this may
 *  mean 7 sectors in some cases.
 *
 *  Since single sector reads are slow and out of the question,
 *  we must take care of this by creating new parameter tables
 *  (for the first disk) in RAM.  We will set the maximum sector
 *  count to 18 - the most we will encounter on an HD 1.44.  
 *
 *  High doesn't hurt.  Low does.
 *
 *  Segments are as follows: ds=es=ss=cs - INITSEG,
 *      fs = 0, gs = parameter table segment
 */

    push    #0
    pop fs
    mov bx,#0x78        ! fs:bx is parameter table address
    seg fs
    lgs si,(bx)         ! gs:si is source

    mov di,dx           ! es:di is destination
    mov cx,#6           ! copy 12 bytes
    cld

    rep
    seg gs
    movsw

    mov di,dx
    movb    4(di),*18       ! patch sector count

    seg fs
    mov (bx),di
    seg fs
    mov 2(bx),es

    mov ax,cs
    mov fs,ax
    mov gs,ax

    xor ah,ah           ! reset FDC 
    xor dl,dl
    int     0x13    

Ответы [ 2 ]

4 голосов
/ 06 марта 2019

Я предполагаю, что он собирается как префикс fs для следующей инструкции. Это будет соответствовать комментариям, и это единственное, что имеет смысл.

Должно быть достаточно легко собрать и разобрать (в синтаксис AT & T, если хотите).

В синтаксисе AT & T вы можете просто использовать fs в качестве префикса для других мнемоник.

fs movsw

собирается на это (в 64-битном режиме. 16-битный режим пропускает префикс размера операнда 66).

0000000000000000 <.text>:
   0:   64 66 a5                movsw  %fs:(%rsi),%es:(%rdi)
0 голосов
/ 07 марта 2019

кто может сказать мне, чтобы изменить это, чтобы быть правильным или нет?!

__go:   
movw    %cs         ,   %ax
movw    $0x4000-12  ,   %dx
movw    %ax         ,   %ds
movw    %ax         ,   %es
movw    %ax         ,   %ss
movw    %dx         ,   %sp
pushw   $0x0000
popw    %fs
movw    $0x0078     ,   %bx
lgs     %fs:(%bx)   ,   %si
movw    %dx         ,   %di
movw    $0x0006     ,   %cx
cld
rep
movw    %dx         ,   %di
movw    $0x12       ,   0x0004(%di)
movw    %di         ,   %fs:(%bx)
movw    %es         ,   %fs:0x0002(%bx)
movw    %cs         ,   %ax
movw    %ax         ,   %fs
movw    %ax         ,   %gs
xorb    %ah         ,   %ah
xorb    %dl         ,   %dl
int     $0x13
...