CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
IBM Rational 系统开发最佳实践工具包 WebSphere MQ 最佳实践 TOP 15
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  其他开发语言 >  汇编语言

大侠,帮我看看这段保护模式代码,怎么编译时候出了这么多错误呀.!!!!!!!!!

楼主ywchen2000(灌水大帝:努力奋斗)2004-04-04 18:29:42 在 其他开发语言 / 汇编语言 提问

;--------------------------------------------------------  
  ea20               macro                                       //打开A20地址线  
                                  push         ax  
                                  in             al,92h  
                                  or             al,00000010b  
                                  out           92h,al  
                                  pop           ax  
                                  endm  
  ;----------------------------------------------------------------------------  
  ;关闭A20地址线  
  ;----------------------------------------------------------------------------  
  da20             macro  
                                  push         ax  
                                  in             al,92h  
                                  and           al,11111101b  
                                  out           92h,al  
                                  pop           ax                                
              endm  
  ;----------------------------------------------------------------------------  
  jump macro selector,offsetv                             //跳转宏  
  db 0EAh  
  dw offsetv  
  dw selector  
  endm  
  ;--------------------  
  descriptor struc                                               //描述符的结构  
  limitl dw 0  
  basel dw 0  
  basem db 0  
  attributes dw 0  
  baseh db 0  
  descriptor ends  
  ;--------------------  
  pdesc struc     //伪描述府  
  limit dw 0  
  base dd 0  
  pdesc ends  
  ;  
  atdw=92h  
  atce=98h  
  atcer=9ah  
  atldt=82h  
  TIL=1  
  .386P  
  ;---------------------------------------------------------------------------------------  
  gdtseg segment use16  
  gdt label byte  
  dummy descriptor <>  
  code         descriptor             <0FFFFh,,,atce,>  
  code_sel=code-gdt  
  ;代码段codekseg的描述符  
  codek descriptor <0FFFFh,,,atdw,>  
  codek_sel=codek-gdt  
  ;通用描述符  
  normal descriptor <0FFFFh,,,atdw,>  
  normal_sel=normal-gdt  
  ;局部描述表的描述符  
  ldtable descriptor <0FFFFh,,,atldt,>  
  ldt_sel=ldtable-gdt  
  gdtlen=$-gdt  
  vgdtr pdesc <gdtlen-1,>  
  gdtseg ends  
  ;------------------------------------------------------------------  
  ;局部描述表  
  ldtseg segment use16  
  ldt label byte  
  ;数据段ldtseg的描述符    
  data descriptor <0FFFFh,,,atdw,>                      
  data_sel=(data-ldt)+TIL  
  ;代码段vcode的描述符  
  vcode descriptor <0FFFFh,,,atce,>                
  vcode_sel=(vcode-ldt)+TIL  
  ;要显示的数据  
  vdata descriptor <0FFFFh,,,atdw,>  
  vdata_sel=(vdata-ldt)+TIL  
  ;要显示的数据2  
  vdata1 descriptor <0FFFFh,,,atdw,>  
  vdata1_sel=(vdata1-ldt)+TIL  
  ;  
  vbuf descriptor <0FFFFh,8000,0b,atdw,>  
  vbuf_sel=(vbuf-ldt)+TIL        
  ldtseg ends  
  ;-----------------------------------------------------  
  ;代码段  
  vdseg       segment   use16  
  yang         db             'how   are   you',0  
  vdseg       ends  
  ;-----------------------------------------------------  
  vdseg1     segment   use16  
  hello       db             'hello',0  
  hellolen=$-hello  
  vdseg1     ends  
  ;-----------------------------------------------------  
  vcseg       segment   use16        
                  assume     cs:vcseg  
  vstart:   mov           ax,vdata_sel  
                  mov           ds,ax  
                  mov           ax,vbuf_sel  
                  mov           es,ax  
                  lea           si,yang  
                  xor           bx,bx  
                  mov           cx,14  
  again:     mov           al,[si]  
                  mov           ah,07h  
                  mov           es:[bx],ax  
                  add           bx,2  
                  inc           si  
                  loop         again  
                  ;hello  
                  mov           ax,vdata1_sel  
                  mov           ds,ax  
                  lea           si,hello  
                  mov           cx,hellolen  
  again1:   mov           al,[si]  
                  mov           ah,0F4h  
                  mov           es:[bx],ax  
                  add           bx,2  
                  inc           si  
                  loop         again1  
  gojump:   jump         <code_sel>,<offset   toreal>    
  vcseg       ends  
  ;-----------------------------------------------------  
  codekseg segment use16  
  assume cs:codekseg  
  startk: mov ax,ldt_sel  
  lldt ax  
  jump <vcode_sel>,<offset vstart>  
   
  codekseg ends  
  ;-----------------------------------------------------  
  cseg segment use16  
  assume cs:cseg  
  start: mov ax,gdtseg  
  mov ds,ax  
  mov bx,16  
  mul bx  
  add ax,offset gdt  
  adc dx,0  
  mov word ptr   vgtdr.base,ax  
  mov word ptr vgtdr.base+2,dx  
  ;  
  mov ax,cseg  
  mul bx  
                  mov           word         ptr           code.basel,ax  
                  mov           byte         ptr           code.basem,dl  
                  mov           byte         ptr           code.baseh,dh  
                  ;  
  mov ax,codekseg  
  mul bx  
  mov word ptr codek.basel,ax  
  mov byte ptr codek.basem,dl  
  mov byte ptr codek.baseh,dh  
  ;  
  push ds  
  mov ax,ldtseg  
  mov ds,ax  
  mul bx  
  mov word ptr ldtable.basel,ax  
  mov byte ptr ldtable.basem,dl  
  mov byte ptr ldtable.baseh,dh  
  ;  
  mov           ax,vcseg  
                  mul           bx  
                  mov           word         ptr           vcode.basel,ax  
                  mov           byte         ptr           vcode.basem,dl  
                  mov           byte         ptr           vcode.baseh,dh  
                  ;  
                  mov           ax,vdseg  
                  mul           bx  
                  mov           word         ptr           vdata.basel,ax  
                  mov           byte         ptr           vdata.basem,dl  
                  mov           byte         ptr           vdata.baseh,dh  
                  ;  
                  mov           ax,vdseg1  
                  mul           bx  
                  mov           word         ptr           vdata1.basel,ax  
                  mov           byte         ptr           vdata1.basem,dl  
                  mov           byte         ptr           vdata1.baseh,dh  
                  pop ds  
                  ;  
  lgdt qword ptr vgtdr  
  cli  
  ea20                                                                             //  
  mov eax,cr0     //    
  or eax,1     //      
  mov cr0,eax     //  
  jump <codek_sel>,<offset   startk>               //     proctect   mode    
   
  toreal: mov ax,normal_sel  
  mov ds,ax  
  mov eax,cr0  
  and eax,0FFFFFFFEH  
  mov cr0,eax  
  jump <seg real>,<offset real>  
  real: da20  
  sti  
  mov ah,4ch  
  int 21h  
  cseg ends  
  end start  
  ;-------------------------------------------------------------------------------  
   
  编译时候,好多符号没有定义呀.可是我在数据段已经定义了呀.  
  对于保护模式下的程序,我真的不知道怎么调试呀.  
   
   
   
   
   
   
  问题点数:100、回复次数:11Top

1 楼csdsjkk()回复于 2004-04-04 19:28:29 得分 100

;--------------------------------------------------------  
  ea20               macro   ;                                     //打开A20地址线  
                                  push         ax  
                                  in             al,92h  
                                  or             al,00000010b  
                                  out           92h,al  
                                  pop           ax  
                                  endm  
  ;----------------------------------------------------------------------------  
  ;关闭A20地址线  
  ;----------------------------------------------------------------------------  
  da20             macro  
                                  push         ax  
                                  in             al,92h  
                                  and           al,11111101b  
                                  out           92h,al  
                                  pop           ax                                
              endm  
  ;----------------------------------------------------------------------------  
  jump         macro       selector,offsetv   ;                           //跳转宏  
  db 0EAh  
  dw offsetv  
  dw selector  
  endm  
  ;--------------------  
  descriptor             struc                           ;                     //描述符的结构  
  limitl dw 0  
  basel dw 0  
  basem db 0  
  attributes dw 0  
  baseh db 0  
  descriptor ends  
  ;--------------------  
  pdesc       struc                                             ;               //伪描述府    
  limit dw 0  
  base dd 0  
  pdesc ends  
  ;  
  atdw=92h  
  atce=98h  
  atcer=9ah  
  atldt=82h  
  TIL=4  
  .386P  
  ;---------------------------------------------------------------------------------------  
  gdtseg segment use16  
  gdt label byte  
  dummy descriptor <>  
  code         descriptor             <0FFFFh,,,atce,>  
  code_sel=code-gdt  
  ;代码段codekseg的描述符  
  codek descriptor <0FFFFh,,,atce,>  
  codek_sel=codek-gdt  
  ;通用描述符  
  normal descriptor <0FFFFh,,,atdw,>  
  normal_sel=normal-gdt  
  ;局部描述表的描述符  
  ldtable descriptor <0FFFFh,,,atldt,>  
  ldt_sel=ldtable-gdt  
  gdtlen=$-gdt  
  vgdtr pdesc <gdtlen-1,>  
  gdtseg ends  
  ;------------------------------------------------------------------  
  ;局部描述表  
  ldtseg segment use16  
  ldt label byte  
  ;数据段ldtseg的描述符    
  data descriptor <0FFFFh,,,atdw,>                      
  data_sel=(data-ldt)+TIL  
  ;代码段vcode的描述符  
  vcode descriptor <0FFFFh,,,atce,>                
  vcode_sel=(vcode-ldt)+TIL  
  ;要显示的数据  
  vdata descriptor <0FFFFh,,,atdw,>  
  vdata_sel=(vdata-ldt)+TIL  
  ;要显示的数据2  
  vdata1 descriptor <0FFFFh,,,atdw,>  
  vdata1_sel=(vdata1-ldt)+TIL  
  ;  
  vbuf descriptor <0FFFFh,8000h,0bh,atdw,>  
  vbuf_sel=(vbuf-ldt)+TIL        
  ldtseg ends  
  ;-----------------------------------------------------  
  ;代码段  
  vdseg       segment   use16  
  yang         db             'how   are   you',0  
  vdseg       ends  
  ;-----------------------------------------------------  
  vdseg1     segment   use16  
  hello       db             'hello',0  
  hellolen=$-hello  
  vdseg1     ends  
  ;-----------------------------------------------------  
  vcseg       segment   use16        
                  assume     cs:vcseg  
  vstart:   mov           ax,vdata_sel  
                  mov           ds,ax  
                  mov           ax,vbuf_sel  
                  mov           es,ax  
                  lea           si,yang  
                  xor           bx,bx  
                  mov           cx,11     ;14  
  again:     mov           al,[si]  
                  mov           ah,07h  
                  mov           es:[bx],ax  
                  add           bx,2  
                  inc           si  
                  loop         again  
                  ;hello  
                  mov           ax,vdata1_sel  
                  mov           ds,ax  
                  lea           si,hello  
                  mov           cx,hellolen  
  again1:   mov           al,[si]  
                  mov           ah,0F4h  
                  mov           es:[bx],ax  
                  add           bx,2  
                  inc           si  
                  loop         again1  
  gojump:   jump         <code_sel>,<offset   toreal>    
  vcseg       ends  
  ;-----------------------------------------------------  
  codekseg segment use16  
  assume cs:codekseg  
  startk: mov ax,ldt_sel  
  lldt ax  
  jump <vcode_sel>,<offset vstart>  
   
  codekseg ends  
  ;-----------------------------------------------------  
  cseg segment use16  
                  assume     cs:cseg,ds:gdtseg  
  start: mov ax,gdtseg  
  mov ds,ax  
  mov bx,16  
  mul bx  
  add ax,offset gdt  
  adc dx,0  
                  mov           word         ptr           vgdtr.base,ax  
                  mov           word         ptr           vgdtr.base+2,dx  
  ;  
  mov ax,cseg  
  mul bx  
                  mov           word         ptr           code.basel,ax  
                  mov           byte         ptr           code.basem,dl  
                  mov           byte         ptr           code.baseh,dh  
                  ;  
  mov ax,codekseg  
  mul bx  
  mov word ptr codek.basel,ax  
  mov byte ptr codek.basem,dl  
  mov byte ptr codek.baseh,dh  
  ;  
  mov ax,ldtseg  
  mul bx  
  mov word ptr ldtable.basel,ax  
  mov byte ptr ldtable.basem,dl  
  mov byte ptr ldtable.baseh,dh  
  ;  
  push ds  
  mov ax,ldtseg  
  mov ds,ax  
   
                  assume   ds:ldtseg  
   
  mov           ax,vcseg  
                  mul           bx  
                  mov           word         ptr           vcode.basel,ax  
                  mov           byte         ptr           vcode.basem,dl  
                  mov           byte         ptr           vcode.baseh,dh  
                  ;  
                  mov           ax,vdseg  
                  mul           bx  
                  mov           word         ptr           vdata.basel,ax  
                  mov           byte         ptr           vdata.basem,dl  
                  mov           byte         ptr           vdata.baseh,dh  
                  ;  
                  mov           ax,vdseg1  
                  mul           bx  
                  mov           word         ptr           vdata1.basel,ax  
                  mov           byte         ptr           vdata1.basem,dl  
                  mov           byte         ptr           vdata1.baseh,dh  
                  pop ds  
                  ;  
                  assume     ds:gdtseg  
                  lgdt         fword       ptr           vgdtr  
  cli  
                  ea20                                                 ;                             //  
                  mov           eax,cr0                             ;                           //      
                  or             eax,1                                   ;                         //        
                  mov           cr0,eax                                 ;                       //    
                  jump         <codek_sel>,<offset   startk>   ;             //     proctect   mode    
   
  toreal: mov ax,normal_sel  
  mov ds,ax  
  mov eax,cr0  
  and eax,0FFFFFFFEH  
  mov cr0,eax  
  jump <seg real>,<offset real>  
  real: da20  
  sti  
  mov ah,4ch  
  int 21h  
  cseg ends  
  end start  
  Top

2 楼Areslee(懒虫易水)回复于 2004-04-04 19:35:19 得分 0

用TASM编译  
  如果用MASM 6.XX编译需要加上/Zm开关Top

3 楼ywchen2000(灌水大帝:努力奋斗)回复于 2004-04-04 19:41:22 得分 0

to     csdsjkk():  
  请问你改了那个地方,我的代码写的........Top

4 楼xinhongfengye(红枫叶)回复于 2004-04-04 19:47:26 得分 0

;--------------------------------------------------------  
  ea20               macro   ;                                     //打开A20地址线  
                                  push         ax  
                                  in             al,92h  
                                  or             al,00000010b  
                                  out           92h,al  
                                  pop           ax  
                                  endm  
  ;----------------------------------------------------------------------------  
  ;关闭A20地址线  
  ;----------------------------------------------------------------------------  
  da20             macro  
                                  push         ax  
                                  in             al,92h  
                                  and           al,11111101b  
                                  out           92h,al  
                                  pop           ax                                
              endm  
  ;----------------------------------------------------------------------------  
  jump         macro       selector,offsetv   ;                           //跳转宏  
  db 0EAh  
  dw offsetv  
  dw selector  
  endm  
  ;--------------------  
  descriptor             struc                           ;                     //描述符的结构  
  limitl dw 0  
  basel dw 0  
  basem db 0  
  attributes dw 0  
  baseh db 0  
  descriptor ends  
  ;--------------------  
  pdesc       struc                                             ;               //伪描述府    
  limit dw 0  
  base dd 0  
  pdesc ends  
  ;  
  atdw=92h  
  atce=98h  
  atcer=9ah  
  atldt=82h  
  TIL=4  
  .386P  
  ;---------------------------------------------------------------------------------------  
  gdtseg segment use16  
  gdt label byte  
  dummy descriptor <>  
  code         descriptor             <0FFFFh,,,atce,>  
  code_sel=code-gdt  
  ;代码段codekseg的描述符  
  codek descriptor <0FFFFh,,,atce,>  
  codek_sel=codek-gdt  
  ;通用描述符  
  normal descriptor <0FFFFh,,,atdw,>  
  normal_sel=normal-gdt  
  ;局部描述表的描述符  
  ldtable descriptor <0FFFFh,,,atldt,>  
  ldt_sel=ldtable-gdt  
  gdtlen=$-gdt  
  vgdtr pdesc <gdtlen-1,>  
  gdtseg ends  
  ;------------------------------------------------------------------  
  ;局部描述表  
  ldtseg segment use16  
  ldt label byte  
  ;数据段ldtseg的描述符    
  data descriptor <0FFFFh,,,atdw,>                      
  data_sel=(data-ldt)+TIL  
  ;代码段vcode的描述符  
  vcode descriptor <0FFFFh,,,atce,>                
  vcode_sel=(vcode-ldt)+TIL  
  ;要显示的数据  
  vdata descriptor <0FFFFh,,,atdw,>  
  vdata_sel=(vdata-ldt)+TIL  
  ;要显示的数据2  
  vdata1 descriptor <0FFFFh,,,atdw,>  
  vdata1_sel=(vdata1-ldt)+TIL  
  ;  
  vbuf descriptor <0FFFFh,8000h,0bh,atdw,>  
  vbuf_sel=(vbuf-ldt)+TIL        
  ldtseg ends  
  ;-----------------------------------------------------  
  ;代码段  
  vdseg       segment   use16  
  yang         db             'how   are   you',0  
  vdseg       ends  
  ;-----------------------------------------------------  
  vdseg1     segment   use16  
  hello       db             'hello',0  
  hellolen=$-hello  
  vdseg1     ends  
  ;-----------------------------------------------------  
  vcseg       segment   use16        
                  assume     cs:vcseg  
  vstart:   mov           ax,vdata_sel  
                  mov           ds,ax  
                  mov           ax,vbuf_sel  
                  mov           es,ax  
                  lea           si,yang  
                  xor           bx,bx  
                  mov           cx,11     ;14  
  again:     mov           al,[si]  
                  mov           ah,07h  
                  mov           es:[bx],ax  
                  add           bx,2  
                  inc           si  
                  loop         again  
                  ;hello  
                  mov           ax,vdata1_sel  
                  mov           ds,ax  
                  lea           si,hello  
                  mov           cx,hellolen  
  again1:   mov           al,[si]  
                  mov           ah,0F4h  
                  mov           es:[bx],ax  
                  add           bx,2  
                  inc           si  
                  loop         again1  
  gojump:   jump         <code_sel>,<offset   toreal>    
  vcseg       ends  
  ;-----------------------------------------------------  
  codekseg segment use16  
  assume cs:codekseg  
  startk: mov ax,ldt_sel  
  lldt ax  
  jump <vcode_sel>,<offset vstart>  
   
  codekseg ends  
  ;-----------------------------------------------------  
  cseg segment use16  
                  assume     cs:cseg,ds:gdtseg  
  start: mov ax,gdtseg  
  mov ds,ax  
  mov bx,16  
  mul bx  
  add ax,offset gdt  
  adc dx,0  
                  mov           word         ptr           vgdtr.base,ax  
                  mov           word         ptr           vgdtr.base+2,dx  
  ;  
  mov ax,cseg  
  mul bx  
                  mov           word         ptr           code.basel,ax  
                  mov           byte         ptr           code.basem,dl  
                  mov           byte         ptr           code.baseh,dh  
                  ;  
  mov ax,codekseg  
  mul bx  
  mov word ptr codek.basel,ax  
  mov byte ptr codek.basem,dl  
  mov byte ptr codek.baseh,dh  
  ;  
  mov ax,ldtseg  
  mul bx  
  mov word ptr ldtable.basel,ax  
  mov byte ptr ldtable.basem,dl  
  mov byte ptr ldtable.baseh,dh  
  ;  
  push ds  
  mov ax,ldtseg  
  mov ds,ax  
   
                  assume   ds:ldtseg  
   
  mov           ax,vcseg  
                  mul           bx  
                  mov           word         ptr           vcode.basel,ax  
                  mov           byte         ptr           vcode.basem,dl  
                  mov           byte         ptr           vcode.baseh,dh  
                  ;  
                  mov           ax,vdseg  
                  mul           bx  
                  mov           word         ptr           vdata.basel,ax  
                  mov           byte         ptr           vdata.basem,dl  
                  mov           byte         ptr           vdata.baseh,dh  
                  ;  
                  mov           ax,vdseg1  
                  mul           bx  
                  mov           word         ptr           vdata1.basel,ax  
                  mov           byte         ptr           vdata1.basem,dl  
                  mov           byte         ptr           vdata1.baseh,dh  
                  pop ds  
                  ;  
                  assume     ds:gdtseg  
                  lgdt         fword       ptr           vgdtr  
  cli  
                  ea20                                                 ;                             //  
                  mov           eax,cr0                             ;                           //      
                  or             eax,1                                   ;                         //        
                  mov           cr0,eax                                 ;                       //    
                  jump         <codek_sel>,<offset   startk>   ;             //     proctect   mode    
   
  toreal: mov ax,normal_sel  
  mov ds,ax  
  mov eax,cr0  
  and eax,0FFFFFFFEH  
  mov cr0,eax  
  jump <seg real>,<offset real>  
  real: da20  
  sti  
  mov ah,4ch  
  int 21h  
  cseg ends  
  end startTop

5 楼ywchen2000(灌水大帝:努力奋斗)回复于 2004-04-04 20:26:47 得分 0

TIL=1  
  为什么要吧TIL改位四呢,TIL=1说明他是从局部描述表中取得描述符呀Top

6 楼csdsjkk()回复于 2004-04-04 20:38:11 得分 0

段选择符格式:  
  15..3       2     1   0  
  index     TI     RPL  
  Top

7 楼ywchen2000(灌水大帝:努力奋斗)回复于 2004-04-04 20:51:05 得分 0

还是这段代码,我编译通过了,但是运行起来,系统就重启呀.@_@  
   
  ;--------------------------------------------------------  
  ea20               macro                                       ;打开A20地址线  
                                  push         ax  
                                  in             al,92h  
                                  or             al,00000010b  
                                  out           92h,al  
                                  pop           ax  
                                  endm  
  ;----------------------------------------------------------------------------  
  ;关闭A20地址线  
  ;----------------------------------------------------------------------------  
  da20             macro  
                                  push         ax  
                                  in             al,92h  
                                  and           al,11111101b  
                                  out           92h,al  
                                  pop           ax                                
              endm  
  ;----------------------------------------------------------------------------  
  jump macro selector,offsetv                             ;跳转宏  
  db 0EAh  
  dw offsetv  
  dw selector  
  endm  
  ;--------------------  
  descriptor struc                                               ;描述符的结构  
  limitl dw 0  
  basel dw 0  
  basem db 0  
  attributes dw 0  
  baseh db 0  
  descriptor ends  
  ;--------------------  
  pdesc struc     ;伪描述府  
  limit dw 0  
  base dd 0  
  pdesc ends  
  ;  
  atdw=92h  
  atce=98h  
  atcer=9ah  
  atldt=82h  
  TIL=4  
  .386P  
  ;---------------------------------------------------------------------------------------  
  gdtseg segment use16  
  gdt label byte  
  dummy descriptor <>  
  code         descriptor             <0FFFFh,,,atce,>  
  code_sel=code-gdt  
  ;代码段codekseg的描述符  
  codek descriptor <0FFFFh,,,atdw,>  
  codek_sel=codek-gdt  
  ;通用描述符  
  normal descriptor <0FFFFh,,,atdw,>  
  normal_sel=normal-gdt  
  ;局部描述表的描述符  
  ldtable descriptor <0FFFFh,,,atldt,>  
  ldt_sel=ldtable-gdt  
  gdtlen=$-gdt  
  vgdtr pdesc <gdtlen-1,>  
  gdtseg ends  
  ;------------------------------------------------------------------  
  ;局部描述表  
  ldtseg segment use16  
  ldt label byte  
  ;数据段ldtseg的描述符    
  data descriptor <0FFFFh,,,atdw,>                      
  data_sel=(data-ldt)+TIL  
  ;代码段vcode的描述符  
  vcode descriptor <0FFFFh,,,atce,>                
  vcode_sel=(vcode-ldt)+TIL  
  ;要显示的数据  
  vdata descriptor <0FFFFh,,,atdw,>  
  vdata_sel=(vdata-ldt)+TIL  
  ;要显示的数据2  
  vdata1 descriptor <0FFFFh,,,atdw,>  
  vdata1_sel=(vdata1-ldt)+TIL  
  ;  
  vbuf descriptor <0FFFFh,8000,0b,atdw,>  
  vbuf_sel=(vbuf-ldt)+TIL        
  ldtseg ends  
  ;-----------------------------------------------------  
  ;代码段  
  vdseg       segment   use16  
  yang         db             'how   are   you',0  
  vdseg       ends  
  ;-----------------------------------------------------  
  vdseg1     segment   use16  
  hello       db             'hello',0  
  hellolen=$-hello  
  vdseg1     ends  
  ;-----------------------------------------------------  
  vcseg       segment   use16        
                  assume     cs:vcseg  
  vstart:   mov           ax,vdata_sel  
                  mov           ds,ax  
                  mov           ax,vbuf_sel  
                  mov           es,ax  
                  lea           si,yang  
                  xor           bx,bx  
                  mov           cx,11  
  again:     mov           al,[si]  
                  mov           ah,07h  
                  mov           es:[bx],ax  
                  add           bx,2  
                  inc           si  
                  loop         again  
                  ;hello  
                  mov           ax,vdata1_sel  
                  mov           ds,ax  
                  lea           si,hello  
                  mov           cx,hellolen  
  again1:   mov           al,[si]  
                  mov           ah,0F4h  
                  mov           es:[bx],ax  
                  add           bx,2  
                  inc           si  
                  loop         again1  
  gojump:   jump         <code_sel>,<offset   toreal>    
  vcseg       ends  
  ;-----------------------------------------------------  
  codekseg segment use16  
  assume cs:codekseg  
  startk: mov ax,ldt_sel  
  lldt ax  
  jump <vcode_sel>,<offset vstart>  
   
  codekseg ends  
  ;-----------------------------------------------------  
  cseg segment use16  
  assume cs:cseg,ds:gdtseg  
  start: mov ax,gdtseg  
  mov ds,ax  
  mov bx,16  
  mul bx  
  add ax,offset gdt  
  adc dx,0  
  mov word ptr   vgdtr.base,ax  
  mov word ptr vgdtr.base+2,dx  
  ;  
  mov ax,cseg  
  mul bx  
                  mov           word         ptr           code.basel,ax  
                  mov           byte         ptr           code.basem,dl  
                  mov           byte         ptr           code.baseh,dh  
                  ;  
  mov ax,codekseg  
  mul bx  
  mov word ptr codek.basel,ax  
  mov byte ptr codek.basem,dl  
  mov byte ptr codek.baseh,dh  
  ;  
   
  mov ax,ldtseg  
  mul bx  
  mov word ptr ldtable.basel,ax  
  mov byte ptr ldtable.basem,dl  
  mov byte ptr ldtable.baseh,dh  
  ;  
  push ds  
   
  mov ax,ldtseg  
  mov ds,ax  
  assume ds:ldtseg  
   
  mov           ax,vcseg  
                  mul           bx  
                  mov           word         ptr           vcode.basel,ax  
                  mov           byte         ptr           vcode.basem,dl  
                  mov           byte         ptr           vcode.baseh,dh  
                  ;  
                  mov           ax,vdseg  
                  mul           bx  
                  mov           word         ptr           vdata.basel,ax  
                  mov           byte         ptr           vdata.basem,dl  
                  mov           byte         ptr           vdata.baseh,dh  
                  ;  
                  mov           ax,vdseg1  
                  mul           bx  
                  mov           word         ptr           vdata1.basel,ax  
                  mov           byte         ptr           vdata1.basem,dl  
                  mov           byte         ptr           vdata1.baseh,dh  
                  pop ds  
                  ;  
                  assume ds:gdtseg  
                  lgdt         fword       ptr           vgdtr  
  cli  
  ea20                                                                          
  mov eax,cr0  
  or eax,1  
  mov cr0,eax  
  jump <codek_sel>,<offset   startk>              
   
  toreal: mov ax,normal_sel  
  mov ds,ax  
  mov eax,cr0  
  and eax,0FFFFFFFEH  
  mov cr0,eax  
  jump <seg real>,<offset real>  
  real: da20  
  sti  
  mov ah,4ch  
  int 21h  
  cseg ends  
  end start  
   
   
   
   
   
   
  Top

8 楼csdsjkk()回复于 2004-04-04 21:01:34 得分 0

我改的没问题呀Top

9 楼ywchen2000(灌水大帝:努力奋斗)回复于 2004-04-04 21:05:24 得分 0

你的那段代码可以运行,可能你改了一个地方我没有发现呀Top

10 楼csdsjkk()回复于 2004-04-04 21:11:35 得分 0

codek descriptor <0FFFFh,,,atdw,>  
  改为:  
  codek descriptor <0FFFFh,,,atce,>  
  Top

11 楼ywchen2000(灌水大帝:努力奋斗)回复于 2004-04-04 21:16:34 得分 0

呵呵,谢谢Top

相关问题

  • 请看这段代码怎么有编译错误。。。
  • 方法重载,这个代码编译错误了
  • 吐血送分!编译下列代码出现一堆错误!
  • 编译错误
  • 编译错误!!
  • 编译错误??
  • 编译错误!!
  • 编译错误???
  • 编译错误
  • 编译错误

关键词

  • 代码
  • 数据
  • vdata
  • 描述符
  • movax
  • vdseg
  • baseh
  • basel
  • ax
  • sel

得分解答快速导航

  • 帖主:ywchen2000
  • csdsjkk

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo