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...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in...
Write a sequence of two instructions that copies bits 0-5 from AL to bits 0-5 in BL. Bits 6-7 in BL should be cleared, and AL should be unchanged             Mov al, bl       And 00111111, bl       Write a sequence of two instructions that copies the integer in bits 4-7 from AL register into bits 0-3 of the BL register. Upper 4 bits of AL and BL will be cleared             Shr al, 4       Mov bl,...
Write an assembly procedure Find to return the index of the first occurrence of a character...
Write an assembly procedure Find to return the index of the first occurrence of a character ch in a string str. If ch is not found in str the return value should be -1. Input parameters: None. Preconditions: The base address of str is stored in ecx. str is ‘\0’ terminated. ch is strored in bl. Return value: The return value should be stored in eax. Run and test your procedure using the following driver program: .386 .model flat, stdcall...
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...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the Irvine library for the print function #include <iostream> // The string that needs to be printed char word[] = "Golf\0"; // Pointer to a specific character in the string char * character = word; //NOTE: This main() function is not portable outside of Visual Studio void main() { // Set up a LOOP - See the while loop's conditional expression below int ecx =...
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...
program has to be written in X86 processor assy language. Write a program that find the...
program has to be written in X86 processor assy language. Write a program that find the minimum number of coins that can represent an amount of money under $1. The amount of money is a random number between 0 and 99 (cents). The randomRange procedure is used to get a random number. Review the sample code in lab4.asm and run it to see how randomRange works. Each time randomRange is called, it creates a random number between 0 and the...
Objectives: ⦁   Declare and initialize null-terminated string ⦁   Apply indirect address ⦁   Write loop ⦁   Apply...
Objectives: ⦁   Declare and initialize null-terminated string ⦁   Apply indirect address ⦁   Write loop ⦁   Apply Irvine.inc library functions to display a string Problem Description: Write a program with a loop and indirect address that copies a string from source to target. Revising the character order in the process. Use the following variables: source BYTE “This is the string that will be reversed”, 0 target BYTE SIZEOF source DUP(‘#’) You may refer to the Programming Exercise #7 on Page 138...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT