Experiments with eco32-30-port-4

Here are a few suggestions for experiments with the system. They all assume the monitor running from flash ROM. Note that all numbers that you type as input for the monitor are hexadecimal values, without any prefix. Note also that there is a command history buffer, which you can access with CTRL-P (previous) and CTRL-N (next). Finally, you can type 'help' or 'help cmd' (with cmd substituted by any monitor command) to get help.

Experiment 1: Store into memory-mapped display

Since the display is memory-mapped, you can access it with the monitor command 'mw'. The virtual base address is 0xF0100000, line 16 has offset 16*128*4 bytes from that and column 40 has an additional offset of 40*4 bytes from the beginning of the line. So if you type 'mw f01020a0 e440', you will store an '@' (ASCII code 0x40) with attributes 0xE4 (blinking, red foreground on yellow background) into the middle of the display.

Experiment 2: Exchange register contents with XOR

There is an old method how the contents of two registers can be exchanged without using a third register: three XOR instructions will do the trick. Assemble the following tiny program at a suitable location, e.g. 0xC0000000 (i.e., issue the command 'a c0000000'):

c0000000: xor $5,$4,$5
c0000004: xor $4,$4,$5
c0000008: xor $5,$4,$5

You leave the assembler by pressing return again. Now set registers 4 and 5 to values you can easily recognize, e.g. 0x12345678 and 0xAABBCCDD. Set the PC to 0xC0000000, if it happens to have another value. Single-step through the instructions and observe the register contents.

Experiment 3: Output "Hello, world!" on the display

You can use the monitor routines for your own programs. This is especially useful for I/O. Note that you must set-up a valid stackpointer in $29 in order to call monitor routines. The following program outputs a null-terminated string stored at 0xC0000200 on the display, which has an associated output routine located at 0xE0000018:

c0000000: ldhi $29,c0000000
c0000004: or $29,$29,1000
c0000008: ldhi $17,e0000000
c000000c: or $17,$17,18
c0000010: ldhi $16,c0000000
c0000014: or $16,$16,200
c0000018: ldbu $4,$16,0
c000001c: beq $4,$0,c000002c
c0000020: jalr $17
c0000024: add $16,$16,1
c0000028: j c0000018
c000002c: j c000002c

Store some null-terminated string at 0xC0000200, e.g.:

mw c0000200 48656c6c
mw c0000204 6f2c2077
mw c0000208 6f726c64
mw c000020c 210d0a00

Set a breakpoint at 0xC000002C and set the PC to 0xC0000000, then start the program with the 'c' (continue) command.

One last note: Normally you can directly call (jump-and-link, 'jal') a routine, but here the address distance to the ROM is too large to fit into the allocated bits within an instruction word. So the output routine must be called with a jump-and-link-register ('jalr') instruction.

Experiment 4: Create an address mapping with the TLB

The monitor runs in kernel mode und uses direct-mapped virtual addresses (starting at 0xC0000000 and extending up to the full 4 GB address space limit), which are translated to physical addresses by setting the topmost two bits to zero. If you try to access any address in page-mapped address space (e.g., by typing 'd 0'), you will notice an error message from the monitor, as this triggers a TLB miss exception (no address mapping found by the MMU for the page the address is contained in, i.e., page 0 in this case). But you can easily create such an address mapping. Assume that you want to show up frame 0 when accessing page 0. Then you have to enter the pair (page = 0, frame = 0) into the TLB. The mapping pair can be entered into an arbitrary slot of the 32 slots available within the TLB, since the TLB acts as an associative memory. So you can, e.g., use slot 6:

t 6 p 00000000
t 6 f 00000003

The last two bits in the frame number are the writeable and valid bits. If you now do a 'd 0' you will see frame 0, with exactly the contents you get when looking at its direct-mapped address 'd c0000000'.

You can of course set up aliases. Say, that you want to see the very same frame under the address 0x20007000. Again, the slot you choose is irrelevant, so it could, e.g., be 15:

t 15 p 20007000
t 15 f 00000003

If you now do a 'd 20007000', you will see again frame 0.