近跳或呼叫不同的CS

问题描述 投票:1回答:1

对不起,我是汇编的初学者,所以当我尝试跳入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 :     

谢谢你的帮助。谢谢你的帮助。

assembly tasm
1个回答
1
投票

完全固定的你的代码(有一些猜测,你想要什么),以及更广泛的指令使用,从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(奔腾),386模拟非常非常稳固,486也很好AFAIK,586更实验...现在我不确定,如果没有一瞥“686”(“核心二重奏”是吗?英特尔不再使用“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)...

http://www.wagemakers.be/english/doc/vga获取的VGA 12h模式VRAM访问知识(如何设置蓝色位平面)(不确定该文章的总质量,我基本上确切地知道我在寻找什么(只是VGA控制端口号+哪个位是掩码),还记得如何组织16种颜色模式VRAM以及我需要在那里写什么,所以我没有阅读整篇文章。

© www.soinside.com 2019 - 2024. All rights reserved.