-2

MY PC のパーティション ディスクを表示する起動プログラムを作成するという割り当てがあります。よく検索した結果、これらの情報が 1BE にあるセクションを見つけたので、そのセクターから読み取ろうとしています。いくつかのコードを見つけて、このコードの割り込み13を調べようとしましたが、何か問題があると感じています。

次にNASMで実行すると、認識されないディレクティブORGというエラーが表示されました

どうもありがとう :) :) :)

[BITS 16]                            ; 16 bit code generation
[ORG 0x7C00]                          ; Origin location

; Main program
main:                         ; Label for the start of the main program


start: 
       mov ax,cs
       mov ds,ax
       mov es,ax
       mov ss,ax
       sti

reset: mov ah,0h                  ;resetting the drive to the first sector
       mov dl, 0x80
       int 13h
       js reset

read:  mov ax,1BEh              ;reading sectors into memory address 0x1BE:0
       mov es,ax
       xor bx,bx
       mov ah,02h
       mov al,01h               ;reading 1 sector
       mov  cx, 0001h           ; track 0, sector 1
       mov  dx, 0000h           ; head 0, drive 0
       int 13h

      jc   errp                ; detect error
      ret




          jmp $            ; Never ending loop

; Procedures
errp:                          ; process error here
 mov ax,0x0000          
 mov ds,ax  
 mov si, ERRR                 ; Load the string into position for the procedure.
 call PutStr



PutStr:     ; Procedure label/start
                ; Set up the registers for the interrupt call
 mov ah,0x0E    ; The function to display a chacter (teletype)
 mov bh,0x00    ; Page number
 mov bl,0x07    ; Normal text attribute

.nextchar   
 lodsb  

 or al,al           
 jz .return         
 int 0x10   ; Run the BIOS video interrupt 

 jmp .nextchar  ; Loop back round tothe top
.return     ; Label at the end to jump to when complete
 ret        ; Return to main program

; Data

ERRR db 'ERROOOORR',13,10,0

; End Matter
times 510-($-$$) db 0   
dw 0xAA55       
4

1 に答える 1

0

ORG 0x7C00 を使用するという事実は、セグメント レジスタをゼロに設定し、既に CS にある値に設定しないことを意味します。
ドライブをリセットする BIOS 関数は、サイン フラグ SF に何も返しません。ただし、キャリー フラグ CF は変更されます。
パーティション テーブルは、ブートセクタのオフセット 0x01BE にあり、4 つの 16 バイト エントリが含まれています。
(現在使用されていない) READ 関数は、メモリ内のどこでもセクター サイズのバッファーを使用できますが、0x7C00 の 512 バイトから離れることをお勧めします。
最初のハードディスクをリセットしているのに、最初のフロッピーディスクから読み取っていることに気付きましたか? 後で
書くつもりだったと思いますよね?jmp $ ; Never ending loopcall PutStr
演習が使用可能なパーティションの表示に関するものである場合、もちろんシステム インジケータ バイトがパーティションなしを意味する 0 を読み取らない限り、各パーティション テーブル エントリから CHS 値を表示するだけで済みます。

于 2014-11-09T15:29:51.390 に答える