COMMENT+ Note: This illustrates the use of multiline comments! Hw2 V22.0201.002, Machine Organization Fall 1997, Chee Yap This is a sample BUGGY solution for hw1. In hw2, the STUDENTS MUST DISCOVER THE BUGS HERE USING A DEBUGGER + title hw1, echorev program .model small .stack 100h .data CR equ 13 LF equ 10 Greeting db 'Welcome to my echo/reverse program!',CR,LF db 'Please type any 16 characters at the prompt. $' Prompt db CR,LF,'>>$' Input db 16 dup (?),'$' EchoPrompt db CR,LF,'Here is your input: $' RevPrompt db CR,LF,'And its reversal: $' .code main proc ; mov ax,@data mov ds,ax ; ; Print Greeting lea dx,Greeting mov ah,9 int 21h ; Request Input lea dx,Prompt mov ah,9 int 21h ; Read 16 characters ; NOTE: we use loops here, but ; you are not expected to do this for hw1. ; That is a bit painful, admittedly. mov cx,16 mov bx,0 mov ah,1 ; function 1 of int 21h (read char) Again: int 21h ; read a character into al mov [bx+Input],al ; save it in Input inc bx ; get ready for next input position loop Again ; Echo the input mov ah,9 lea dx,EchoPrompt int 21h lea dx,Input int 21h ; Reverse the input ; We want to exchange the contents ; of Input[i] with Input[15-i] ; for i=0,1,2,...,7. mov cx,8 mov bx,0 Repeat: mov ah,[Input+bx] xchg ah,[Input-bx+15] xchg ah,[Input+bx] inc bx loop Repeat ; Print the reversed input mov ah,9 lea dx,RevPrompt int 21h lea dx,Input int 21h ; DOS cleanup mov ax,4c00h int 21h main endp end main