如何修复异常"错误:操作码和操作数的无效组合"在这段代码?

时间:2018-05-14 17:18:42

标签: assembly x86 nasm x86-16 bootloader

如何修复异常"错误:操作码和操作数的无效组合"在这段代码中?

以下是我在 bootsimple.asm 中的代码:

BITS 16
jmp short bootloader_start
nop
bootloader_start:
    mov ax, 07C0h           ; Set up 4K of stack space above buffer
    add ax, 544         ; 8k buffer = 512 paragraphs + 32 paragraphs (loader)
    ;cli                ; Disable interrupts while changing stack
    mov ss, ax
    mov sp, 4096
    ;sti                ; Restore interrupts

    mov ax, 07C0h           ; Set data segment to where we're loaded
    mov ds, ax
    mov si,prompt
    call print_string
    lea si,string
    call read_string
    mov si, string
    call print_string

print_string:           ; Routine: output string in SI to screen
    ;pusha
    mov ah, 0Eh     ; int 10h 'print char' function

.repeat:
    lodsb           ; Get character from string
    cmp al, 0
    je .main_done       ; If char is zero, end of string
    int 10h         ; Otherwise, print it
    jmp .repeat

.main_done:
    mov si,eol
.eol_repeat:
    lodsb           ; Get character from string
    cmp al, 0
    je .done        ; If char is zero, end of string
    int 10h         ; Otherwise, print it
    jmp .eol_repeat
.done:
    ;popa
    ret
read_string:
.repeat:
    mov     ah, 01h
    int     21H                 ; read 1 character
    cmp     al, 0x0A              ; is it return?
    je      .done                ; yes, we are done
    mov     [si], al            ; no, move charater into buffer
    inc     si                  ; increase pointer
    jmp     .repeat             ; loop back
.done:            
    ret
    eol db 10,0
    prompt db "Hello>"
    string times 80 db 0
    times 510-($-$$) db 0   ; Pad remainder of boot sector with 0s
    dw 0xAA55       ; The standard PC boot signature

在编译期间,这是例外:

  

bootsimple.asm:16:错误:操作码和操作数的组合无效

我建造简单的操作系统

0 个答案:

没有答案