What sequence of regular instructions could be used to do the same thing?

Question

What sequence of regular instructions could be used to do the same thing? That is, how could we store a specific number, say 133, into a specific memory location, say memory cell 13?

Summary

By performing a series of commands, a specified number can be saved in a given spot.
An assembler will automatically translate some statements written in high language to assembly language.
However, in ARM 32-bit assembly language, there is a unique instruction called str that allows you to store a value at a specific address.

Explanation

We first reserve a specific address for a variable in RAM using the stdio.h header file.
The variable will then be given a value, and the number will be put at the address that has been set aside for that variable.
The following is a list of code statements:

#include <stdio.h>

#include <stdlib.h>

int ramloc @ 0x13;

int main(int arg, char** argv)

{

ramloc = 0x133;

for(int i=0;i<1000;i++)

for(int j=0;j<10000;j++);

return (EXIT_SUCCESS)

}

The hex location 0x13 is reserved for the variable ramloc in the given code.
The variable is then given the value of 0x133.
As a result, the value 0x133 was saved at location 0x13.
In assembly language, some instructions can be written to accomplish the same thing.
A store instruction is used to store a value in a specified address.
In hex, 133 equals 0x85 Mov var, 0x85 Str var, [0xD]
The mov instruction in this case assigns the hexadecimal value 0x85 to the variable var.

The contents of this variable will then be saved at address 0xD, which is nothing more than memory cell 13.

sequence of regular instructions

 

Also, read check the python code below that doesn’t work properly, adjust it, and explain?

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *