I am new to assembly language and I'm using a simpler version called Y86, essentially the same thing. I wonder how to initialize a multidimensional array in such a format, specifically making a 2x2. Later with the 2x2 I will be adding two matrices (or arrays in this case). Thank you!
Multidimensional Array (2x2) Initialization in Assembly Language - Y86
1.5k Views Asked by Alowishious At
1
There are 1 best solutions below
Related Questions in ARRAYS
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- What does: "char *argv[]" mean?
- How to populate two dimensional array
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- Function is returning undefined but should be returning a matched object from array in JavaScript
- The rules of Conway's Game of Life aren't working in my Javascript version. What am I doing wrong?
- Array related question, cant find the pattern
- Setting the counter (j) for (inner for loop)
- I want to flip an image (with three channels RGB) horizontally just using array slicing. How can I do it with python?
- Numpy array methods are faster than numpy functions?
- How to enter data in mongodb array at specific position such that if there is only 2 data in array and I want to insert at 5, then rest data is null
- How to return array to ArrayPool when it was rented by inner function?
- best way to remove a word from an array in a react app
- Vue display output of two dimensional array
- Undot Array with Wildcards in Laravel
Related Questions in ASSEMBLY
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- How to call a C language function from x86 assembly code?
- Binary Bomb Phase 2 - Decoding Assembly
- AVR Assembly Clock Cycle
- Understanding the differences between mov and lea instructions in x86 assembly
- ARM Assembly code is not executing in Vitis IDE
- Which version of ARM does the M1 chip run on?
- Why would %rbp not be equal to the value of %rsp, which is 0x28?
- Move immediate 8-bit value into RSI, RDI, RSP or RBP
- Unable to run get .exe file from assembly NASM
- DOSbox automatically freezes and crashes without any prompt warnings
- Load function written in amd64 assembly into memory and call it
- link.exe unresolved external symbol _mainCRTStartup
- x86 Wrote a boot loader that prints a message to the screen but the characters are completely different to what I expected
- running an imf file using dosbox in parallel to a game
Related Questions in Y86
- Y86 bubble sort program not sorting properly
- Getting and setting an address pointer from memory in Y86-64 assembly
- Y86 program stops midway through throwing exception "Invalid instruction f4"
- Simulate y86 program as per Computer Systems: A Programmer's Perspective 3e Student Site
- y86 instructions set create confusion
- Why is the wrong parameter being passed here?
- Y86 Architecture Immediate VS Register Arithmetic Efficiency Question
- How to write a for loop in y86
- Implementing Y86 Fetch Instruction in C
- Convert C function to Y86 function
- Why is this Y86-64 code segment failing to execute the expected jg branch?
- Why is writing considered an input operation and reading considered an output operation?
- Why the rA:rB is 2:8 instead of 2:f in the execution of a pushl instruction?
- CSAPP confuse with pushtest result Practice Problem 4.7
- How to perform right shift in Y86-64 (or other toy ISAs with ADD + AND but no native right shift)
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
In machine code you have available (for information storage) CPU registers and memory.
Registers have fixed names and types and they are used like that, for example in x86 you can do
mov eax, 0x12345678to load 32b value into registereax.Memory is like continuous block of byte-cells, each having it's own unique physical address (like: 0, 1, 2, ... mem_size-1). So it is like 1 dimensional byte array.
Whatever different type you want, in the end it is somehow mapped to this 1D byte array, so you have to first design how that mapping happens.
Some mappings like for example 32 bit integers have native mappings/support in the instructions, so you can for example read whole 32b int by single instruction like
mov eax,[address], not having to compose it from individual bytes, but the CPU will for you read four bytes from memory at addresses:address+0,address+1,address+2andaddress+3and concatenate it into 32 bit value (on x86 CPU in little-endian order, so the byte fromaddress+0is in the lowest 8 bits of final value).Other mappings like "array 2x2" don't have native support, and you have to design the memory layout and write the code accordingly to support it. For 2 dimensional arrays often mapping
memory_offset = (row * columns_max + column) * single_element_byte_sizeis used.Like for 16x16 matrix of 32 bit floats you can calculate memory offset (from the start of matrix data, which is at offset 0):
But you are of course free to devise and implement any kind of mapping you wish...
edit: as Peter Cordes notes, some mappings favour certain task, like for example continuously designed matrices like the one above, in the task of adding two matrices, can be dealt with in the implementation as one dimensional 256 (16x16) element array, because there's no significance of row/columns in the matrix addition, so you can just add corresponding elements of both. In multiplication you have to traverse the elements in more complex patterns, where row/columns are important, so there you have to write more complex code to respect the 2D mapping logic.
edit 2, to actually add answer to your question:
Eee... this doesn't make sense from machine point of view. You simply need somewhere in memory reserved space, which represents data of the array, and you may want to set those to certain initial values, by simply writing those values into memory (by ordinary memory store instructions, like
mov [ebx],eax), or for example in simple code adding two matrices of fixed values, you can define both of them directly in.datasegment with some directive defining values, like for example in NASM assembler (for the simple mapping as described above):(check your assembler documentation to see which directives are available to reserve+initialize part of memory)
Which kind of memory area you want to reserve for the data (the load-time initialized
.data, or stack, or dynamically allocated from OS "heap", ...), and how you load it with initial data, is up to you, but in no way related to the "two dimensional array", usually the allocation/initialization code often works with all the types as "continuous block of bytes", without caring about the inner structure of the data, that's left for the other functions, which are dealing with particular elements of the data.