Skip to content

Memory orchestration at the different levels of languages

Notifications You must be signed in to change notification settings

z1skgr/Memory-Management-I-O

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

memory structure

Μemory management at programming levels (high-> mid -> low (Assembly))

Table of contents

Labs

1

Memory management and data structures

  • Hexadeced representation.
  • Ordering elements in memory using pointers and arrays.
  • Structs declaration
    • 2 structs with different variable content
  • Dynamic memory allocation
  • Μemory use map






2

Structure management in memory using linked data list operations.

C

Menu for the options

  • Create List
  • Insert Element
    • (id, value)
  • Delete First
  • Print
    • Address/Value element
    • List count
    • List address
    • Address element field
    • List size (bytes)
    • Element size (bytes)



CLang
  • Create List
  • Insert Element
    • (id, value)
  • Delete First
  • Print element value




3

Deepening the understanding of memory function in Clang/understanding of Assembly

C

New operation

  • Print function address
  • Calculate list size to bytes from addresses that occupy items



CLang

Conversion of all the variables used in c Menu for the options using standards (reference registers, etc)

  • Create List
  • Insert Element
    • (id, value)
  • Delete First
  • Print
    • Address/Value element
    • List count
    • List address
    • Address element field
    • List size (bytes)
    • Element size (bytes)



Assembly

Menu options (no functionality)




4

Deepening the understanding of Clang/Assembly

CLang

Modification from previous implementation

  • Create finite list
  • Delete Last
  • Print element with minimum value



Assembly
  • 100 nodes on list (static array)
  • Correctness of assembly contracts (register contracts)
  • Menu functionality (#3)
  • Jal commands for call functions




5

Modification from previous implementation

Assembly
  • Ascending sort using recursive Merge sort 1
    • Stack emerged
  • Convert values from type int -> short





6

I/O Exceptions

Assembly

Management of input/output devices, using the memory display of the units I/O

Polling

Checking peripheral devices if they are ready to accept/export data without syscall (write_ch,read_ch).

Functions
write_ch Reads register Transmission control (TC) / Check device (crosscheck instruction and LSB)
read_ch Waiting for new registration
print_str Candidate for printing char per char



Interrupts
Menu
Choice #1
Choice #2
Exit

Menu options for keyboard using interrupts * cflag, cdata for handler

Choice 1 for 1
Choice 2 for 2
Exit for space.
Message appears





How to run

C/CLang

  1. Instal cygwin compiler for your operation system
https://www.cygwin.com/install.html
  • Create folder Cygwin
  • Open installer
  • Install from internet
  • Select your path folder
  • Select + and install compiler and debugger
  • Find gcc-core, gcc-g++, gdb, make

  1. Configure PATH variable
  • Go to System and Security in Control Panel
  • Advanced System Settings
  • Environmental Variables
  • Add to path variable the path cygwin-directory\bin of your cygwin folder

  1. Install Apache NetBeans (or any other C IDE)
https://netbeans.apache.org/download/index.html
  1. Instal NetBeans plugins
  2. Import .c files to your workspace or Create a new C project
  3. Run your .c source files
  4. To execute clang files, use gcc 5.2_ or below



Assembly

  1. Install PCSpim from website
http://spimsimulator.sourceforge.net/
  1. Install Notepad 2 software (or mipster 3)
  2. Simulator->Settings
    • Mapped I/O
    • Load Exception file
  3. File->Reinitialize->Load File 45 -> Run



For (#6), necessery modifications on file

  • Exception file
lui $k1 0xFFFF
lw  $k0 4($k1)

la $t1, cdata
sw $k0,0($t1)
la $t1, cflag
addi $k0, $zero,1
sw $k0,0($t1)

Acknowledgments

Projects were created for the requirements of the lesson Digital Computers

Footnotes

  1. https://en.wikipedia.org/wiki/Merge_sort#:~:text=In%20computer%20science%2C%20merge%20sort%20%28also%20commonly%20spelled,was%20invented%20by%20John%20von%20Neumann%20in%201945.

  2. MIPS simulator recognizes programs written in text editors

  3. https://mipster.software.informer.com/

  4. Reinitialize and load every time you run the program

  5. Extension .asm to run files on SPIM