书上源代码,为何出错?《80x86汇编语言设计教程》(杨季文等编)

boodweb 2001-04-22 12:53:00
错误信息:
Turbo Assembler Version 3.2 Copyright (c) 1988, 1992 Borland International

Assembling file: t10-4.asm
**Error** t10-4.asm(41) Offset or pointer is 32-bit
**Error** t10-4.asm(44) Offset or pointer is 32-bit
**Error** t10-4.asm(47) Offset or pointer is 32-bit
**Error** t10-4.asm(53) Offset or pointer is 32-bit
**Error** t10-4.asm(56) Offset or pointer is 32-bit
**Error** t10-4.asm(59) Offset or pointer is 32-bit
*Warning* t10-4.asm(172) Operand size conflict
*Warning* t10-4.asm(175) Operand size conflict

源代码:
(386scd.asm)
;存储段描述符/系统段描述符 结构类型的定义
DESCRIPTOR STRUC
LIMITL DW 0
BASEL DW 0
BASEM DB 0
ATTRIBUTES DW 0
BASEH DB 0
DESCRIPTOR ENDS
;
GATE STRUC
OFFSETL DW 0
SELECTOR DW 0
DCOUNT DB 0
GTYPE DB 0
OFFSETH DW 0
GATE ENDS
;
PDESC STRUC
LIMIT DW 0
BASE DD 0
PDESC ENDS
;
TASKSS STRUC
TRLINK DW ?,0
TRESP0 DD ?
TRSS0 DW ?,0
TRESP1 DD ?
TRSS1 DW ?,0
TRESP2 DD ?
TRSS2 DW ?,0
TRCR3 DD ?
TREIP DD ?
TREFLAG DW ?,?
TREAX DD ?
TRECX DD ?
TREDX DD ?
TREBX DD ?
TRESP DD ?
TREBP DD ?
TRESI DD ?
TREDI DD ?
TRES DW ?,0
TRCS DW ?,0
TRSS DW ?,0
TRDS DW ?,0
TRFS DW ?,0
TRGS DW ?,0
TRLDT DW ?,0
TRFLAG DW 0
TRIOMAP DW $+2
TASKSS ENDS
;
ATDR=90H
ATDW=92H
ATDWA=93H
ATCE=98H
ATCER=9AH
ATCCO=9CH
ATCCOR=9EH
;
ATLDT=82H
ATTASKGAT=85H
AT386TSS=89H
AT386CGAT=8CH
AT386IGAT=8EH
AT386TGAT=8FH
;
;
DPL1=20H
DPL2=40H
DPL3=60H
RPL1=01H
RPL2=02H
RPL3=03H
IOPL1=1000H
IOPL2=2000H
IOPL3=3000H
;
D32=4000H
TIL=04H
VMFL=0002H
IFL=0200H

;
JUMP32 MACRO selector,offsetv
DB 0EAH
DW offsetv
DW 0
DW selector
ENDM
CALL32 MACRO selector,offsetv
DB 09AH
DW offsetv
DW 0
DW selector
ENDM
JUMP16 MACRO selector,offsetv
DB 0EAH
DW offsetv
DW selector
ENDM
CALL16 MACRO selector,offsetv
DB 09AH
DW offsetv
DW selector
ENDM

(t10-4.asm)
INCLUDE 386SCD.ASM
.386P

GDTSEG SEGMENT PARA USE16
GDT LABEL BYTE
DUMMY DESCRIPTOR <>
NORMAL DESCRIPTOR <0FFFFH,0,0,ATDW,0>
NORMAL_SEL=NORMAL-GDT
EFFGDT LABEL BYTE

DEMOTSS DESCRIPTOR <DemoTSSLEN-1,DemoTSSSEG,,AT386TSS,>
DemoTSS_SEL=DEMOTSS-GDT

DEMOLDTD DESCRIPTOR <DemoLDTLEN-1,DemoLDTSEG,,ATLDT,>
DemoLDT_SEL=DEMOLDTD-GDT

TEMPCODE DESCRIPTOR <0FFFFH,TempCodeSEG,,ATCE,>
TempCode_SEL=TEMPCODE-GDT

VIDEOBUFFER DESCRIPTOR <0FFFFH,0,0,0F00H+ATDW+DPL3,0>
Video_SEL=VIDEOBUFFER-GDT

GDNUM=($-EFFGDT)/(SIZE DESCRIPTOR)
GDTLEN=$-GDT
GDTSEG ENDS

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

DemoLDTSEG SEGMENT PARA USE16
DemoLDT LABEL BYTE

DEMOSTACK0 DESCRIPTOR <DemoStack0LEN-1,DemoStack0SEG,,ATDW+D32,>
DemoStack0_SEL=(DEMOSTACK0-DemoLDT)+TIL

DEMOSTACK1 DESCRIPTOR <DemoStack1LEN-1,DemoStack1SEG,,ATDW+D32,>
DemoStack1_SEL=(DEMOSTACK1-DemoLDT)+TIL+RPL1

DEMOSTACK3 DESCRIPTOR <DemoStack3LEN-1,DemoStack3SEG,,ATDW+D32,>
DemoStack3_SEL=(DEMOSTACK3-DemoLDT)+TIL+RPL3

DEMOCODE DESCRIPTOR <DemoCodeLEN-1,DemoCodeSEG,,ATCE+D32+DPL3,>
DemoCode_SEL=(DEMOCODE-DemoLDT)+TIL+RPL3

T32CODE DESCRIPTOR <T32CodeLEN-1,T32CodeSEG,,ATCE+D32,>
T32Code_SEL=(T32CODE-DemoLDT)+TIL

ECHOSUBR DESCRIPTOR <EchoSUBRLEN-1,EchoSUBRSEG,,ATCE+D32+DPL1,>
Echo_SEL1=(ECHOSUBR-DemoLDT)+TIL+RPL1
Echo_SEL3=(ECHOSUBR-DemoLDT)+TIL+RPL3

DemoLDNUM=($-DemoLDT)/(SIZE DESCRIPTOR)

TO32GATEA DESCRIPTOR <T32Begin,T32Code_SEL,0,AT386CGAT,0>
ToT32A_SEL=(TO32GATEA-DemoLDT)+TIL

TO32GATEB DESCRIPTOR <T32End,T32Code_SEL,0,AT386CGAT+DPL3,0>
ToT32B_SEL=(TO32GATEA-DemoLDT)+TIL

TOECHOGATE DESCRIPTOR <EchoSUB,Echo_SEL3,0,AT386CGAT+DPL3,0>
ToEcho_SEL=(TOECHOGATE-DemoLDT)+TIL

DemoLDTLEN=$-DemoLDT
DemoLDTSEG ENDS

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

DemoTSSSEG SEGMENT PARA USE16
DD 0
DW DemoStack0LEN,0
DW DemoStack0_SEL,0
DW DemoStack1LEN,0
DW DemoStack1_SEL,0
DD ?
DW ?,0
DD 0
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DW ?,0
DW ?,0
DW ?,0
DW ?,0
DW ?,0
DW ?,0
DW DemoLDT_SEL,0
DW 0
DW $+2
DB 0FFH
DemoTSSLEN=$
DemoTSSSEG ENDS

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

DemoStack0SEG SEGMENT PARA USE32
DemoStack0LEN=512
DB DemoStack0LEN DUP (0)
DemoStack0SEG ENDS

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

DemoStack1SEG SEGMENT PARA USE16
DemoStack1LEN=512
DB DemoStack1LEN DUP (0)
DemoStack1SEG ENDS

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

DemoStack3SEG SEGMENT PARA USE16
DemoStack3LEN=512
DB DemoStack3LEN DUP (0)
DemoStack3SEG ENDS

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

EchoSUBRSEG SEGMENT PARA USE32
MESSAGE DB 'CPL=',0
ASSUME CS:EchoSUBRSEG
EchoSUB PROC FAR
CLD
PUSH EBP
MOV EBP,ESP
MOV AX,Echo_SEL1
MOV DS,AX
MOV AX,Video_SEL
MOV ES,AX
MOV EDI,0B8000H
MOV AH,17H
EchoSUB1:
LODSB
OR AL,AL
JZ EchoSUB2
STOSW
JMP EchoSUB1
EchoSUB2:
MOV EAX,[EBP+8]
AND AL,3
AND AL,'0'
MOV AH,17H
STOSW
POP EBP
RETF
EchoSUB ENDP
EchoSUBRLEN=$
EchoSUBRSEG ENDS

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

DemoCodeSEG SEGMENT PARA USE32
ASSUME CS:DemoCodeSEG
DemoBegin:
CALL32 ToEcho_SEL,0
CALL32 ToT32B_SEL,0
DemoCodeLEN=$
DemoCodeSEG ENDS

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

T32CodeSEG SEGMENT PARA USE32
ASSUME CS:T32CodeSEG
T32Begin:
MOV AX,DemoStack0_SEL
MOV SS,AX
MOV ESP,DemoStaCK0LEN

PUSH DWORD PTR DemoStack3_SEL
PUSH DWORD PTR DemoStack3LEN

PUSH DWORD PTR DemoCode_SEL
PUSH OFFSET DemoBegin
RETF
T32END:
JUMP32 TempCode_SEL,<OFFSET ToReal>
T32CodeLEN=$
T32CodeSEG ENDS

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

TempCodeSEG SEGMENT PARA USE16
ASSUME CS:TempCodeSEG
Virtual:
MOV AX,DemoTSS_SEL
LTR AX

MOV BX,DemoLDT_SEL
LLDT BX
JUMP16 ToT32A_SEL,0
ToReal:
MOV AX,Normal_SEL
MOV DS,AX
MOV ES,AX
MOV FS,AX
MOV GS,AX
MOV SS,AX

MOV EAX,CR0
AND AX,0FFFEH
MOV CR0,EAX
JUMP16 <SEG Real>,<OFFSET Real>
TempCodeLEN=$
TempCodeSEG ENDS

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

RDataSEG SEGMENT PARA USE16
VGDTR PDESC <GDTLEN-1,>
SPVAR DW ?
SSVAR DW ?
RDataSEG ENDS

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

RCodeSEG SEGMENT PARA USE16
ASSUME CS:RCodeSEG,DS:RDataSEG
Start:
MOV AX,RDataSEG
MOV DS,AX
CLD
CALL INIT_GDT

MOV AX,DemoLDTSEG
MOV FS,AX
MOV SI,OFFSET DemoLDT
MOV CX,DemoLDNUM
CALL INIT_LDT

MOV SSVAR,SS
MOV SPVAR,SP

LGDT QWORD PTR VGDTR
CLI
MOV EAX,CR0
OR AX,1
MOV CR0,EAX
JUMP16 TempCode_SEL,<OFFSET Virtual>
Real:
MOV AX,RDataSEG
MOV DS,AX
LSS SP,DWORD PTR SPVAR
STI
MOV AX,4C00H
INT 21H

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

INIT_GDT PROC NEAR
PUSH DS
MOV AX,GDTSEG
MOV DS,AX
MOV CX,GDNUM
MOV SI,OFFSET EFFGDT
INITG: MOV AX,[SI].BASEL
MOVZX EAX,AX
SHL EAX,4
SHLD EDX,EAX,16
MOV [SI].BASEL,AX
MOV [SI].BASEM,DL
MOV [SI].BASEH,DH
ADD SI,SIZE DESCRIPTOR
LOOP INITG
POP DS

MOV BX,16
MOV AX,GDTSEG
MUL BX
MOV WORD PTR VGDTR.BASE,AX
MOV WORD PTR VGDTR.BASE+2,DX
RET
INIT_GDT ENDP

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

INIT_LDT PROC NEAR
ILDT: MOV AX,FS:[SI].BASEL
MOVZX EAX,AX
SHL EAX,4
SHLD EDX,EAX,16
MOV FS:[SI].BASEL,AX
MOV FS:[SI].BASEM,DL
MOV FS:[SI].BASEH,DH
ADD SI,SIZE DESCRIPTOR
LOOP ILDT
RET
INIT_LDT ENDP
RCodeSEG ENDS
END Start
...全文
139 点赞 收藏 11
写回复
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
boodweb 2001-05-06
aaa
回复
boodweb 2001-05-02
哦,算了,我找到tasm3.0了,谢谢各位
不过说也奇怪,为什么高版本不兼容低版本呢?
回复
snowingedge 2001-04-30
"描述符中的段界限如果是32位段的(如:EchoSUBRLEN=$),其长度应该是32位的,但是定义的描述符结构中段界限却只有16位,我该如何解决呢?"----->将描述符中的G位设为1,OK!
回复
fd 2001-04-30
到 http://llyycchhcc.top263.net 看以下,那有原码
回复
boodweb 2001-04-29
To repus & alwaysakid:
我.386已经加了,没贴出来而已

To cui(蚊子王):
可以将3.1寄给我吗?(只要几个主要文件就可以了)
boodweb@263.net
回复
蚊子王 2001-04-27
这个问题我看了想了两天也想不明白,但你这程序在Tasm3.1能通过(你用的是3.2),在Tlink一下就行了,Tlink 要加/3选项。
回复
alwaysakid 2001-04-26
for masm 6 and up
.386p
.model flat,stdcall
回复
repus 2001-04-26
最前面加上伪指令
.386
回复
boodweb 2001-04-26
可是我换了masm 5.1还是有错啊
原因好象是这样的:描述符中的段界限如果是32位段的(如:EchoSUBRLEN=$),其长度应该是32位的,但是定义的描述符结构中段界限却只有16位,我该如何解决呢?
DESCRIPTOR STRUC
LIMITL DW 0
回复
fd 2001-04-24
用 masm5.1就行了.
如果用 6.14以上版本 注意 不能用 coff选项
回复
Areslee 2001-04-23
用MASM 6。X试试
回复
发动态
发帖子
汇编语言
创建于2007-08-27

2.0w+

社区成员

汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
申请成为版主
社区公告
暂无公告