当前位置: 代码迷 >> 汇编语言 >> 关于jmp段间转移,该怎么解决
  详细解决方案

关于jmp段间转移,该怎么解决

热度:777   发布时间:2013-02-26 00:00:00.0
关于jmp段间转移
在网上看了个代码,类似这样的

jmp _go_init,INIT_SETUP

我下载的nasm编译工具好像不支持jmpi,所以我想换成jmp,下面是代码,不知道对不对.

jmp [ INIT_SETUP + _go_init ]

但是执行后并没有预想的结果,"load loader"字符串没有打印出来,哪位高手帮忙看看,下面是全部代码,谢谢.




; name   :   boot
; writer :   jues
; home   :   http://blog.sina.com.cn/xiaogeyou
; date   :   2012-08-01


;----------------------------------------------------
%define BOOT_SETUP      07c00h
%define INIT_SETUP      09000h
%define LOADER_SETUP    09200h
;----------------------------------------------------

    org BOOT_SETUP
    jmp _start  ;start exec


;----------------------------------------------------

; string

    start_boot  db  'boot'
    start_boot_len  equ $-start_boot

    load_loader  db  'load loader'
    load_loader_len  equ $-load_loader


;string line number

    string_line db  00h

;----------------------------------------------------

_print:

    mov bp,ax
    mov cx,bx

    mov        ax, 01301h
    mov        bx, 000fh

;----------------------------------------------------

;auto next line show

    mov dl,0h
    mov        dh,[ string_line ]
    int        10h
    add dh,1h
    mov [ string_line ],dh

ret

;----------------------------------------------------

;start here

_start:

    mov ax,cs
    mov ds,ax
    mov es,ax

    mov ax,start_boot
    mov bx,start_boot_len
    call _print
    call _init_setup         ;copy boot to INIT_SETUP
    jmp [ INIT_SETUP + _go_init ]


_go_init:
    mov ax,cs
    mov ds,ax
    mov es,ax
    mov ss,ax
    call _load_loader

ret
;----------------------------------------------------
;copy boot from BOOT_SETUP to INIT_SETUP

_init_setup:

    mov ax,BOOT_SETUP
    mov ds,ax
    mov ax,INIT_SETUP
    mov es,ax
    mov cx,100h ;256*2 = 512(boot size)
    sub si,si
    sub di,di
    rep
    movsw


ret

;----------------------------------------------------
  相关解决方案