Code works on bochs but does not on real computer, x86 real mode

被刻印的时光 ゝ 提交于 2019-12-13 16:19:45

问题


This small piece of code works fine on bochs 2.6, but doesn't seem to work on 'real' computers (I've tried several of them). It seems like lodsb is causing the problem, since it worked fine, when I did hello world by printing the string "manually" character by character.

.code16
.text
.globl _start
_start:

    movw $0, %ax
    jmp main

### DATA AND BUFFERS ###
welcome:
    .asciz "welcome"

main:
    movw $welcome, %si
    call print_string

hang:
    jmp hang

print_string:
    lodsb

    cmp $0, %al
    je done

    mov $0x0e, %ah
    int $0x10
    jmp print_string

done:
    ret


. = _start + 510
.byte 0x55
.byte 0xaa

Since I don't have a debugger on my 'real' computer I can't quite figure out what is the problem and restarting computer so many times becomes really frustrating. Can the problem be with segment registers?

Problem solved: Issue was with the direction flag, that unlike bochs was set backwards when bios jumped on my code. For more details and suggestions to avoid further problems see the answers below.

来源:https://stackoverflow.com/questions/36195242/code-works-on-bochs-but-does-not-on-real-computer-x86-real-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!