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: 3794426 • 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 ch1 = ' ', 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 # variable declarations follow this line

#name: storage_type value(s)

ch1: .byte ' '

ch2: .byte '$'

x: .word 0

y: .word -1

z: .space 4

name: .ascii "Marge Simpson"

iarray: .word 0:250

carray: .byte 0:250

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