View on GitHub

Computer Architecture and Operating Systems

Course taught at Faculty of Computer Science of Higher School of Economics

Programming task “PseudoVM”

NOTE: Need to cover exceptions first to be able to solve this task.

See program PseudoVM.s.

Write an exception handler that imitates “virtual memory” for “forbidden” addresses. A “forbidden” address is any address that causes exceptions LOAD_ACCESS_FAULT and STORE_ACCESS_FAULT when we try to access it (read or write). This is not supported for address 0x0 (it is reserved).

Memory configuration

It is suggested to create a table (array) that will store records "virtual address":value (pairs of 4-byte values). The capacity of the table is 16 records (i.e. 2*4*16=128 bytes). Address 0x0 can be used to specify an empty record.

“Virtual memory” works only with instructions lw and sw that use register t0 as a source/destination for values (other registers are not checked).

Reading from an address works in the following way:

Writing to an address works in the following way:

Notes:

Input:

21
123
22
1234
20
1001
100500
1000
100
-70001
-70001
-70000
-70004
0

Output:

1234
100500
0
0
-70001