In assembly masm use the code below! Write a program that reverse a string using indirect addressing (may not use the stack - push/pop). The string will be given by the user and be up to 64 characters long INCLUDE Irvine32.inc INCLUDE macros.inc MAX = 64 .data source BYTE MAX DUP('#'),0 destination BYTE LENGTHOF source DUP('*'),0 actual_length DWORD ? ask BYTE "Enter a String: ",0 .code main proc ; ask user for input mov edx, OFFSET ask call WriteString ; read string from keyboard mov edx, OFFSET source ; where to put string from keyboard mov ecx, LENGTHOF source ; max num char to get (dont' over fill) call ReadString ; get string mov actual_length, eax ; how long is the string call WriteString mov esi, OFFSET source mov ecx, SIZEOF source call ShowBuffer exit main ENDP ; show ALL char is a buffer ; does not stop at null ; ecx - must be length of buffer ; esi - must be address (offset) of buffer ShowBuffer PROC mov ebx, 0 call CRLF call CRLF TOP: mov eax, 0 ; zero out all of register mov al, bl ; copy over index value call WriteDec ; print index mwrite<" : "> ; add space mov al, [esi] ; get a single char from buffer call WriteChar ; show char mwrite<" ["> ; add space call WriteDec ; ASCII value mwrite<"] "> ; add space call CRLF ; newline add esi, TYPE BYTE ; update address (where is char) inc bl ; loop TOP call CRLF ret ShowBuffer ENDP END main
...............................................................Please like this answer...............................................................
If you have any deficulty then comment your question.
INCLUDE Irvine32.inc
INCLUDE macros.inc
MAX = 64
.data
Data Segment
str1 db \'String_Reverse\',\'$\'
strlen1 dw $-str1
strrev db 20 dup(\' \')
Data Ends
Code Segment
Assume cs:code, ds:data
Begin:
mov ax, data
mov ds, ax
mov es, ax
mov cx, strlen1
add cx, -2
lea si, str1
lea di, strrev
add si, strlen1
add si, -2
L1:
mov al, [si]
mov [di], al
dec si
inc di
loop L1
mov al, [si]
mov [di], al
inc di
mov dl, \'$\'
mov [di], dl
Print:
mov ah, 09h
lea dx, strrev
int 21h
Exit:
mov ax, 4c00h
int 21h
Code Ends
End Begin
Get Answers For Free
Most questions answered within 1 hours.