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...
An assembler translates assembly language to machine language instructions. A disassembler can be used to translate...
An assembler translates assembly language to machine language instructions. A disassembler can be used to translate the other way, from machine language to assembly language. For example, our 8086 emulator shows both the machine language bytes and the disassembler output while running a program (it also shows the original assembly code). The disassembled code is usually harder to read than the original assembly language program because some things are missing or may be incorrect. Write down one of the things...
Write an assembly language program to input a string from the user. Your program should do...
Write an assembly language program to input a string from the user. Your program should do these two things: ***** I AM POSTING THIS QUESTION FOR THE THIRD TIME NOW,I WANT IT DONE USING INCLUDE IRVINE32.INC***** 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   "Hello thEre. How aRe yOu?" Your output should be:...
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?
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.
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...
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 ?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT