내 AX 레지스터에 저장된 값을 CL 레지스터로 이동하려고합니다. 또한 BX : DH 및 CX : CH와 같은 레지스터 쌍 (이동에서 이동)으로이 작업을 수행하려고합니다.AX를 CL로 이동 - 연산 코드와 피연산자의 조합이 올바르지 않음
여기 내 코드입니다.
;;;
;;; Stage 1 - Boot Loader
;;;
BITS 16 ; Start in 16 bit real mode
ORG 0x7C00 ; Loaded by BIOS at 0x7C00
start: jmp stage1 ; Jump to the stage 1 section
;;;
;;; Parameter Block
;;;
SECTORS_TRACK dw 18 ; Sectors per track
HEADS_CYLINDER dw 2 ; Heads per cylinder
;;;
;;; Strings Block
;;;
stage1_message db 'Stage 1 - 16 bit real mode', 13, 10, 0
;;;
;;; Print String Function
;;; Input:
;;; - si = Null terminated string
;;; Output:
;;; - None
;;;
print:
lodsb ; Load next byte from string in SI to AL
or al, al ; Does AL equal 0?
jz print_done ; Yes, null terminator found, return
mov ah, 0eh ; No, print the character
int 10h
jmp print ; Repeat until null terminator found
print_done:
ret ; We are done, return
;;;
;;; LBA to CHS Function
;;; - Sector 1 = LBA 0
;;; Input:
;;; - ax = LBA value
;;; Output:
;;; - ax = Sector
;;; - bx = Head
;;; - cx = Cylinder
;;; Credit:
;;; - http://www.osdever.net/tutorials/view/lba-to-chs
;;;
lbachs:
push dx
xor dx, dx
mov bx, [SECTORS_TRACK]
div bx
inc dx
push dx
xor dx, dx
mov bx, [HEADS_CYLINDER]
div bx
mov cx, ax
mov bx, dx
pop ax
pop dx
ret
;;;
;;; Load Stage 2 Function
;;;
stage2:
mov ax, 0x01 ; LBA 1 = Sector 2
call lbachs ; Convert LBA to CHS
mov ah, 0x02 ; Read disk sectors function
mov al, 0x01 ; Read one sector only (512 bytes)
mov dl, 0x00 ; Drive 0 (Floppy Disk 1)
mov cl, ax ; Sector - Stored in AX - ERROR
mov dh, bx ; Head - Stored in BX - ERROR
mov ch, cx ; Cylinder - Stored in CX - ERROR
mov bx, 0x2000 ; Put loaded data into segment 0x2000:0x0000
mov es, bx ; Load segment into ES (Segment parameter)
mov bx, 0x0000 ; Load segment offset into BX (Offset parameter)
int 0x13 ; Call BIOS read disk sectors function
jc stage2 ; Error occurred, try loading again
jmp 0x2000:0x0000 ; Loading complete, jump to stage 2
;;;
;;; Stage 1 Section
;;;
stage1:
mov si, stage1_message ; Load the stage 1 message
call print ; Call the print function
jmp stage2 ; Attempt to load stage 2
;;;
;;; Footer Information
;;;
times 510-($-$$) db 0 ; Fill remainder of bootloader with 0's
dw 0xAA55 ; Standard PC boot signature at the end
문제를 일으키는 세 가지 라인은 stage1:
위의 하단에있는 누군가가 내가 대단히 감사하겠습니다이 나를 도울 수 있다면 단어 ERROR
으로 표시됩니다. 또한, 내 코드에서 평소와 다른 것을 발견하면 알려 주시기 바랍니다. 나는 이것을 보조 커널로 옮기는 첫 번째 단계 부트 로더로 개발 중이다.
귀하의 조언과 고려에 미리 감사드립니다.
mov 명령은 두 피연산자의 비트 길이가 같아야합니다. 그러므로 cl에 8 비트가 있기 때문에 mov ax (16 비트 레지스터)를 cl에 넣을 수 없습니다. 유효한 대안 : mov cl, al 또는 mov cl, ah. –
어리석은 실수는 우리 모두가 만들었으므로 이것은 좋은 질문입니다.하지만 나는 당신의 질문에 +1하기로 결정했음을 알았 으면합니다. 전에 47 번이나 만들었던 바보 같은 실수가 아니라 코드에 주석을 달았 기 때문에 각 명령, 다양한 섹션의 헤더. 이것은주의를 끄는 종류의 코드입니다. 대답을 얻는다. –
@ User.1 친절한 말을 해주셔서 정말 고맙습니다. 내 질문은 자신과 같은 다른 사용자에게 기쁘게 생각합니다. –