Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

can you check if the following code is correct for the following question and can you show me the screen shot of the out put. Thank you so much 

; include the irvine library
INCLUDE Irvine32.inc

;Data section declare all the variables
.data
    source BYTE "This is the source string",0
    target BYTE SIZEOF source DUP('#')

;Code section
.code
 main PROC    
    ;assign value o to esi                    
    mov esi,0    
    ;find the length of the source
    ;subtract with 2 and assign to edi                
     mov edi,LENGTHOF source - 2
    ;find the number of bytes used source
    ;assign to ecx        
     mov ecx,SIZEOF source
    ;iterate a loop        
    L1:        
    ;get the value of source at index esi
    ;and move into register al.                    
    mov al,source[esi]        
    ;move the value of al into target array
    ;at index edi.                                
    mov target[edi],al
    ;increment the value of esi        
     inc esi        
    ;decrement the value of edi.                     
     dec edi                    
     loop L1
    ;get the address value of the target
    ;into edx.
    mov edx, OFFSET target    
    ;print the string        
    call WriteString            
exit
main ENDP
END main

Programming Exercise 2 :-
COPY A STRING IN REVERSE ORDER
Write a program with a loop and indirect addressing that copies a string from source to target, reversing the character order in the process. You MUST use the
exact data block, memory allocation and initialization, as shown in the followings for testing - for showing that your code would not over-write the original
data at the head(4 '$'s) middle(4 '%'s) and tail(4 '^'s):
BYTE 4 DUP('$')
source BYTE "This is the source string",0
BYTE 4 DUP ('%')
SIZEOF
SIZEOF source DUP ('#')
source
target BYTE
BYTE 4 DUP('^')
Hint: Should Not copy the null character, O, at the end of the source string to the front of the target string. And, finish writing the target string by writing the
null character, O, to the last byte - replacing the last '#' there.
In the output of the program, both the source and target(reversed) strings should be shown, by calling the Irvine peripheral procedure(s). Use the following test
code to display the Whole Data Bank:
mov edx, OFFSET source-4
call WriteString
mov edx, OFFSET target-4
call WriteString
mov edx, OFFSET target+SIZEOF target ; display the 4 "^"
call WriteString
; display the 4 "$" and source string
; display the 4 "%" and target string
IMPORTANT: for this exercise, NOT allowable to use any one of these directives: .IF, .ELSE, .ELSEIF, .WHILE, .REPEAT, etc
expand button
Transcribed Image Text:Programming Exercise 2 :- COPY A STRING IN REVERSE ORDER Write a program with a loop and indirect addressing that copies a string from source to target, reversing the character order in the process. You MUST use the exact data block, memory allocation and initialization, as shown in the followings for testing - for showing that your code would not over-write the original data at the head(4 '$'s) middle(4 '%'s) and tail(4 '^'s): BYTE 4 DUP('$') source BYTE "This is the source string",0 BYTE 4 DUP ('%') SIZEOF SIZEOF source DUP ('#') source target BYTE BYTE 4 DUP('^') Hint: Should Not copy the null character, O, at the end of the source string to the front of the target string. And, finish writing the target string by writing the null character, O, to the last byte - replacing the last '#' there. In the output of the program, both the source and target(reversed) strings should be shown, by calling the Irvine peripheral procedure(s). Use the following test code to display the Whole Data Bank: mov edx, OFFSET source-4 call WriteString mov edx, OFFSET target-4 call WriteString mov edx, OFFSET target+SIZEOF target ; display the 4 "^" call WriteString ; display the 4 "$" and source string ; display the 4 "%" and target string IMPORTANT: for this exercise, NOT allowable to use any one of these directives: .IF, .ELSE, .ELSEIF, .WHILE, .REPEAT, etc
Expert Solution
Check Mark
Step 1: Define assembly language

In the Assembly language, to copy a string in reverse order by using any of the assembly language, you will need to use a loop to iterate over the characters in the string and copy them into a new string in reverse order. You will also need to use a couple of registers to keep track of the current index in both the source and destination strings.

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education