找到你要的答案

Q:TASM error: CS unreachable from current segment

Q:错误:无法从当前TASM CS段

I recently installed tasm for winxp using windows xp mode and installed it. The tasm and tlink commands work, but I get an error at either MAIN PROC or START:, same error for both.

This is my code to input a number and output that same number:

.model small    
.stack 100h
.code
.data

start:
mov ah,1
int 21h

mov dl,al
mov ah,2
int 21h

mov ah,4ch
int 21h

end start

and the error I get is:

name.asm(5) CS unreachable from current segment

Is it possible this is due to my software? Initially I was using tasm w/DOSBox for win7, but that kept resetting on it's own and showing symbols all over the screen. enter image description here

我最近安装的TASM winxp使用Windows XP模式安装它。TASM和神州龙命令的工作,但我得到一个错误是主要的触发或启动,对于同样的错误。

这是我的代码输入一个数字,输出相同的数字:

.model small    
.stack 100h
.code
.data

start:
mov ah,1
int 21h

mov dl,al
mov ah,2
int 21h

mov ah,4ch
int 21h

end start

我得到的错误是:

name.asm(5) CS unreachable from current segment

Is it possible this is due to my software? Initially I was using tasm w/DOSBox for win7, but that kept resetting on it's own and showing symbols all over the screen. enter image description here

answer1: 回答1:

The OP's code started with the following. I've added comments:

.model small    ; Code and Data max 64K
.stack 100h     ; Only 256 bytes of stack
.code           ; Start writing code...
.data           ; Start giving some data...

start:          ; Here's the entry point
mov ah,1        ; Put 1 into ah

And the assembler was giving the error CS unreachable from the current segment.

@Michael Petch pointed out that by opening the .data segment and then writing code, the OP was trying to put code into the data segment - which the assembler didn't like. By swapping the .code and .data statements, the assembler was satisfied.

OP的代码开始如下。我增加了评论:

.model small    ; Code and Data max 64K
.stack 100h     ; Only 256 bytes of stack
.code           ; Start writing code...
.data           ; Start giving some data...

start:          ; Here's the entry point
mov ah,1        ; Put 1 into ah

和汇编给了错误的CS从遥不可及的当前段。

”Michael Petch指出,通过开放。数据段,然后写代码,作品试图把代码插入到数据段,汇编不喜欢。通过交换代码和数据语句,汇编器得到了满足。

assembly  windows-xp  tasm