程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了程序集引导加载程序继续使用“mov ah, 09h”打印 S大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决程序集引导加载程序继续使用“R_448_11845@ov ah, 09h”打印 S?

开发过程中遇到程序集引导加载程序继续使用“R_448_11845@ov ah, 09h”打印 S的问题如何解决?下面主要结合日常开发的经验,给出你关于程序集引导加载程序继续使用“R_448_11845@ov ah, 09h”打印 S的解决方法建议,希望对你解决程序集引导加载程序继续使用“R_448_11845@ov ah, 09h”打印 S有所启发或帮助;

每次我尝试为我的程序集引导加载程序添加颜色时,它总是打印“S”,我不知道为什么!

代码:

            BITS 16
    
    start:
        mov ax,07C0h       ; Set up 4K stack space after this bootloader
        add ax,288     ; (4096 + 512) / 16 bytes per paragraph
        mov ss,ax
        mov sp,4096
    
        mov ax,07C0h       ; Set data segment to where we're loaded
        mov ds,ax
    
    
        ;setTing vIDeo mode
        mov ah,00h
      mov al,00h
      int 10h
        ;setTing cursor position
        mov ah,02h  
        mov dh,10    ;row 
        mov dl,45     ;column
        int 10h
    
        mov si,text_String ; Put String position into SI
        call print_String   ; Call our String-prinTing r@R_674_9981@ne
    
        jmp $           ; Jump here - infinite loop!
    
    
        text_String db 'KRIPKE OS',0
    
    
    print_String:           ; R@R_674_9981@ne: output String in SI to screen
    mov ah,09h
    mov bl,2  ;colour
    mov cx,1    ;no.of times

.repeat:
    lodsb           ; Get character from String
    cmp al,0
    je .done    ; If char is zero,end of String
    int 10h         ; Otherwise,print it
    mov ah,02h
    add dl,1
    jmp .repeat

.done:
    ret

    
    
        times 510-($-$$) db 0   ; Pad remainder of boot sector with 0s
        DW 0xAA55       ; The standard PC boot signature

请帮我解决这个问题。 我认为 bl 寄存器可能有问题。 我需要在顶部添加 [org 0x7c00] 吗?

输出: K then lots of spaces

解决方法

int 10h / ah=09h BIOS 调用不会更新光标位置,因此您需要在打印每个字符后重复 int 10h / ah=02h,并增加位置。您当前的代码将 @H_320_7@mov ah,02h 和 add dl,1 放入循环中,但实际上并未执行第二次 int 10h 调用。您还必须在每个字符输出调用之前将 ah 重置为 09h

更好的是,在输出字符之前更新循环中的光标位置。这也意味着您不再需要在调用 print_String 或进入循环之前设置光标位置。

我会写:

print_String:           ; R@R_674_9981@ne: output String in SI to screen
    mov dl,45      ; initial cursor column column
    mov dh,10      ; row
    mov bl,2       ; colour
    mov cx,1       ; no.of times

.repeat:
    mov ah,02h     ; update cursor position
    int 10h
    inc dl          ; same as `add dl,1` but smaller 

    lodsb           ; Get character from String
    cmp al,0
    je .done        ; If char is zero,end of String
    mov ah,09h     ; Otherwise,print it
    int 10h         


    jmp .repeat

.done:
    ret

为了进一步增强,让 print_String 的调用者设置 dh,dl 的值,以便它可以在任何需要的位置打印。或许还有 bl便调用者也可以选择颜色。

,

明白了! Nate 是对的,但忘记添加 @H_320_7@mov ah,02h 和 int 10h

print_String:           ; R@R_674_9981@ne: output String in SI to screen
      mov ah,02h
      mov dl,0   ; initial cursor column
      mov dh,0     ; row
      int 10h
      mov bl,2       ; colour
      mov cx,1       ; no.of times

    .repeat:
      lodsb           ; Get character from String
      cmp al,0
      je .done        ; If char is zero,end of String
      mov ah,print it
      int 10h         
    
      mov ah,02h     ; update cursor position
      int 10h
      inc dl          ; same as `add dl,1` but smaller 
    
      jmp .repeat
    
    .done:
      ret

大佬总结

以上是大佬教程为你收集整理的程序集引导加载程序继续使用“mov ah, 09h”打印 S全部内容,希望文章能够帮你解决程序集引导加载程序继续使用“mov ah, 09h”打印 S所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:ah