近跳或呼叫其他CS [英] Near jump or call to different CS

查看:153
本文介绍了近跳或呼叫其他CS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

sorry , I'm a beginner to assembly , so I got an error when i try to jump in TASM , I wanted to set color of these pixels to blue , but i got these errors , please help me so this is my code:

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 :     

感谢您的帮助.

推荐答案

您的代码完全固定(有些猜测,您想要什么),并且使用了更广泛的指令,请从

Fully fixed code of yours (with some guessing, what did you want), and somewhat more extensive use of directives, read from http://www.ousob.com/ng/masm/ng3e51c.php (I have somewhere also original TASM books which were in package, but no idea where they did end, probably in some box inside some bigger box, placed very close to the previous millennium... need to call archaeologists probably)

.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寄存器):

And how would my version look - avoiding extremely slow BIOS write pixel, and using 80386 instructions (32b registers):

(dosbox 0.74最多支持80586(Pentium)的CPU,386仿真非常稳定,AFAIK 486也很好,586更具实验性...现在我不是当然,如果看不到"686"(是"core duo"吗?英特尔不再使用"686",因为数字无法注册为(tm)),可惜,数字方案更加清楚了比目前市场上的四代"i7" CPU还不确定,但不确定是否有最新消息),但如果有的话,我认为它还远远不能工作.

(dosbox 0.74 which I'm using as DOS emulator supports CPU up to 80586 (Pentium), and 386 emulation is very very solid, 486 is fine too AFAIK, 586 is more experimental ... now I'm not sure, if there's not a glimpse of "686" ("core duo" was it? Intel didn't use "686" any more as numbers can't be registered as (tm), pity, the number scheme was much more clear than current four generations of "i7" CPU on market, not being sure which is latest without research), but I think it's far from working, if it's there)

.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进行了测试,例如:

Tested with TASM 4.1 and TLINK 7.1.30.1 in DOSBOX 0.74, like:

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模式VRAM访问知识(如何设置蓝色位平面)取自 http://www.wagemakers.be/english/doc/vga (不确定该文章的总体质量,我基本上完全知道我要查找的内容(只是VGA控制端口号+掩码位),回想起16种颜色模式VRAM的组织方式以及我在那里需要写的内容,因此我没有阅读整篇文章.

The VGA 12h mode VRAM access knowledge (how to set blue bitplane) taken from http://www.wagemakers.be/english/doc/vga (not sure about total quality of that article, I basically knew exactly what I was looking for (just the VGA control port number + which bit is mask), still recalling how the 16 colour modes VRAM is organized and what I need to write there, so I didn't read the whole article.

这篇关于近跳或呼叫其他CS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆