Answer to Question #285951 in Assembler for nvhdoo

Question #285951

Write an assembly language program that input characters string and prints them in reverse order. Use a stack. HINT: Take user input with interrupt method in loop until user press Enter


1
Expert's answer
2022-01-09T02:21:00-0500
.stack 16h
DATA SEGMENT
msg   db "String: $"

DATA ENDS

CODE SEGMENT
START:
    MOV AX,DATA
    MOV DS,AX    
    MOV ES,AX

; print a  message:
    mov dx, offset msg
    mov ah, 9
    int 21h

    xor cx,cx  ; counter
     
 wait_key:
     mov ah, 0
    int 16h
        
;print charecter    
    mov     ah, 0eh
    int     10h
    push ax     ; push  character on stack
    inc cx      ; char counter++
    
    cmp     al, 13
    jz      reverse
jmp     wait_key
;============================

reverse:
; set cursor
    mov    ah,2h
    mov dx, 200h
    int 10h
    
; prints string in reverse order
print:     
     pop ax  
;print charecter     
     mov ah, 0eh
     int 10h
     dec cx
     cmp cx,0
     jnz print   
    
   MOV AH,1            
    INT 16H    

     MOV AH,4CH
     INT 21H

CODE ENDS
END START

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS