在协助* .asm程序时出错

时间:2014-01-28 14:56:16

标签: assembly

我必须在接下来的几天为大学做一个演示,所以我需要用Assambler语言学习一个程序如何逐行工作。我从网上获取了这个源代码,我意识到他没有标题如:.model堆栈和数据所以我已经推出了它们。但是我还有4个错误要修复。 该计划应该这样做: ;给你一个屏幕按钮,用鼠标点击,然后 ;只有当你这样做时才会收获!

以下是该计划的源代码:

.model small
.stack 100h
.data
;Gives you an on-screen button to click on with the mouse, and
;proceeds only when you do!
mov ah,06h ;this calls SCROLL SCREEN UP
mov al,00h ;AL specifies how many lines... 0 just clears the screen
mov ch,00h
mov cl,00h
mov dh,24h
mov dl,80h
int 10h

;The above lines just clear the screen.

mov ah,02h ;Set cursor position
mov dh,0Bh ;row
mov dl,22h ;column
int 10h    ;Actually does it. :)
MOV AX,SEG MESSAGE
MOV DS,AX               
MOV DX,OFFSET MESSAGE

mov ah,0009             ;9 in AH makes INT 21 print the string
int 21h                 ;referenced in DS:DX.

;So, we have printed BUTTON right where we want it!!!

mov ax,0001
int 33h

;Now, that's got the mouse on.

MOUSLOOP:

MOV AX,5     ;5 in AX tells INT 33 to get mouse button press info
INT 33h      ;get mouse button info
CMP AX,1b    ;this compares AX (button status) with 1
JNE MOUSLOOP ;unless LEFT button ONLY is pressed, go back to MOUSLOOP

;(Only the left button will work for this... Not the right.)

MOV AX,3
INT 33h      ;Now we're getting the POSITION info through INT 33,3!

;CX now is mouse horizontal position. 0 - 639
;DX now is mouse vertical position. 0 - 199

CMP CX,270
JL MOUSLOOP ;If CX is less than 270 (left edge of button), go back
CMP CX,315
JG MOUSLOOP ;If CX if more than 400 (right edge), go back
CMP DX,85
JL MOUSLOOP ;If DX is less than 85 (top), go back
CMP DX,95
JG MOUSLOOP ;If DX is more than 110 (bottom), go back

;The numbers above for the button dimensions are approximations, but
;should be good enough.

mov ax,0002
int 33h

;This just hides the cursor. Otherwise it would stay on when the program
;ended! :)

mov ah,4ch             ;terminate program
int 21h

MESSAGE: DB 'BUTTON$'
接下来会出现

错误:

Line 34 - CS unreachable from current segment
Line 70 - CS unreachable from current segment
FATAL line 71 - Unexpected end of file encountered

我在64x和DoxBox上使用Windows 8.1来尝试程序。 谢谢你的帮助。

1 个答案:

答案 0 :(得分:1)

我没有足够的评论点,所以我把它作为答案:

这是TASM吗?你还没有说明你的汇编程序。

.data
.code
MAIN PROC
MAIN ENDP
END

main:
end main
end

无论你在特定汇编程序中为代码做什么。

这应该解释文件问题的结束以及每个细分的实施问题。我有点新,但我认为你只是没有结束代码块。

此外,您的代码是16位,如果您正在运行Windows,可能会导致问题。