這裏是分配:彙編語言程序設計 - 致命錯誤A1010
寫「菜單式」程序,從鍵盤讀取一個段落,並以下列方式進行處理:
張數 計算字數, 計算與您的姓氏的第三個字母相同的字母數, 計算大寫字母的數量。
終止與特殊字符的段落:
如果你的姓氏以A,B,C,d,E開始,F,G,H終止與#段落,
如果你的姓如果您的姓氏以R,S,T,U,V,W,X,Y,Z開頭,則以I,J,K,L,M,N,O,P開頭,並以%終止該段落,
用&,
終止段落對於此練習,您需要使用子程序。閱讀主要程序中的段落;
子過程中的過程段落(每個計數的單獨過程)。
這是我的代碼,我在最後一行得到一個A1010錯誤(不匹配塊嵌套:主),我找不到原因,請幫忙。我使用Visual Studio 2015年:
include Irvine32.inc
displayMSG MACRO MSG
MOV AH, 09H
LEA DX, MSG
INT 21H
ENDM
.DATA
para DB 100 , ? , 100 DUP('$')
;messages for menu
mes1 DB 0AH, 0DH, 'MENU $'
mes21 DB 0AH, 0DH, '1.COUNT CHARACTERS $'
mes22 DB 0AH, 0DH, '2.COUNT WORDS $'
mes23 DB 0AH, 0DH, '3.COUNT CAPITAL LETTERS $'
mes24 DB 0AH, 0DH, '4.COUNT THIRD LETTER $'
mes25 DB 0AH, 0DH, '5.EXIT $'
mes3 DB 0AH, 0DH, 'ENTER YOUR CHOICE : $'
mes4 DB 0AH, 0DH, 'WRONG CHOICE $'
mes5 DB 0AH, 0DH, 'ENTER THE PARAGRAPH : $'
mes6 DB 0AH, 0DH, 'NUMBER OF CHARACTERS IS : $'
mes7 DB 0AH, 0DH, 'NUMBER OF WORDS $'
mes8 DB 0AH, 0DH, 'NUMBER OF CAPITAL LETTERS $'
mes9 DB 0AH, 0DH, 'NUMBER OF THIRD LETTER $'
.CODE
main PROC
start:
mov ax, @data
mov ds, ax
mov es, ax
displayMSG mes5 ;PROMPT THE USER TO ENTER A PARAGRAPH
mov ah, 0ah ; Accept PARAGRAPH
lea dx, para
int 21h
;DISPLAY MENU TO THE USER
menu :
displayMSG mes1
displayMSG mes21
displayMSG mes22
displayMSG mes23
displayMSG mes24
displayMSG mes25
displayMSG mes3 ; accept choice
mov ah, 01h
int 21h
mov bl, al ; userChoice BL
cmp bl, 31h ; if userChoice=1
je FINDCHAR ; Find NUMBER OF CHARACTERS IN THE STRING
cmp bl, 32h ; if userChoice=2
je FINDWORDS ; FIND NUMBER OF WORDS
cmp bl, 33h ; if userChoice=3
je FINDCAPITAL ; FIND NUMBER OF CAPITAL LETTERS
cmp bl, 34h ; if userChoice=4
je FINDLETTER
cmp bl, 35h ; if userChoice=5
je L1 ; exit
displayMSG mes4 ; Wrong Choice
jmp menu
FINDCHAR:
call FINDCHARPROC
jmp menu
FINDWORDS :
call FINDWORDSPROC
jmp menu
FINDCAPITAL:
call FINDCAPITALSPROC
jmp menu
FINDLETTER :
call FINDTHIRDPROC
jmp menu
L1:
end start
exit
exit
main ENDP
;procedure THAT FINDS NUMBER OF CHARACTERS
FINDCHARPROC proc
displayMSG mes6
mov dl, para+1 ; NUMBER OF CHARACTERS IN THE PARAGRAPH
or dl, 30h
mov ah, 02h ; DISPLAY THE CHARACTERS COUNT
int 21h
ret
FINDCHARPROC ENDP
;find number of WORDS in the paragraph
FINDWORDSPROC proc
mov dl,00h
mov ch, 00h
lea esi, para+2
mov cl, para+1
mov bl,20h ;ASCII value of space
loopAn:
dec cl
cmp cl, 00h
je printWordCount
cmp bl, [esi] ;check if character is space
je incWordCnt
inc esi
jne loopAn
incWordCnt:
inc dl
inc esi
jmp loopAn
printWordCount:
displayMSG mes7
or dl,30h
mov ah,02h
int 21h
ret
FINDWORDSPROC ENDP
;find number of CAPITAL letters in the paragraph
FINDCAPITALSPROC proc
mov dl,00h
mov ch, 00h
lea esi, para+2 ; USER INPUTTED PARAGRAPH
mov cl, para+1
loopAgn:
dec cl
cmp cl, 00h
je printcapitalCount
mov al, byte ptr[esi]
cmp al,"A" ;check if character is capital
jb nextChar
cmp al,"Z" ;check if character is capital
ja nextChar
inc esi
inc dl
jne loopAgn
nextChar:
inc esi
jmp loopAgn
printcapitalCount :
displayMSG mes8
or dl,30h
mov ah,02h
int 21h
ret
FINDCAPITALSPROC ENDP
;count the number of third letter present in the paragraph
FINDTHIRDPROC proc
mov dl,00h
mov ch, 00h
lea esi, para+2 ; DESTINATION STRING
mov cl, para+1
call ReadChar ;get THIRD letter of your name
loopTemp:
dec cl
cmp cl, 00h
je printCount
cmp al, [esi] ;check if character is your third letter
je incCnt
inc esi
jne loopTemp
incCnt:
inc dl
inc esi
jmp loopTemp
printCount :
displayMSG mes9
or dl,30h
mov ah,02h
int 21h
ret
FINDTHIRDPROC ENDP
END main
你有'結束開始'在'L1'。不知道你想在那裏做什麼,你應該刪除它。 – Jester
好的,我刪除了,但現在我得到了第59行的這個錯誤:錯誤2004符號類型衝突 'mov ax,@ data' – cantoX
請標記問題中的第59行。 – Jester