美好的一天!我是汇编语言(特别是TASM)的新手,我这里有一个简单的球(字符串,由字符组成),我想把它移到右边。
.MODEL SMALL
.STACK 100
.DATA
ball DB 10," #######"
DB 10,"# #"
DB 10,"# #"
DB 10,"# #"
DB 10," #######","$"
ROW1 DB 5
ROW2 DB 10
COL DB 25
MAX DB ?
RAND DB ?
ATT DB 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
.CODE
.STARTUP
mov ax, @data ;required
mov ds, ax
MOV AX, 3 ; 80x25 color
INT 10H ; video BIOS call
MOV AH, 2 ; set cursor position
MOV BH, 0 ; display page number
MOV DH, ROW1 ; row number
MOV DL, COL ; column number
INT 10H ; video BIOS call
LEA BP, ATT ; point to first attribute array
CALL FAR PTR MOVE ; display first line of video text
MOV MAX, AL ;max=10
@TIMELOOPS1:
;get system time
MOV AH, 2Ch
INT 21h
MOV RAND, DH
@WAIT1SEC1:
MOV AH, 2Ch
INT 21h
CMP RAND, DH
JE @WAIT1SEC1
MOV AH, 2
MOV DL, '.'
INT 21H
MOV AH, 2 ; set cursor position
MOV BH, 0 ; display page number
MOV DH, ROW2 ; row number
MOV DL, COL ; column number
INT 10H ; video BIOS call
LEA BP, ATT ; point to first attribute array
CALL FAR PTR MOVE ; display first line of video text
;clear
DEC MAX
CMP MAX, 0
JNE @TIMELOOPS1
.EXIT
MOVE PROC FAR
MOV SI, 0 ; set up array pointer
NEXT:
MOV AL, ball[SI]; get name character
;xor al, al
CMP AL, '$' ; exit if character is 0
JZ EXIT
CMP AL, 10
JE LF
MOV BH, 0 ; display page number
MOV BL, [BP+SI] ; get attribute
MOV CX, 1 ; do 1 character
MOV AH, 9 ; write character/attribute on screen
INT 10H ; video BIOS call
INC SI ; point to next character/attribute
ADD DL, 1 ; move one column to the right
MOV AH, 2 ; set cursor position
INT 10H ; video BIOS call
JMP NEXT ; and continue
EXIT: ret
LF:
MOV BH, 0 ; display page number
MOV BL, [BP+SI] ; get attribute
MOV CX, 1 ; do 1 character
MOV AH, 0Ah ; write character/attribute on screen
MOV AL, 10
INT 12H ; video BIOS call
INC SI ; point to next character/attribute
ADD DH, 1 ; move one column to the right
MOV DL,0
MOV AH, 2 ; set cursor position
INT 10H ; video BIOS call
JMP NEXT ; and continue
MOVE ENDP
END
我要做的是每秒打印一个点.
,这样球就会向右移动。但它只是打印一个点然后再次打印球串。
现在,我正在考虑清除初始球然后将其移动到接下来的3列。但是,它会让人感到困惑,因为它已经操纵了每个字符的列和行,以便打印整个字符串。
请帮助我让球移动。非常感谢你!
编辑
在Jim Mischel爵士之后,我在致电MOV AL, COL
后立即添加了INC AL
,MOV COL, AL
,MOVE
。但是,它只显示一次球并且程序没有停止(我看不到J:/TASM/BIN
)。
.MODEL SMALL
.STACK 100
.DATA
ball DB 10," #######"
DB 10,"# #"
DB 10,"# #"
DB 10,"# #"
DB 10," #######","$"
ROW1 DB 5
ROW2 DB 10
COL DB 25
MAX DB ?
RAND DB ?
ATT DB 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
.CODE
.STARTUP
mov ax, @data ;required
mov ds, ax
MOV MAX, AL ;max=10
@TIMELOOPS1:
;get system time
MOV AH, 2Ch
INT 21h
MOV RAND, DH
@WAIT1SEC1:
MOV AH, 1
INT 16h
;JNZ @ENDPROGRAM
MOV AH, 2Ch
INT 21h
CMP RAND, DH
JE @WAIT1SEC1
MOV AX, 3 ; 80x25 color
INT 10H ; video BIOS call
MOV AH, 2 ; set cursor position
MOV BH, 0 ; display page number
MOV DH, ROW2 ; row number
MOV DL, COL ; column number
INT 10H ; video BIOS call
LEA BP, ATT ; point to first attribute array
CALL FAR PTR MOVE ; display first line of video text
MOV AL, COL
INC AL
MOV COL, AL
;clear
DEC MAX
CMP MAX, 0
JNE @TIMELOOPS1
.EXIT
MOVE PROC FAR
MOV SI, 0 ; set up array pointer
NEXT:
MOV AL, ball[SI]; get name character
;xor al, al
CMP AL, '$' ; exit if character is 0
JZ EXIT
CMP AL, 10
JE LF
MOV BH, 0 ; display page number
MOV BL, [BP+SI] ; get attribute
MOV CX, 1 ; do 1 character
MOV AH, 9 ; write character/attribute on screen
INT 10H ; video BIOS call
INC SI ; point to next character/attribute
ADD DL, 1 ; move one column to the right
MOV AH, 2 ; set cursor position
INT 10H ; video BIOS call
JMP NEXT ; and continue
EXIT: ret
LF:
MOV BH, 0 ; display page number
MOV BL, [BP+SI] ; get attribute
MOV CX, 1 ; do 1 character
MOV AH, 0Ah ; write character/attribute on screen
MOV AL, 10
INT 12H ; video BIOS call
INC SI ; point to next character/attribute
ADD DH, 1 ; move one column to the right
MOV DL,0
MOV AH, 2 ; set cursor position
INT 10H ; video BIOS call
JMP NEXT ; and continue
MOVE ENDP
END
答案 0 :(得分:0)
在您的代码中,在调用MOVE
proc:
MOV DL, COL ; column number
INT 10H ; video BIOS call
LEA BP, ATT ; point to first attribute array
CALL FAR PTR MOVE ; display first line of video text
如果要在每次循环中向右移动,则每次循环时都必须递增COL
值。我建议在致电MOVE
之后添加以下内容:
MOV AL, COL
INC AL
MOV COL, AL
所以第一次通过循环,COL
是25.下次是26,等等。 。