i 在今天的考试中提出这个问题,我为这个问题写了某些法典。 我要告诉我,哪里确实错了。
Problem: for an 8086 microprocessor,write code that does the following task. it asks for user to enter the data and it counts the keypresses..
on execution of the ALP,the first message is obtained "counting keypresses , press escape to stop." (without quotation marks) , if the user enters the escape, the second message "counting keypresses" is shown and the result of the count is stored in BX and shown in displayed in binary. also the keys pressed (while entering data) ,the input key shall be echoed in the next line.
Solution: (that i wrote)
.model tiny
.data
text1 db "counting keypresses,press escape to stop $"
text2 db "counting keypresses"
.code
.startup
mov dx,offset text1 ;displaying text1 (i guess so)
mov ah,09h
int 21h
and bx,00h
label1 mov ah,01h ;(getting input from user and incrementing bx on every click)
int 21h
inc bx
cmp al,1bh ;comparing with escape
np label1
mov dx,offset text2 ;if zero then do this i.e display text2
mov ah,09h
int 21h
mov dx,offset bx ;display bx
mov ah,09h
int 21h
.exit
end
i am not sure if the comments i added are suitable or not. i know my code wont be correct,infact it wont be correct at all,but i managed to write this on the basis of my one night preparation.so if anyone could tell me,what wrong i am doing,then i will be highly thankful. because i really need to perform well in the next exam.