Question

In: Computer Science

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

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

Solutions

Expert Solution

.file 1 ""
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.globl ch1
.data
.type ch1, @object
.size ch1, 1
ch1:
.byte 32
.globl ch2
.type ch2, @object
.size ch2, 1
ch2:
.byte 42
b)

.file 1 ""
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.globl x
.section .bss,"aw",@nobits
.align 2
.type x, @object
.size x, 4
x:
.space 4
.globl y
.data
.align 2
.type y, @object
.size y, 4
y:
.word -1
.globl z
.section .bss
.align 2
.type z, @object
.size z, 4
z:
.space 4
(c)

.file 1 ""
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.globl name
.rdata
.align 2
$LC0:
.ascii "marge simpson\000"
.section .data.rel.local,"aw",@progbits
.align 2
.type name, @object
.size name, 4
name:
.word $LC0
(d)

.file 1 ""
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.globl arrayi
.section .bss,"aw",@nobits
.align 2
.type arrayi, @object
.size arrayi, 1000
arrayi:
.space 1000
(e)

.file 1 ""
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.globl arrayi
.section .bss,"aw",@nobits
.align 2
.type arrayi, @object
.size arrayi, 1000
arrayi:
.space 1000


Related Solutions

arms64 assembly language Write a function to read a Sudoku board from an input string. The...
arms64 assembly language Write a function to read a Sudoku board from an input string. The input string must be exactly 81 characters long (plus the terminating null that marks the end of the string) and contains digits and dots (the `.` character represents an unmarked position). The input contains all 9 rows packed together. For example, a Sudoku board that looks like this: ``` ..7 ... ... 6.4 ... ..3 ... .54 ..2 ... .4. ... 9.. ... ..5...
Write a program in MIPS assembly language to convert an ASCII number string containing positive and...
Write a program in MIPS assembly language to convert an ASCII number string containing positive and negative integer decimal strings, to an integer. Your program should expect register $a0 to hold the address of a nullterminated string containing some combination of the digits 0 through 9. Your program should compute the integer value equivalent to this string of digits, then place the number in register $v0. If a non-digit character appears anywhere in the string, your program should stop with...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A palindrome is a word, number, phrase or any other sequence which reads the same backward as forward e.g. madam, racecar. Sample Execution: Please enter a String: redivider The string is a palindrome Another Sample Execution: Please enter a String: abracadabra The string is not a palindrome
In Assembly Language (Visual Studio 2017), create a procedure that generates a random string of Length...
In Assembly Language (Visual Studio 2017), 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 hold the random string. Write a test program that calls your procedure 20 times and displays the strings in the console window. In your program, the random string size shall be preset as a constant. Please include...
reference string 0123342453346256 If we allocate 3 page frames to the program, 1. Please draw a...
reference string 0123342453346256 If we allocate 3 page frames to the program, 1. Please draw a figure to show the LRU page allocation/replacement \. 2. How many page faults will be generated?
ASSEMBLY LANGUAGE x86: Reverse a string using the Run-time stack and a procedures You may want...
ASSEMBLY LANGUAGE x86: Reverse a string using the Run-time stack and a procedures You may want to use your project 4 as a starting point As in the last project we will get a string from the user put it into a buffer called 'source' (ReadString) Copy this string into a buffer called ‘destination’, in reverse order For this project you will use the run-time stack (push & pop) to reverse the string in ‘source’ You must still use indirect...
In C++ language implement an end of the world simulation. Create 3 global variables earthquake =...
In C++ language implement an end of the world simulation. Create 3 global variables earthquake = 30%, hurricane = 35%, volcano = 35% Implement a class named World. Class World inherited Class CRandom In class World create three methods Earthquakes, Hurricanes and Volcanoes. These methods return death toll in numbers and percentage up to their global percentage. This percentage is calculated using CRandom.
HowI can learn assembly language quickly??And how I can instill it’s program ??!
How I can learn assembly language quickly? And how I can instill it’s program ?
The Indexed addressing mode can not be used to specify the destination in MSP430 assembly language...
The Indexed addressing mode can not be used to specify the destination in MSP430 assembly language programs. Select one: True False
Can someone write a method in MIPS assembly language that asks the user for a hexadecimal...
Can someone write a method in MIPS assembly language that asks the user for a hexadecimal value and converts it into a decimal? I will thumbsup if its right
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT