Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We can allocate string literals and global variables in the .data section of an

ID: 3793799 • Letter: W

Question

We can allocate string literals and global variables in the .data section of an assembly language program. Write MARS directives which would allocate the following C-like variables in the .data section, char chi = ' ch2 = $//Assume char variables/values are 1-byte int x = 0, y = -1, z;//Assume int variables/values are 4-bytes char *name = "Marge Simpson";//name is a label assoc'd with the address of the first char int iarray[250] = {0};//iarray is an array of 250 ints, all initialized to 0 char carray[250] = {0};//carray is an array of 250 chars, all initialized to 0

Explanation / Answer


Data declaration and initiallized .data segment in the assembly program
The following are declareation of varibales and literals using MARS directives

.data
ch1: .byte 32          # Allocates 1 byte initialized to space, ' ' since 32 is ascii of space
ch2: .byte 36          # Allocates 1 byte initialized to space, '$' since 36 is ascii of dollar
name : .string "Marge Simpson" # Declare 13 bytes starting at the address str initialized to
           the ASCII character values for hello followed by a nul (0) byte.

x: .long 0          # Allocates 1 byte initialized to 0
y: .long -1         # Allocates 1 byte initialized to -1
z: .long            # Allocates 1 byte

array1: .byte 0 : 250 # Allocates 250 bytes, all initiailizedd to 0
carray: .byte 0 : 250 # Allocates 250 bytes, all initiailizedd to 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote