近跳转或呼叫不同的CS

Near jump or call to different CS

抱歉,我是组装初学者,所以当我尝试跳入 TASM 时出现错误,我想将这些像素的颜色设置为蓝色,但出现了这些错误,请帮助我 所以这是我的代码:

data_here segment
    px dw 0
    py dw 0
ends

stack segment
    dw   128  dup(0)
ends

code segment

start:
; set segment registers:
    ;mov ax, data_here
    ;mov ds, ax
    ;mov es, ax

    assume ds:data_here   
;80x*60y 640*480
mov ax,012h
int 10h

ppos1:
mov al, 1
mov cx, px
mov dx, py
mov ah, 0ch
int 10h
inc px
cmp px,59
jne ppos1
inc py    
cmp py,5
jne ppos1    

mov ah,7
int 21h

int 20h


ends

end start 

这是 TASM 结果:

-------------
12/20/2017 12:27:35 AM :     Assembling file - C:\cxcc.asm
12/20/2017 12:27:37 AM :     Turbo Assembler  Version 4.1  Copyright (c) 1988, 1996 Borland International
12/20/2017 12:27:37 AM :     
12/20/2017 12:27:37 AM :     Assembling file:   cxcc.asm
12/20/2017 12:27:37 AM :     *Warning* cxcc.asm(7) Reserved word used as symbol: STACK
12/20/2017 12:27:37 AM :     **Error** cxcc.asm(32) Near jump or call to different CS
12/20/2017 12:27:37 AM :     **Error** cxcc.asm(35) Near jump or call to different CS
12/20/2017 12:27:37 AM :     Error messages:    2
12/20/2017 12:27:37 AM :     Warning messages:  1
12/20/2017 12:27:37 AM :     Passes:            1
12/20/2017 12:27:37 AM :     Remaining memory:  468k
12/20/2017 12:27:37 AM :     

感谢 help.thanks 的帮助。

完全固定你的代码(有一些猜测,你想要什么),以及更广泛地使用指令,从 http://www.ousob.com/ng/masm/ng3e51c.php 阅读(我在某个地方也有原始的 TASM 书籍,它们在包装中,但是不知道他们在哪里结束,可能在某个更大盒子里的某个盒子里,离上个千年很近……可能需要打电话给考古学家)

.MODEL SMALL
data_here SEGMENT USE16 PAGE MEMORY
    px dw 0
    py dw 0
ENDS

my_stack SEGMENT USE16 PAGE STACK
    dw   128  dup(0)
ENDS

my_code SEGMENT USE16 PARA PUBLIC

    ASSUME cs:my_code, ss:my_stack
start:
; set segment registers:
    mov ax, data_here
    mov ds, ax
    ASSUME ds:data_here

    ;80x*60y 640*480
    mov ax,012h
    int 10h

    xor bh,bh       ; page number for pixel write = 0
ppos1:
    mov ax, 0C01h   ; ah = 0C (write pixel), al = 1 (blue color)
    mov cx, [px]
    mov dx, [py]
    int 10h
    inc word ptr [px]
    cmp word ptr [px],59
    jne ppos1
    mov word ptr [px],0
    inc word ptr [py]
    cmp word ptr [py],5
    jne ppos1

    ; wait for console input without echo
    mov ah,7
    int 21h
    ; restore text mode
    mov ax,3
    int 10h
    ; terminate EXE through int 21,4C (int 20h works for COM files)
    mov ah,4Ch
    int 21h

ENDS

END start

我的版本看起来如何 - 避免极慢的 BIOS 写入像素,并使用 80386 指令(32b 寄存器):

(dosbox 0.74 我正在使用它作为 DOS 模拟器支持 CPU 高达 80586 (Pentium),并且 386 仿真非常非常可靠,486 也很好 AFAIK,586 更具实验性...现在我不确定,如果看不到“686”("core duo" 是吗?英特尔不再使用“686”,因为数字不能注册为 (tm),遗憾的是,数字方案比目前市场上的四代 "i7" CPU 更清晰,不确定哪个是最新的没有研究),但我认为它远未奏效,如果它在那里)

.MODEL SMALL
data_here SEGMENT USE16 PAGE MEMORY
ENDS

my_stack SEGMENT USE16 PAGE STACK
    dw   1024  dup(0)
ENDS

my_code SEGMENT USE16 PARA PUBLIC
.386

    ASSUME cs:my_code, ss:my_stack
start:
    ; init environment
    mov ax, data_here
    mov ds, ax
    ASSUME ds:data_here
    mov ax,0A000h
    mov es,ax       ; es = VRAM segment for direct VRAM writes
    ;640x480 16 colour mode
    mov ax,012h
    int 10h

    ; draw 59x5 rectangle [0, 0] -> [58, 4] with blue color (1)
    mov dx,03C4h    ; dx = VGA control index register
    mov ax,0102h    ; INDEX = MASK MAP, MASK = 0x01 (blue bitplane)
    out dx,ax       ; other planes are zeroed by mode change
                    ; so I will modify only blue bitplane
    xor di,di       ; initial address to write
    mov dx,5        ; number of lines to fill
    mov eax,0FFFFFFFFh   ; fill value with pixel bits (all set)
fill_line:
    ; 59 pixels = 7 full bytes (8 bits), and 3 bits in last 8th byte
    stosd           ; 4 bytes written
    stosw           ; 6 bytes written
    stosb           ; 7 bytes written
    ; patch remaining 3 bits (3 pixels) of 8th byte
    mov bl,es:[di]  ; read VRAM
    or  bl,0E0h     ; set top 3 bits of old value
    mov es:[di],bl  ; write it back to VRAM
    ; actually mov byte ptr es:[di],0E0h would work too, because clear screen
    ; but this is also showing how set bit to 1 works with OR
    add di,640/8-7  ; advance DI to next line
    dec dx
    jnz fill_line

    ; wait for console input without echo
    mov ah,7
    int 21h
    ; restore text mode
    mov ax,3
    int 10h
    ; terminate EXE through int 21,4C (int 20h works for COM files)
    mov ah,4Ch
    int 21h

ENDS

END start

在 DOSBOX 0.74 中使用 TASM 4.1 和 TLINK 7.1.30.1 进行测试,例如:

C:\>TASM TEST_EXE
  ... TASM output ...
C:\>TLINK TEST_EXE
  ... TLINK output (just version + copyright)
C:\>TEXT_EXE.EXE
  .. switches to gfx mode and draws small blue rectangle, waits for some key, exits to DOS (restoring text mode)...

VGA 12h mode VRAM access knowledge (how to set blue bitplane) 取自http://www.wagemakers.be/english/doc/vga(不确定那篇文章的总体质量,我基本上知道我在找什么(只是VGA控制port number + which bit is mask), 还记得16种颜色模式VRAM是怎么组织的,需要写什么,所以没看全文