Question

In assembly masm use the code below! Write a program that reverse a string using indirect...

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

Homework Answers

Answer #1

...............................................................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
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
6. (True/False): The RET instruction pops the top of the stack into the instruction pointer. 8....
6. (True/False): The RET instruction pops the top of the stack into the instruction pointer. 8. (True/False): In protected mode, each procedure call uses a minimum of 4 bytes of stack space. 1. Which instruction pushes all of the 32-bit general-purpose registers on the stack? 20. What values will be written to the array when the following code executes? .data array DWORD 4 DUP(0) .code main PROC mov eax,10 mov esi,0 call proc_1 add esi,4 add eax,10 mov array[esi],eax INVOKE...
A) Is the code below secure? Explain your rationale. ExitProcess PROTO .data firstval qword 20002000h secondval...
A) Is the code below secure? Explain your rationale. ExitProcess PROTO .data firstval qword 20002000h secondval qword 11111111h thirdval qword 22222222h sum qword 0 .code main proc      mov rax,firstval                         add rax,secondval             add    rax,thirdval      mov    sum,rax      mov    ecx,0      invoke ExitProcess main endp end main b) Transmitted messages often include a parity bit, whose value is combined with a data byte to produce an even number of 1 bits. Suppose a message byte in the AL...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a...
Please complete in MASM (x86 assembly language). Use the code below to get started. Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n – 1) + Fib(n – 2). .386 .model flat,stdcall .stack 4096 ExitProcess PROTO,dwExitCode:DWORD .data    ; define your variables here .code main PROC    ; write your assembly code here    INVOKE ExitProcess,0 main...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following...
Section 2: Using the MARS or SPIM simulator develop a program that will implement the following conditional statement. If ( n is even) { n = n / 2; } else { n = 3 * n + 1; } In this case, n is to be input by the user (assume they input a non-negative value), the conditional is performed, and the resulting n is to be output. Again, use the system calls for input, output, and exiting the...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question.. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. 6.) Random Strings Create a procedure that generates a random string of length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will...
Strings The example program below, with a few notes following, shows how strings work in C++....
Strings The example program below, with a few notes following, shows how strings work in C++. Example 1: #include <iostream> using namespace std; int main() { string s="eggplant"; string t="okra"; cout<<s[2]<<endl; cout<< s.length()<<endl; ​//prints 8 cout<<s.substr(1,4)<<endl; ​//prints ggpl...kind of like a slice, but the second num is the length of the piece cout<<s+t<<endl; //concatenates: prints eggplantokra cout<<s+"a"<<endl; cout<<s.append("a")<<endl; ​//prints eggplanta: see Note 1 below //cout<<s.append(t[1])<<endl; ​//an error; see Note 1 cout<<s.append(t.substr(1,1))<<endl; ​//prints eggplantak; see Note 1 cout<<s.find("gg")<<endl; if (s.find("gg")!=-1) cout<<"found...
Note: Do not use classes or any variables of type string to complete this assignment Write...
Note: Do not use classes or any variables of type string to complete this assignment Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT