|
Chapter 2 - Implementation
Table of contents :2.1 Instructions Set of the DLX processor
Program example for DLX processor : 000111_00 000_00011 11111111 11110001 // 0: lhi 0 3 -15 --- rg[3]=(-15)(c)<< 16 010111_00 011_00100 00000000 00010000 // 4: srai 3 4 16 --- rg[4]=rg[3]>>16(a)=-15(c) 000100_00 100_00010 00000000 00110111 // 8: lw 4 2 55 --- rg[2]=mem[55+rg[4]]=mem[40]=127=7fh 010000_00 010_00001 00000000 00010111 //12: addi 2 1 23 --- rg[1]=rg[2]+23=150=96h 001001_00 000_00001 00000000 01000000 //16: sh 0 1 64 --- mem[64+0]=rg[1]=98h 001001_00 000_00010 00000000 01000100 //16: sh 0 2 68 --- mem[68+0]=rg[2]=7fh 111110_00 010_00001 00011_000 00000101 //20: mult 2 1 3 --- rg[3],rg[4]=rg[2]*rg[1] 001010_00 000_00011 00000000 01001000 //24: sw 0 3 72 --- mem[72+0]=rg[3]=0h 001010_00 000_00100 00000000 01001100 //28: sw 0 4 76 --- mem[76+0]=rg[4]=4a6ah 111111_00 00000000 00000000 00000000 //32: halt 00000000 00000000 00000000 01111111 //40: 127 After the program loading, memory is: 00011100_00000011_11111111_11110001 01011100_01100100_00000000_00010000 00010000_10000010_00000000_00110111 01000000_01000001_00000000_00010111 00100100_00000001_00000000_01000000 00100100_00000010_00000000_01000100 11111000_01000001_00011000_00000101 00101000_00000011_00000000_01001000 00101000_00000100_00000000_01001100 11111100_00000000_00000000_00000000 00000000_00000000_00000000_01111111 After the program running, memory will be 00011100_00000011_11111111_11110001 01011100_01100100_00000000_00010000 00010000_10000010_00000000_00110111 01000000_01000001_00000000_00010111 00100100_00000001_00000000_01000000 00100100_00000010_00000000_01000100 11111000_01000001_00011000_00000101 00101000_00000011_00000000_01001000 00101000_00000100_00000000_01001100 11111100_00000000_00000000_00000000 00000000_00000000_00000000_01111111 xxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxx xxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxx xxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxx xxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxx xxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxx xxxxxxxx_xxxxxxxx_00000000_10010110 xxxxxxxx_xxxxxxxx_00000000_01111111 00000000_00000000_00000000_00000000 00000000_00000000_01001010_01101010 xxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxx xxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxx xxxxxxxx_xxxxxxxx_xxxxxxxx_xxxxxxxx 2.3 Source code Source code is too big to fit here. If you want to see it click here. (for Netscape users click here.) |