diff --git a/lab1/csrc/CMakeLists.txt b/lab1/csrc/CMakeLists.txt index a1c1c7c..ee07b00 100644 --- a/lab1/csrc/CMakeLists.txt +++ b/lab1/csrc/CMakeLists.txt @@ -5,7 +5,7 @@ project(yatcpu-programs C CXX ASM) # Setting variables set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 --target=riscv32-unknown-elf -march=rv32i -mabi=ilp32") set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O0 --target=riscv32-unknown-elf -march=rv32i -mabi=ilp32") -set(C_PROGRAMS tetris hello fibonacci quicksort) +set(C_PROGRAMS tetris hello fibonacci quicksort paging tetris_mmu) set(ASM_PROGRAMS mmio sb) set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/link.lds) set(LINKER_FLAGS -T ${LINKER_SCRIPT}) @@ -32,8 +32,8 @@ foreach(program IN LISTS ASM_PROGRAMS) set_target_properties(${program} PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT}) endforeach() -# Copy the .text section to .asmbin files -foreach(program IN LISTS C_PROGRAMS ASM_PROGRAMS) +# Copy the .text and .data section to .asmbin files +foreach(program IN LISTS C_PROGRAMS ASM_PROGRAMS PROGRAMS) add_custom_command( TARGET ${program} POST_BUILD diff --git a/lab1/csrc/hdmi_test.c b/lab1/csrc/hdmi_test.c deleted file mode 100644 index e439af3..0000000 --- a/lab1/csrc/hdmi_test.c +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2022 hrpccs -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - -#include "mmio.h" - - - -int main(){ - int *vram = ((int *) VRAM_BASE); - for (int i = 0; i < 600; ++i) vram[i] = 0x20202020; - - for(int i = 0;i < 12;i++){ - VRAM[i] = "hello world!"[i]; - } - - while(1); -} \ No newline at end of file diff --git a/lab1/csrc/init.S b/lab1/csrc/init.S index 4534c78..1d4dbce 100644 --- a/lab1/csrc/init.S +++ b/lab1/csrc/init.S @@ -15,7 +15,7 @@ .section .text.init .globl _start _start: - li sp, 4096 # Initialize stack pointer + li sp, 0x10000000 # Initialize stack pointer call main # Jump to main function loop: j loop # Loop forever @@ -26,6 +26,16 @@ enable_interrupt: li t0, 0x1888 csrrw t1, mstatus, t0 # enable interrupt ret +.globl enable_paging +enable_paging: + li t0, 0x80000005 # ppn << 12 = 0x005000 + csrw satp, t0 + ret +.globl get_mtval +get_mtval: + csrr a0, mtval + ret + .globl get_epc get_epc: csrr a0, mepc diff --git a/lab1/csrc/link.lds b/lab1/csrc/link.lds index b5d8366..a166fc7 100644 --- a/lab1/csrc/link.lds +++ b/lab1/csrc/link.lds @@ -6,6 +6,7 @@ SECTIONS . = 0x00001000; .text : { *(.text.init) *(.text.startup) *(.text) } .data ALIGN(0x1000) : { *(.data*) *(.rodata*) *(.sdata*) } + . = 0x00100000; .bss : { *(.bss) } _end = .; } diff --git a/lab1/csrc/mm.h b/lab1/csrc/mm.h new file mode 100644 index 0000000..5d4c89a --- /dev/null +++ b/lab1/csrc/mm.h @@ -0,0 +1,43 @@ +// Copyright 2022 hrpccs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +typedef unsigned int uint32; +typedef uint32 pte_t; +typedef uint32* pagetable_t; + +#define PGSIZE 4096 // bytes per page +#define PGSHIFT 12 // bits of offset within a page + +#define PGROUNDUP(sz) (((sz)+PGSIZE-1) & ~(PGSIZE-1)) +#define PGROUNDDOWN(a) (((a)) & ~(PGSIZE-1)) + +#define PTE_V (1L << 0) // valid +#define PTE_R (1L << 1) +#define PTE_W (1L << 2) +#define PTE_X (1L << 3) +#define PTE_U (1L << 4) // 1 -> user can access + +// shift a physical address to the right place for a PTE. +#define PA2PTE(pa) ((((uint32)pa) >> 12) << 10) + +#define PTE2PA(pte) (((pte) >> 10) << 12) + +#define PTE_FLAGS(pte) ((pte) & 0x3FF) + +// extract the two 10-bit page table indices from a virtual address. +#define PXMASK 0x3FF // 10 bits +#define PXSHIFT(level) (PGSHIFT+(10*(level))) +#define PX(level, va) ((((uint32) (va)) >> PXSHIFT(level)) & PXMASK) + +#define MAXVA (1L << (10 + 10 + 12)) diff --git a/lab1/csrc/mmio.h b/lab1/csrc/mmio.h index b1222dd..fb0fa5f 100644 --- a/lab1/csrc/mmio.h +++ b/lab1/csrc/mmio.h @@ -21,3 +21,13 @@ #define UART_BAUDRATE ((volatile unsigned int *) (UART_BASE + 4)) #define UART_RECV ((volatile unsigned int *) (UART_BASE + 12)) #define UART_SEND ((volatile unsigned int *) (UART_BASE + 16)) +//remap the mmio to reduce memory usage of page table +#define VA_VRAM_BASE 0x00100000 +#define VA_VRAM ((volatile unsigned char *) VA_VRAM_BASE) +#define VA_TIMER_BASE 0x00200000 +#define VA_TIMER_LIMIT ((volatile unsigned int *) (VA_TIMER_BASE + 4)) +#define VA_TIMER_ENABLED ((volatile unsigned int *) (VA_TIMER_BASE + 8)) +#define VA_UART_BASE 0x00300000 +#define VA_UART_BAUDRATE ((volatile unsigned int *) (VA_UART_BASE + 4)) +#define VA_UART_RECV ((volatile unsigned int *) (VA_UART_BASE + 12)) +#define VA_UART_SEND ((volatile unsigned int *) (VA_UART_BASE + 16)) \ No newline at end of file diff --git a/lab1/csrc/paging.c b/lab1/csrc/paging.c new file mode 100644 index 0000000..d8d59d5 --- /dev/null +++ b/lab1/csrc/paging.c @@ -0,0 +1,191 @@ +// # Copyright 2022 hrpccs +// # +// # Licensed under the Apache License, Version 2.0 (the "License"); +// # you may not use this file except in compliance with the License. +// # You may obtain a copy of the License at +// # +// # http://www.apache.org/licenses/LICENSE-2.0 +// # +// # Unless required by applicable law or agreed to in writing, software +// # distributed under the License is distributed on an "AS IS" BASIS, +// # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// # See the License for the specific language governing permissions and +// # limitations under the License. + +#include "mm.h" +#include "mmio.h" + + + +#define SCREEN_COLS 80 +#define SCREEN_ROWS 30 +#define INT_TIMER_LIMIT 50000000 +#define PAGEDIR_BASE 0x5000 + +typedef unsigned int uint32; +typedef uint32 pte_t; +typedef uint32* pagetable_t; + +extern void enable_paging(); +extern void enable_interrupt(); +extern int get_mtval(); + +int wk_mul(int a, int b) { + int r = 0; + for (; b; a <<= 1, b >>= 1) + if (b & 1) + r += a; + return r; +} + +void memoryset(unsigned char *dest,unsigned char num, unsigned int size){ + for(unsigned int i=0;i=0){ + int* taddr = (int*)(t<<12); + for(int i=0;i>2;i++){ + taddr[i]=0; + } + pgtbl[PX(1,va)] = PA2PTE(t<<12) | PTE_V; + }else{ + while(1); + for(int i=0;i<14;i++){ + putch_at(i,22,"out of memory!"[i]); + } + while(1); + } + } + pagetable_t n = (void*)PTE2PA(pgtbl[PX(1,va)]); + n[PX(0,va)] = PA2PTE(pa) | perm | PTE_V; +} + + +void kvminit(){ + pagetable_t pgtbl = (void*)PAGEDIR_BASE; + // memoryset(pgtbl,0,PGSIZE); //后面需要读这个内存,所以先初始化 + for(int i=0;i>2;i++){ + pgtbl[i]=0; + } + + pm[PAGEDIR_BASE >> 12] = 1; + pm[0]=1; + pm[1]=1; + pm[2]=1; + pm[3]=1; + pm[4]=1; + //create pte mmap for text + pgtbl[1023] = PA2PTE(PAGEDIR_BASE) | PTE_R | PTE_W; + map(pgtbl,PAGEDIR_BASE,PAGEDIR_BASE,PTE_R | PTE_W); + map(pgtbl,0x0,0x0, PTE_W | PTE_R ); //kernel stack + map(pgtbl,0x1000,0x1000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x2000,0x2000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x3000,0x3000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x4000,0x4000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,VA_VRAM_BASE,VRAM_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_VRAM_BASE + PGSIZE,VRAM_BASE + PGSIZE, PTE_W | PTE_R); + map(pgtbl,VA_UART_BASE,UART_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_TIMER_BASE,TIMER_BASE, PTE_W | PTE_R ); // +} + +void clear_screen() { + int *vram = ((int *) VRAM_BASE); + for (int i = 0; i < 600; ++i) vram[i] = 0x20202020; +} + +void trap_handler(void *epc, unsigned int cause) { + if (cause == 10 || cause == 15 || cause == 13) { + for(int i=0;i<39;i++){ + putch_at(i,4,"A not handled page fault caused by : 0x"[i]); + } + int mtval = get_mtval(); + char ch; + for (int i = 0; i < 8; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (mtval & mask) >> (i * 4); + if(num >= 10){ + ch = num - 10 + 'A'; + }else{ + ch = num + '0'; + } + putch_at(39+7-i,4,ch); + } + while(1); //目前还没有处理page-fault,因为还没有建立完整的映射。 + } else if(cause == 0x80000007){ + for(int i=0;i<16;i++){ + putch_at(i,3,"timer count : 0x"[i]); + } + char ch; + for (int i = 0; i < 8; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (timercount & mask) >> (i * 4); + if(num >= 10){ + ch = num - 10 + 'A'; + }else{ + ch = num + '0'; + } + putch_at(16+7-i,3,ch); + } + timercount += 1; + + } +} + +int main(){ + putch_at = __putch_at; + for(int i=0;i<8;i++){ + pm[i] = 0; + } + timercount = 0; + clear_screen(); + for(int i=0;i<19;i++){ + putch_at(i,0,"print before paging"[i]); + } + kvminit(); + putch_at = __vputch_at; + enable_paging(); + for(int i=0;i<18;i++){ + putch_at(i,1,"print after paging"[i]); + } + enable_interrupt(); + *VA_TIMER_ENABLED = 1; + *VA_TIMER_LIMIT = INT_TIMER_LIMIT; + + while(1){ + if(timercount == 0x20){ + *(int*)0x11415 = 1130; + } + } + for(;;); +} \ No newline at end of file diff --git a/lab1/csrc/say_goodbye.c b/lab1/csrc/say_goodbye.c new file mode 100644 index 0000000..566e7e2 --- /dev/null +++ b/lab1/csrc/say_goodbye.c @@ -0,0 +1,44 @@ + +void uart_send_char(char c) +{ + *((volatile unsigned int *) (0x40000010)) = c; + // *((volatile unsigned int *) (0x40000000)) = c; +} + + +void waste_some_time(int cycle) { + unsigned int a = 135; + while (cycle--) { + a++; + } +} + +int main() { + + // const char* s = "abcd"; + const char* s = "Never gonna give you up~ Never gonna let you down~\n\ + Never gonna run around and~ desert you~\n"; + + while (1) { + + + // for (int i = 0; i < ; i++) { + // uart_send_char(s[i]); + // waste_some_time(100); + // } + + const char *p = s; + while (*p != 0) + { + uart_send_char(*p); + p++; + waste_some_time(100); + } + + waste_some_time(200); + + break; // print once, but pressing CPU reset can print again + } + + return 0; +} diff --git a/lab1/csrc/tetris.c b/lab1/csrc/tetris.c index 2b37550..6ce1f3a 100644 --- a/lab1/csrc/tetris.c +++ b/lab1/csrc/tetris.c @@ -395,7 +395,7 @@ void on_timer() { void trap_handler(void *epc, unsigned int cause) { if (cause == 0x80000007) { on_timer(); - } else { + } else if (cause == 0x8000000B){ unsigned int ch = *UART_RECV; *UART_SEND = ch; on_input(ch); diff --git a/lab1/csrc/tetris_mmu.c b/lab1/csrc/tetris_mmu.c new file mode 100644 index 0000000..b9ce7a4 --- /dev/null +++ b/lab1/csrc/tetris_mmu.c @@ -0,0 +1,568 @@ +// Copyright 2021 Howard Lau +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifdef DEBUG +#include +#endif + +#include "mmio.h" +#include "mm.h" + +#define FALL_TIMER_LIMIT 50000000 +#define ROWS 22 +#define COLS 10 +#define OFFSET_X 28 +#define OFFSET_Y 3 +#define SCREEN_COLS 80 +#define SCREEN_ROWS 30 + + +struct block { + unsigned int shape[3]; + unsigned int xywh; +}; + +struct block current; + +unsigned int score; + +unsigned char *board; + + + +int pm[8]; //板子上有32kb内存,八个页 +int timercount=0; +// void (*putch_at)(int,int,unsigned char); +#define PAGEDIR_BASE 0x5000 + +#ifdef DEBUG +unsigned char screen[SCREEN_COLS * SCREEN_ROWS]; +#endif + +int wk_mul(int a, int b) { + int r = 0; + for (; b; a <<= 1, b >>= 1) + if (b & 1) + r += a; + return r; +} + +unsigned int make_xywh(unsigned int x, unsigned int y, unsigned int w, unsigned int h) { + return (x << 12) | (y << 4) | (w << 2) | h; +} + +void init_block(struct block *block, int type, int x, int y) { + int w = 0; int h = 0; + block->shape[0] = block->shape[1] = block->shape[2] = 0; + switch(type) { + case 0: // I + block->shape[0] = 0xF; + w = 3; h = 0; + break; + case 1: // O + block->shape[0] = 0x3; + block->shape[1] = 0x3; + w = 1; h = 1; + break; + case 2: // J + block->shape[0] = 0x4; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 3: // T + block->shape[0] = 0x2; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 4: // L + block->shape[0] = 0x1; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 5: // Z + block->shape[0] = 0x6; + block->shape[1] = 0x3; + w = 2; h = 1; + break; + case 6: // S + block->shape[0] = 0x3; + block->shape[1] = 0x6; + w = 2; h = 1; + break; + } + block->xywh = make_xywh(x, y, w, h); +} + +unsigned int get_shape(struct block *block, unsigned int r, unsigned int c) { + return (block->shape[r] & (1 << c)) >> c; +} + +unsigned int check_bounds(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + if (x < 0 || x + w >= COLS) return 0; + if (y < 0 || y + h >= ROWS) return 0; + return 1; +} + +void copy_block(struct block *dst, struct block *src) { + dst->xywh = src->xywh; + dst->shape[0] = src->shape[0]; + dst->shape[1] = src->shape[1]; + dst->shape[2] = src->shape[2]; +} + +unsigned int check_collision(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(block, r, c) && + board[wk_mul(y + r, COLS) + x + c]) + return 0; + } + } + return 1; +} + +void putch_at(int x, int y, unsigned char ch) { +#ifdef DEBUG + screen[wk_mul(OFFSET_Y + y, SCREEN_COLS) + x + OFFSET_X] = ch; +#else + VA_VRAM[wk_mul(OFFSET_Y + y, SCREEN_COLS) + x + OFFSET_X] = ch; +#endif +} + + +void block_move(struct block *block, int dir) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + switch(dir) { + case 0: // Left + x--; + break; + case 1: // Right + x++; + break; + case 2: // Down + y++; + break; + default: + break; + } + block->xywh = (x << 12) | (y << 4) | (w << 2) | h; +} + +unsigned int move(struct block *block, int dir) { + struct block moved; + copy_block(&moved, block); + block_move(&moved, dir); + if (check_bounds(&moved) && check_collision(&moved)) { + copy_block(block, &moved); + return 1; + } + return 0; +} + +void block_rotate(struct block *block, unsigned int clock) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + unsigned int xyhw = make_xywh(x, y, h, w); + unsigned int shape[3] = {0, 0, 0}; + if (clock) { + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + shape[c] = shape[c] | (get_shape(block, r, c) << (h - r)); + } + } + + } else { + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + shape[w - c] = shape[w - c] | (get_shape(block, r, c) << r); + } + } + } + block->shape[0] = shape[0]; + block->shape[1] = shape[1]; + block->shape[2] = shape[2]; + block->xywh = xyhw; +} + + +void rotate(struct block *block, int clock) { + struct block rotated; + copy_block(&rotated, block); + block_rotate(&rotated, clock); + if (check_bounds(&rotated) && check_collision(&rotated)) { + copy_block(block, &rotated); + return; + } + unsigned int xywh = rotated.xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; + if (x + w >= COLS) { + x = COLS - w - 1; + } + rotated.xywh = make_xywh(x, y, w, h); + if (check_bounds(&rotated) && check_collision(&rotated)) { + copy_block(block, &rotated); + } +} + +void clear_board() { + for (int i = 0, s = wk_mul(ROWS, COLS); i < s; ++i) { + board[i] = 0; + } +} + +void fix_block(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; +#ifdef DEBUG + printf("%d %d %d %d\n", x, y, w, h); +#endif + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(block, r, c)) { + board[wk_mul(y + r, COLS) + x + c] = 1; + } + } + } +} + +void print_score() { + int c = 8; + putch_at(c++, -2, 'S'); + putch_at(c++, -2, 'C'); + putch_at(c++, -2, 'O'); + putch_at(c++, -2, 'R'); + putch_at(c++, -2, 'E'); + for (int i = 0; i < 5; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (score & mask) >> (i * 4); + putch_at(12 - i, -1, num + '0'); + } +} + +void draw_board() { + for (int r = 0; r < ROWS; ++r) { + for (int c = 0; c < COLS; ++c) { + if (board[wk_mul(r , COLS) + c] == 1) { + putch_at((c << 1) + 1, r, '['); + putch_at((c << 1) + 2, r, ']'); + } else { + putch_at((c << 1) + 1, r, ' '); + putch_at((c << 1)+ 2, r, ' '); + } + } + } + unsigned int xywh = current.xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(¤t, r, c)) { + putch_at(((c + x) << 1) + 1, r + y, '['); + putch_at(((c + x) << 1) + 2, r + y, ']'); + } + } + } + print_score(); +} + + +void add_score(unsigned int delta) { + score += delta; + for (unsigned int i = 0, carry = 0; i < 32; i += 4) { + unsigned int mask = 0xF << i; + unsigned int num = (score & mask) >> i; + num += carry; + if (num >= 10) { + carry = 1; + num -= 10; + } else { + carry = 0; + } + score &= ~(mask); + score |= (num << i); + } +} + +void check_clear() { + unsigned int y = (current.xywh & 0xff0) >> 4; + unsigned int h = current.xywh & 0x3; + for (int r = y + h; r >= y; --r) { + unsigned int count = 0; + for (int c = 0; c < COLS; ++c) { + if (board[wk_mul(r , COLS) + c]) ++count; + } + if (count == COLS) { + add_score(1); + for (int nr = r - 1; nr > 0; --nr) { + for (int c = 0; c < COLS; ++c) { + board[wk_mul(nr + 1, COLS) + c] = board[wk_mul(nr, COLS) + c]; + } + } + ++r; ++y; + } + } +} + +unsigned int rand() { + static unsigned int seed = 990315; + seed = (wk_mul(1103515245 , seed) + 12345) & 0x7FFFFFFF; + return seed; +} + +unsigned int rand_type() { + unsigned int type = rand() & 0x7; + while (type == 7) { + type = rand() & 0x7; + } + return type; +} + +void fall() { + if (move(¤t, 2) == 0) { + fix_block(¤t); + check_clear(); + init_block(¤t, rand_type(), 4, 0); + } +} + +#ifdef DEBUG +void print_screen() { + for (int r = 0; r < SCREEN_ROWS; ++r) { + for (int c = 0; c < SCREEN_COLS; ++c) { + printf("%c", screen[wk_mul(r, SCREEN_COLS) + c]); + } + printf("\n"); + } + printf("\n"); +} +#endif + +void on_input(unsigned int ch) { + switch (ch) { + case 's': + fall(); + break; + case 'a': + move(¤t, 0); + break; + case 'd': + move(¤t, 1); + break; + case 'j': + rotate(¤t, 0); + break; + case 'k': + rotate(¤t, 1); + break; + } + draw_board(); +#ifdef DEBUG + print_screen(); +#endif +} + +void on_timer() { + fall(); + draw_board(); +} + +void trap_handler(void *epc, unsigned int cause) { + if (cause == 0x80000007) { + on_timer(); + } else if (cause == 0x8000000B){ + unsigned int ch = *VA_UART_RECV; + *VA_UART_SEND = ch; + on_input(ch); + } +} + +void init() { + clear_board(); + // Draw border + for (int r = 0; r < ROWS; ++r) { + putch_at(0, r, '|'); + putch_at(COLS << 1 | 1, r, '|'); + } + for (int c = 0; c <= (2 << COLS | 1); ++c) { + putch_at(c, ROWS, '-'); + } + int c = 8; + putch_at(c++, ROWS + 1, 'B'); + putch_at(c++, ROWS + 1, 'e'); + putch_at(c++, ROWS + 1, 'g'); + putch_at(c++, ROWS + 1, 'i'); + putch_at(c++, ROWS + 1, 'n'); + putch_at(c++, ROWS + 1, ' '); + c = 6; + putch_at(c++, ROWS + 3, 'P'); + putch_at(c++, ROWS + 3, 'a'); + putch_at(c++, ROWS + 3, 'g'); + putch_at(c++, ROWS + 3, 'i'); + putch_at(c++, ROWS + 3, 'n'); + putch_at(c++, ROWS + 3, 'g'); + c++; + putch_at(c++, ROWS + 3, 'h'); + putch_at(c++, ROWS + 3, 'r'); + putch_at(c++, ROWS + 3, 'p'); + c = 9; + putch_at(c++, ROWS + 4, '2'); + putch_at(c++, ROWS + 4, '0'); + putch_at(c++, ROWS + 4, '2'); + putch_at(c++, ROWS + 4, '2'); + init_block(¤t, rand_type(), 4, 0); + score = 0; + draw_board(); +} + +int alloc(){ + int index = 0; + int max = 8; + while(index < max){ + if(pm[index] == 0){ + pm[index] = 1; + break; + } + index++; + } + return index == max ? -1 : index; +} + +int map(pagetable_t pgtbl,uint32 va,uint32 pa,int perm){ + int t; + if((pgtbl[PX(1,va)] & PTE_V )!= PTE_V){ //前缀不存在 + t=alloc(); //申请一个页给前缀页表 + if(t>=0){ + pgtbl[PX(1,va)] = PA2PTE(t<<12) | PTE_V; + }else{ + return -1; + } + } + int* n = (void*)PTE2PA(pgtbl[PX(1,va)]); + n[PX(0,va)] = PA2PTE(pa) | perm | PTE_V; + return 0; +} + +void kvminit(){ + //init global valuable + for(int i=0;i<8;i++){ + pm[i] = 0; + } + timercount = 0; + + pagetable_t pgtbl = (void*)PAGEDIR_BASE; + // memoryset(pgtbl,0,PGSIZE); //后面需要读这个内存,所以先初始化 + for(int i=0;i>2;i++){ + pgtbl[i]=0; + } + + pm[PAGEDIR_BASE >> 12] = 1; + pm[0]=1; + pm[1]=1; + pm[2]=1; + pm[3]=1; + pm[4]=1; + //create pte mmap for text + map(pgtbl,PAGEDIR_BASE,PAGEDIR_BASE,PTE_R | PTE_W); + map(pgtbl,0x0,0x0, PTE_W | PTE_R ); //kernel stack + map(pgtbl,0x1000,0x1000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x2000,0x2000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x3000,0x3000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x4000,0x4000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,VA_VRAM_BASE,VRAM_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_VRAM_BASE + PGSIZE,VRAM_BASE + PGSIZE, PTE_W | PTE_R); + map(pgtbl,VA_UART_BASE,UART_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_TIMER_BASE,TIMER_BASE, PTE_W | PTE_R ); // +} + +void clear_screen() { + int *vram = ((int *) VA_VRAM_BASE); + for (int i = 0; i < 600; ++i) vram[i] = 0x20202020; +} + +extern void enable_interrupt(); +extern void enable_paging(); + +int main() { +#ifdef DEBUG + unsigned char b[ROWS * COLS] = {0}; + board = b; + for (int i = 0; i < SCREEN_ROWS * SCREEN_COLS; ++i) screen[i] = '%'; + init(); +#else + kvminit(); + enable_paging(); + board = (unsigned char *) 16640; //0x4100 + clear_screen(); + init(); + *((unsigned int *) 4) = 0xDEADBEEF; + enable_interrupt(); + *VA_TIMER_ENABLED = 1; + *VA_TIMER_LIMIT = FALL_TIMER_LIMIT; + for (;;); +#endif +#ifdef DEBUG + on_input('a'); + on_input('a'); + on_input('s'); + on_input('s'); + on_input('s'); + for (int i = 21; i >= 0; --i) { + on_timer(); + } + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + for (int i = 21; i >= 0; --i) { + on_timer(); + } + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + for (int i = 21; i >= 0; --i) { + on_timer(); + add_score(10); + } + print_score(); + print_screen(); + return 0; +#endif +} diff --git a/lab1/src/main/resources/fibonacci.asmbin b/lab1/src/main/resources/fibonacci.asmbin index 45e994f..91f7740 100644 Binary files a/lab1/src/main/resources/fibonacci.asmbin and b/lab1/src/main/resources/fibonacci.asmbin differ diff --git a/lab1/src/main/resources/hello.asmbin b/lab1/src/main/resources/hello.asmbin index 8e9a27d..27a4e32 100644 Binary files a/lab1/src/main/resources/hello.asmbin and b/lab1/src/main/resources/hello.asmbin differ diff --git a/lab1/src/main/resources/paging.asmbin b/lab1/src/main/resources/paging.asmbin new file mode 100644 index 0000000..45011d8 Binary files /dev/null and b/lab1/src/main/resources/paging.asmbin differ diff --git a/lab1/src/main/resources/quicksort.asmbin b/lab1/src/main/resources/quicksort.asmbin index d9a007a..60d10f4 100644 Binary files a/lab1/src/main/resources/quicksort.asmbin and b/lab1/src/main/resources/quicksort.asmbin differ diff --git a/lab1/src/main/resources/tetris.asmbin b/lab1/src/main/resources/tetris.asmbin index fc07ed8..fdeaeda 100644 Binary files a/lab1/src/main/resources/tetris.asmbin and b/lab1/src/main/resources/tetris.asmbin differ diff --git a/lab1/src/main/resources/tetris_mmu.asmbin b/lab1/src/main/resources/tetris_mmu.asmbin new file mode 100644 index 0000000..fe350f0 Binary files /dev/null and b/lab1/src/main/resources/tetris_mmu.asmbin differ diff --git a/lab2/csrc/CMakeLists.txt b/lab2/csrc/CMakeLists.txt index 32a8ca4..ee07b00 100644 --- a/lab2/csrc/CMakeLists.txt +++ b/lab2/csrc/CMakeLists.txt @@ -5,7 +5,7 @@ project(yatcpu-programs C CXX ASM) # Setting variables set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 --target=riscv32-unknown-elf -march=rv32i -mabi=ilp32") set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O0 --target=riscv32-unknown-elf -march=rv32i -mabi=ilp32") -set(C_PROGRAMS tetris hello fibonacci quicksort simpletest) +set(C_PROGRAMS tetris hello fibonacci quicksort paging tetris_mmu) set(ASM_PROGRAMS mmio sb) set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/link.lds) set(LINKER_FLAGS -T ${LINKER_SCRIPT}) @@ -32,8 +32,8 @@ foreach(program IN LISTS ASM_PROGRAMS) set_target_properties(${program} PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT}) endforeach() -# Copy the .text section to .asmbin files -foreach(program IN LISTS C_PROGRAMS ASM_PROGRAMS) +# Copy the .text and .data section to .asmbin files +foreach(program IN LISTS C_PROGRAMS ASM_PROGRAMS PROGRAMS) add_custom_command( TARGET ${program} POST_BUILD diff --git a/lab2/csrc/init.S b/lab2/csrc/init.S index 4534c78..1d4dbce 100644 --- a/lab2/csrc/init.S +++ b/lab2/csrc/init.S @@ -15,7 +15,7 @@ .section .text.init .globl _start _start: - li sp, 4096 # Initialize stack pointer + li sp, 0x10000000 # Initialize stack pointer call main # Jump to main function loop: j loop # Loop forever @@ -26,6 +26,16 @@ enable_interrupt: li t0, 0x1888 csrrw t1, mstatus, t0 # enable interrupt ret +.globl enable_paging +enable_paging: + li t0, 0x80000005 # ppn << 12 = 0x005000 + csrw satp, t0 + ret +.globl get_mtval +get_mtval: + csrr a0, mtval + ret + .globl get_epc get_epc: csrr a0, mepc diff --git a/lab2/csrc/link.lds b/lab2/csrc/link.lds index b5d8366..a166fc7 100644 --- a/lab2/csrc/link.lds +++ b/lab2/csrc/link.lds @@ -6,6 +6,7 @@ SECTIONS . = 0x00001000; .text : { *(.text.init) *(.text.startup) *(.text) } .data ALIGN(0x1000) : { *(.data*) *(.rodata*) *(.sdata*) } + . = 0x00100000; .bss : { *(.bss) } _end = .; } diff --git a/lab2/csrc/mm.h b/lab2/csrc/mm.h new file mode 100644 index 0000000..5d4c89a --- /dev/null +++ b/lab2/csrc/mm.h @@ -0,0 +1,43 @@ +// Copyright 2022 hrpccs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +typedef unsigned int uint32; +typedef uint32 pte_t; +typedef uint32* pagetable_t; + +#define PGSIZE 4096 // bytes per page +#define PGSHIFT 12 // bits of offset within a page + +#define PGROUNDUP(sz) (((sz)+PGSIZE-1) & ~(PGSIZE-1)) +#define PGROUNDDOWN(a) (((a)) & ~(PGSIZE-1)) + +#define PTE_V (1L << 0) // valid +#define PTE_R (1L << 1) +#define PTE_W (1L << 2) +#define PTE_X (1L << 3) +#define PTE_U (1L << 4) // 1 -> user can access + +// shift a physical address to the right place for a PTE. +#define PA2PTE(pa) ((((uint32)pa) >> 12) << 10) + +#define PTE2PA(pte) (((pte) >> 10) << 12) + +#define PTE_FLAGS(pte) ((pte) & 0x3FF) + +// extract the two 10-bit page table indices from a virtual address. +#define PXMASK 0x3FF // 10 bits +#define PXSHIFT(level) (PGSHIFT+(10*(level))) +#define PX(level, va) ((((uint32) (va)) >> PXSHIFT(level)) & PXMASK) + +#define MAXVA (1L << (10 + 10 + 12)) diff --git a/lab2/csrc/mmio.h b/lab2/csrc/mmio.h index b1222dd..fb0fa5f 100644 --- a/lab2/csrc/mmio.h +++ b/lab2/csrc/mmio.h @@ -21,3 +21,13 @@ #define UART_BAUDRATE ((volatile unsigned int *) (UART_BASE + 4)) #define UART_RECV ((volatile unsigned int *) (UART_BASE + 12)) #define UART_SEND ((volatile unsigned int *) (UART_BASE + 16)) +//remap the mmio to reduce memory usage of page table +#define VA_VRAM_BASE 0x00100000 +#define VA_VRAM ((volatile unsigned char *) VA_VRAM_BASE) +#define VA_TIMER_BASE 0x00200000 +#define VA_TIMER_LIMIT ((volatile unsigned int *) (VA_TIMER_BASE + 4)) +#define VA_TIMER_ENABLED ((volatile unsigned int *) (VA_TIMER_BASE + 8)) +#define VA_UART_BASE 0x00300000 +#define VA_UART_BAUDRATE ((volatile unsigned int *) (VA_UART_BASE + 4)) +#define VA_UART_RECV ((volatile unsigned int *) (VA_UART_BASE + 12)) +#define VA_UART_SEND ((volatile unsigned int *) (VA_UART_BASE + 16)) \ No newline at end of file diff --git a/lab2/csrc/paging.c b/lab2/csrc/paging.c new file mode 100644 index 0000000..d8d59d5 --- /dev/null +++ b/lab2/csrc/paging.c @@ -0,0 +1,191 @@ +// # Copyright 2022 hrpccs +// # +// # Licensed under the Apache License, Version 2.0 (the "License"); +// # you may not use this file except in compliance with the License. +// # You may obtain a copy of the License at +// # +// # http://www.apache.org/licenses/LICENSE-2.0 +// # +// # Unless required by applicable law or agreed to in writing, software +// # distributed under the License is distributed on an "AS IS" BASIS, +// # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// # See the License for the specific language governing permissions and +// # limitations under the License. + +#include "mm.h" +#include "mmio.h" + + + +#define SCREEN_COLS 80 +#define SCREEN_ROWS 30 +#define INT_TIMER_LIMIT 50000000 +#define PAGEDIR_BASE 0x5000 + +typedef unsigned int uint32; +typedef uint32 pte_t; +typedef uint32* pagetable_t; + +extern void enable_paging(); +extern void enable_interrupt(); +extern int get_mtval(); + +int wk_mul(int a, int b) { + int r = 0; + for (; b; a <<= 1, b >>= 1) + if (b & 1) + r += a; + return r; +} + +void memoryset(unsigned char *dest,unsigned char num, unsigned int size){ + for(unsigned int i=0;i=0){ + int* taddr = (int*)(t<<12); + for(int i=0;i>2;i++){ + taddr[i]=0; + } + pgtbl[PX(1,va)] = PA2PTE(t<<12) | PTE_V; + }else{ + while(1); + for(int i=0;i<14;i++){ + putch_at(i,22,"out of memory!"[i]); + } + while(1); + } + } + pagetable_t n = (void*)PTE2PA(pgtbl[PX(1,va)]); + n[PX(0,va)] = PA2PTE(pa) | perm | PTE_V; +} + + +void kvminit(){ + pagetable_t pgtbl = (void*)PAGEDIR_BASE; + // memoryset(pgtbl,0,PGSIZE); //后面需要读这个内存,所以先初始化 + for(int i=0;i>2;i++){ + pgtbl[i]=0; + } + + pm[PAGEDIR_BASE >> 12] = 1; + pm[0]=1; + pm[1]=1; + pm[2]=1; + pm[3]=1; + pm[4]=1; + //create pte mmap for text + pgtbl[1023] = PA2PTE(PAGEDIR_BASE) | PTE_R | PTE_W; + map(pgtbl,PAGEDIR_BASE,PAGEDIR_BASE,PTE_R | PTE_W); + map(pgtbl,0x0,0x0, PTE_W | PTE_R ); //kernel stack + map(pgtbl,0x1000,0x1000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x2000,0x2000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x3000,0x3000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x4000,0x4000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,VA_VRAM_BASE,VRAM_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_VRAM_BASE + PGSIZE,VRAM_BASE + PGSIZE, PTE_W | PTE_R); + map(pgtbl,VA_UART_BASE,UART_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_TIMER_BASE,TIMER_BASE, PTE_W | PTE_R ); // +} + +void clear_screen() { + int *vram = ((int *) VRAM_BASE); + for (int i = 0; i < 600; ++i) vram[i] = 0x20202020; +} + +void trap_handler(void *epc, unsigned int cause) { + if (cause == 10 || cause == 15 || cause == 13) { + for(int i=0;i<39;i++){ + putch_at(i,4,"A not handled page fault caused by : 0x"[i]); + } + int mtval = get_mtval(); + char ch; + for (int i = 0; i < 8; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (mtval & mask) >> (i * 4); + if(num >= 10){ + ch = num - 10 + 'A'; + }else{ + ch = num + '0'; + } + putch_at(39+7-i,4,ch); + } + while(1); //目前还没有处理page-fault,因为还没有建立完整的映射。 + } else if(cause == 0x80000007){ + for(int i=0;i<16;i++){ + putch_at(i,3,"timer count : 0x"[i]); + } + char ch; + for (int i = 0; i < 8; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (timercount & mask) >> (i * 4); + if(num >= 10){ + ch = num - 10 + 'A'; + }else{ + ch = num + '0'; + } + putch_at(16+7-i,3,ch); + } + timercount += 1; + + } +} + +int main(){ + putch_at = __putch_at; + for(int i=0;i<8;i++){ + pm[i] = 0; + } + timercount = 0; + clear_screen(); + for(int i=0;i<19;i++){ + putch_at(i,0,"print before paging"[i]); + } + kvminit(); + putch_at = __vputch_at; + enable_paging(); + for(int i=0;i<18;i++){ + putch_at(i,1,"print after paging"[i]); + } + enable_interrupt(); + *VA_TIMER_ENABLED = 1; + *VA_TIMER_LIMIT = INT_TIMER_LIMIT; + + while(1){ + if(timercount == 0x20){ + *(int*)0x11415 = 1130; + } + } + for(;;); +} \ No newline at end of file diff --git a/lab2/csrc/say_goodbye.c b/lab2/csrc/say_goodbye.c new file mode 100644 index 0000000..566e7e2 --- /dev/null +++ b/lab2/csrc/say_goodbye.c @@ -0,0 +1,44 @@ + +void uart_send_char(char c) +{ + *((volatile unsigned int *) (0x40000010)) = c; + // *((volatile unsigned int *) (0x40000000)) = c; +} + + +void waste_some_time(int cycle) { + unsigned int a = 135; + while (cycle--) { + a++; + } +} + +int main() { + + // const char* s = "abcd"; + const char* s = "Never gonna give you up~ Never gonna let you down~\n\ + Never gonna run around and~ desert you~\n"; + + while (1) { + + + // for (int i = 0; i < ; i++) { + // uart_send_char(s[i]); + // waste_some_time(100); + // } + + const char *p = s; + while (*p != 0) + { + uart_send_char(*p); + p++; + waste_some_time(100); + } + + waste_some_time(200); + + break; // print once, but pressing CPU reset can print again + } + + return 0; +} diff --git a/lab2/csrc/simpletest.c b/lab2/csrc/simpletest.c deleted file mode 100644 index 3993a24..0000000 --- a/lab2/csrc/simpletest.c +++ /dev/null @@ -1,12 +0,0 @@ - -extern void enable_interrupt(); - -void trap_handler(void *epc, unsigned int cause){ - *((int*)0x4) = 0x2022; -} - -int main(){ - *((int*)0x4) = 0xDEADBEEF; - enable_interrupt(); - for(;;); -} \ No newline at end of file diff --git a/lab2/csrc/tetris.S b/lab2/csrc/tetris.S deleted file mode 100644 index 53b41cb..0000000 --- a/lab2/csrc/tetris.S +++ /dev/null @@ -1,2023 +0,0 @@ - -build/tetris: file format elf32-littleriscv - - -Disassembly of section .text: - -00001000 <_start>: - 1000: 00001137 lui sp,0x1 - 1004: 00002097 auipc ra,0x2 - 1008: be4080e7 jalr -1052(ra) # 2be8
- -0000100c : - 100c: 0000006f j 100c - -00001010 : - 1010: 00000297 auipc t0,0x0 - 1014: 02828293 addi t0,t0,40 # 1038 <__trap_entry> - 1018: 30529373 csrrw t1,mtvec,t0 - 101c: 000022b7 lui t0,0x2 - 1020: 88828293 addi t0,t0,-1912 # 1888 - 1024: 30029373 csrrw t1,mstatus,t0 - 1028: 00008067 ret - -0000102c : - 102c: 34102573 csrr a0,mepc - 1030: 00008067 ret - -00001034 : - 1034: 00008067 ret - -00001038 <__trap_entry>: - 1038: 34011073 csrw mscratch,sp - 103c: f8010113 addi sp,sp,-128 # f80 <_start-0x80> - 1040: 00112223 sw ra,4(sp) - 1044: 00312623 sw gp,12(sp) - 1048: 00412823 sw tp,16(sp) - 104c: 00512a23 sw t0,20(sp) - 1050: 00612c23 sw t1,24(sp) - 1054: 00712e23 sw t2,28(sp) - 1058: 02412023 sw tp,32(sp) - 105c: 02912223 sw s1,36(sp) - 1060: 02a12423 sw a0,40(sp) - 1064: 02b12623 sw a1,44(sp) - 1068: 02c12823 sw a2,48(sp) - 106c: 02d12a23 sw a3,52(sp) - 1070: 02e12c23 sw a4,56(sp) - 1074: 02f12e23 sw a5,60(sp) - 1078: 05012023 sw a6,64(sp) - 107c: 05112223 sw a7,68(sp) - 1080: 05212423 sw s2,72(sp) - 1084: 05312623 sw s3,76(sp) - 1088: 05412823 sw s4,80(sp) - 108c: 05512a23 sw s5,84(sp) - 1090: 05612c23 sw s6,88(sp) - 1094: 05712e23 sw s7,92(sp) - 1098: 07812023 sw s8,96(sp) - 109c: 07912223 sw s9,100(sp) - 10a0: 07a12423 sw s10,104(sp) - 10a4: 07b12623 sw s11,108(sp) - 10a8: 07c12823 sw t3,112(sp) - 10ac: 07d12a23 sw t4,116(sp) - 10b0: 07e12c23 sw t5,120(sp) - 10b4: 07f12e23 sw t6,124(sp) - 10b8: 34102573 csrr a0,mepc - 10bc: 342025f3 csrr a1,mcause - 10c0: 00001097 auipc ra,0x1 - 10c4: 6f0080e7 jalr 1776(ra) # 27b0 - 10c8: 00412083 lw ra,4(sp) - 10cc: 00c12183 lw gp,12(sp) - 10d0: 01012203 lw tp,16(sp) - 10d4: 01412283 lw t0,20(sp) - 10d8: 01812303 lw t1,24(sp) - 10dc: 01c12383 lw t2,28(sp) - 10e0: 02012203 lw tp,32(sp) - 10e4: 02412483 lw s1,36(sp) - 10e8: 02812503 lw a0,40(sp) - 10ec: 02c12583 lw a1,44(sp) - 10f0: 03012603 lw a2,48(sp) - 10f4: 03412683 lw a3,52(sp) - 10f8: 03812703 lw a4,56(sp) - 10fc: 03c12783 lw a5,60(sp) - 1100: 04012803 lw a6,64(sp) - 1104: 04412883 lw a7,68(sp) - 1108: 04812903 lw s2,72(sp) - 110c: 04c12983 lw s3,76(sp) - 1110: 05012a03 lw s4,80(sp) - 1114: 05412a83 lw s5,84(sp) - 1118: 05812b03 lw s6,88(sp) - 111c: 05c12b83 lw s7,92(sp) - 1120: 06012c03 lw s8,96(sp) - 1124: 06412c83 lw s9,100(sp) - 1128: 06812d03 lw s10,104(sp) - 112c: 06c12d83 lw s11,108(sp) - 1130: 07012e03 lw t3,112(sp) - 1134: 07412e83 lw t4,116(sp) - 1138: 07812f03 lw t5,120(sp) - 113c: 07c12f83 lw t6,124(sp) - 1140: 34002173 csrr sp,mscratch - 1144: 30200073 mret - -00001148 : - 1148: fe010113 addi sp,sp,-32 - 114c: 00112e23 sw ra,28(sp) - 1150: 00812c23 sw s0,24(sp) - 1154: 02010413 addi s0,sp,32 - 1158: fea42a23 sw a0,-12(s0) - 115c: feb42823 sw a1,-16(s0) - 1160: 00000513 li a0,0 - 1164: fea42623 sw a0,-20(s0) - 1168: 0040006f j 116c - 116c: ff042503 lw a0,-16(s0) - 1170: 00000593 li a1,0 - 1174: 04b50863 beq a0,a1,11c4 - 1178: 0040006f j 117c - 117c: ff044503 lbu a0,-16(s0) - 1180: 00157513 andi a0,a0,1 - 1184: 00000593 li a1,0 - 1188: 00b50e63 beq a0,a1,11a4 - 118c: 0040006f j 1190 - 1190: ff442583 lw a1,-12(s0) - 1194: fec42503 lw a0,-20(s0) - 1198: 00b50533 add a0,a0,a1 - 119c: fea42623 sw a0,-20(s0) - 11a0: 0040006f j 11a4 - 11a4: 0040006f j 11a8 - 11a8: ff442503 lw a0,-12(s0) - 11ac: 00151513 slli a0,a0,0x1 - 11b0: fea42a23 sw a0,-12(s0) - 11b4: ff042503 lw a0,-16(s0) - 11b8: 40155513 srai a0,a0,0x1 - 11bc: fea42823 sw a0,-16(s0) - 11c0: fadff06f j 116c - 11c4: fec42503 lw a0,-20(s0) - 11c8: 01812403 lw s0,24(sp) - 11cc: 01c12083 lw ra,28(sp) - 11d0: 02010113 addi sp,sp,32 - 11d4: 00008067 ret - -000011d8 : - 11d8: fe010113 addi sp,sp,-32 - 11dc: 00112e23 sw ra,28(sp) - 11e0: 00812c23 sw s0,24(sp) - 11e4: 02010413 addi s0,sp,32 - 11e8: fea42a23 sw a0,-12(s0) - 11ec: feb42823 sw a1,-16(s0) - 11f0: fec42623 sw a2,-20(s0) - 11f4: fed42423 sw a3,-24(s0) - 11f8: ff442503 lw a0,-12(s0) - 11fc: 00c51513 slli a0,a0,0xc - 1200: ff042583 lw a1,-16(s0) - 1204: 00459593 slli a1,a1,0x4 - 1208: 00b56533 or a0,a0,a1 - 120c: fec42583 lw a1,-20(s0) - 1210: 00259593 slli a1,a1,0x2 - 1214: 00b56533 or a0,a0,a1 - 1218: fe842583 lw a1,-24(s0) - 121c: 00b56533 or a0,a0,a1 - 1220: 01812403 lw s0,24(sp) - 1224: 01c12083 lw ra,28(sp) - 1228: 02010113 addi sp,sp,32 - 122c: 00008067 ret - -00001230 : - 1230: fd010113 addi sp,sp,-48 - 1234: 02112623 sw ra,44(sp) - 1238: 02812423 sw s0,40(sp) - 123c: 03010413 addi s0,sp,48 - 1240: fea42a23 sw a0,-12(s0) - 1244: feb42823 sw a1,-16(s0) - 1248: fec42623 sw a2,-20(s0) - 124c: fed42423 sw a3,-24(s0) - 1250: 00000513 li a0,0 - 1254: fea42223 sw a0,-28(s0) - 1258: fea42023 sw a0,-32(s0) - 125c: ff442583 lw a1,-12(s0) - 1260: 00a5a423 sw a0,8(a1) - 1264: ff442583 lw a1,-12(s0) - 1268: 00a5a223 sw a0,4(a1) - 126c: ff442583 lw a1,-12(s0) - 1270: 00a5a023 sw a0,0(a1) - 1274: ff042583 lw a1,-16(s0) - 1278: fcb42e23 sw a1,-36(s0) - 127c: 00600513 li a0,6 - 1280: 12b56c63 bltu a0,a1,13b8 <.LBB2_8+0x2c> - 1284: fdc42503 lw a0,-36(s0) - 1288: 00251513 slli a0,a0,0x2 - 128c: 000035b7 lui a1,0x3 - 1290: 00058593 mv a1,a1 - 1294: 00b50533 add a0,a0,a1 - 1298: 00052503 lw a0,0(a0) - 129c: 00050067 jr a0 - -000012a0 <.LBB2_2>: - 12a0: ff442583 lw a1,-12(s0) - 12a4: 00f00513 li a0,15 - 12a8: 00a5a023 sw a0,0(a1) # 3000 <.LJTI2_0> - 12ac: 00300513 li a0,3 - 12b0: fea42223 sw a0,-28(s0) - 12b4: 00000513 li a0,0 - 12b8: fea42023 sw a0,-32(s0) - 12bc: 0fc0006f j 13b8 <.LBB2_8+0x2c> - -000012c0 <.LBB2_3>: - 12c0: ff442583 lw a1,-12(s0) - 12c4: 00300513 li a0,3 - 12c8: 00a5a023 sw a0,0(a1) - 12cc: ff442583 lw a1,-12(s0) - 12d0: 00a5a223 sw a0,4(a1) - 12d4: 00100513 li a0,1 - 12d8: fea42223 sw a0,-28(s0) - 12dc: fea42023 sw a0,-32(s0) - 12e0: 0d80006f j 13b8 <.LBB2_8+0x2c> - -000012e4 <.LBB2_4>: - 12e4: ff442583 lw a1,-12(s0) - 12e8: 00400513 li a0,4 - 12ec: 00a5a023 sw a0,0(a1) - 12f0: ff442583 lw a1,-12(s0) - 12f4: 00700513 li a0,7 - 12f8: 00a5a223 sw a0,4(a1) - 12fc: 00200513 li a0,2 - 1300: fea42223 sw a0,-28(s0) - 1304: 00100513 li a0,1 - 1308: fea42023 sw a0,-32(s0) - 130c: 0ac0006f j 13b8 <.LBB2_8+0x2c> - -00001310 <.LBB2_5>: - 1310: ff442583 lw a1,-12(s0) - 1314: 00200513 li a0,2 - 1318: 00a5a023 sw a0,0(a1) - 131c: ff442603 lw a2,-12(s0) - 1320: 00700593 li a1,7 - 1324: 00b62223 sw a1,4(a2) - 1328: fea42223 sw a0,-28(s0) - 132c: 00100513 li a0,1 - 1330: fea42023 sw a0,-32(s0) - 1334: 0840006f j 13b8 <.LBB2_8+0x2c> - -00001338 <.LBB2_6>: - 1338: ff442583 lw a1,-12(s0) - 133c: 00100513 li a0,1 - 1340: 00a5a023 sw a0,0(a1) - 1344: ff442603 lw a2,-12(s0) - 1348: 00700593 li a1,7 - 134c: 00b62223 sw a1,4(a2) - 1350: 00200593 li a1,2 - 1354: feb42223 sw a1,-28(s0) - 1358: fea42023 sw a0,-32(s0) - 135c: 05c0006f j 13b8 <.LBB2_8+0x2c> - -00001360 <.LBB2_7>: - 1360: ff442583 lw a1,-12(s0) - 1364: 00600513 li a0,6 - 1368: 00a5a023 sw a0,0(a1) - 136c: ff442583 lw a1,-12(s0) - 1370: 00300513 li a0,3 - 1374: 00a5a223 sw a0,4(a1) - 1378: 00200513 li a0,2 - 137c: fea42223 sw a0,-28(s0) - 1380: 00100513 li a0,1 - 1384: fea42023 sw a0,-32(s0) - 1388: 0300006f j 13b8 <.LBB2_8+0x2c> - -0000138c <.LBB2_8>: - 138c: ff442583 lw a1,-12(s0) - 1390: 00300513 li a0,3 - 1394: 00a5a023 sw a0,0(a1) - 1398: ff442583 lw a1,-12(s0) - 139c: 00600513 li a0,6 - 13a0: 00a5a223 sw a0,4(a1) - 13a4: 00200513 li a0,2 - 13a8: fea42223 sw a0,-28(s0) - 13ac: 00100513 li a0,1 - 13b0: fea42023 sw a0,-32(s0) - 13b4: 0040006f j 13b8 <.LBB2_8+0x2c> - 13b8: fec42503 lw a0,-20(s0) - 13bc: fe842583 lw a1,-24(s0) - 13c0: fe442603 lw a2,-28(s0) - 13c4: fe042683 lw a3,-32(s0) - 13c8: 00000097 auipc ra,0x0 - 13cc: e10080e7 jalr -496(ra) # 11d8 - 13d0: ff442583 lw a1,-12(s0) - 13d4: 00a5a623 sw a0,12(a1) - 13d8: 02812403 lw s0,40(sp) - 13dc: 02c12083 lw ra,44(sp) - 13e0: 03010113 addi sp,sp,48 - 13e4: 00008067 ret - -000013e8 : - 13e8: fe010113 addi sp,sp,-32 - 13ec: 00112e23 sw ra,28(sp) - 13f0: 00812c23 sw s0,24(sp) - 13f4: 02010413 addi s0,sp,32 - 13f8: fea42a23 sw a0,-12(s0) - 13fc: feb42823 sw a1,-16(s0) - 1400: fec42623 sw a2,-20(s0) - 1404: ff442503 lw a0,-12(s0) - 1408: ff042583 lw a1,-16(s0) - 140c: 00259593 slli a1,a1,0x2 - 1410: 00b50533 add a0,a0,a1 - 1414: 00052503 lw a0,0(a0) - 1418: fec42583 lw a1,-20(s0) - 141c: 00100613 li a2,1 - 1420: 00b61633 sll a2,a2,a1 - 1424: 00c57533 and a0,a0,a2 - 1428: 00b55533 srl a0,a0,a1 - 142c: 01812403 lw s0,24(sp) - 1430: 01c12083 lw ra,28(sp) - 1434: 02010113 addi sp,sp,32 - 1438: 00008067 ret - -0000143c : - 143c: fd010113 addi sp,sp,-48 - 1440: 02112623 sw ra,44(sp) - 1444: 02812423 sw s0,40(sp) - 1448: 03010413 addi s0,sp,48 - 144c: fea42823 sw a0,-16(s0) - 1450: ff042503 lw a0,-16(s0) - 1454: 00c52503 lw a0,12(a0) - 1458: fea42623 sw a0,-20(s0) - 145c: fec42503 lw a0,-20(s0) - 1460: 00357513 andi a0,a0,3 - 1464: fea42423 sw a0,-24(s0) - 1468: fec42503 lw a0,-20(s0) - 146c: 00c57513 andi a0,a0,12 - 1470: 00255513 srli a0,a0,0x2 - 1474: fea42223 sw a0,-28(s0) - 1478: fec42503 lw a0,-20(s0) - 147c: 000015b7 lui a1,0x1 - 1480: ff058593 addi a1,a1,-16 # ff0 <_start-0x10> - 1484: 00b57533 and a0,a0,a1 - 1488: 00455513 srli a0,a0,0x4 - 148c: fea42023 sw a0,-32(s0) - 1490: fec42503 lw a0,-20(s0) - 1494: 01051513 slli a0,a0,0x10 - 1498: 01c55513 srli a0,a0,0x1c - 149c: fca42e23 sw a0,-36(s0) - 14a0: 00000513 li a0,0 - 14a4: 02a51063 bne a0,a0,14c4 - 14a8: 0040006f j 14ac - 14ac: fdc42503 lw a0,-36(s0) - 14b0: fe442583 lw a1,-28(s0) - 14b4: 00b50533 add a0,a0,a1 - 14b8: 00a00593 li a1,10 - 14bc: 00b56a63 bltu a0,a1,14d0 - 14c0: 0040006f j 14c4 - 14c4: 00000513 li a0,0 - 14c8: fea42a23 sw a0,-12(s0) - 14cc: 0400006f j 150c - 14d0: 00000513 li a0,0 - 14d4: 02a51063 bne a0,a0,14f4 - 14d8: 0040006f j 14dc - 14dc: fe042503 lw a0,-32(s0) - 14e0: fe842583 lw a1,-24(s0) - 14e4: 00b50533 add a0,a0,a1 - 14e8: 01600593 li a1,22 - 14ec: 00b56a63 bltu a0,a1,1500 - 14f0: 0040006f j 14f4 - 14f4: 00000513 li a0,0 - 14f8: fea42a23 sw a0,-12(s0) - 14fc: 0100006f j 150c - 1500: 00100513 li a0,1 - 1504: fea42a23 sw a0,-12(s0) - 1508: 0040006f j 150c - 150c: ff442503 lw a0,-12(s0) - 1510: 02812403 lw s0,40(sp) - 1514: 02c12083 lw ra,44(sp) - 1518: 03010113 addi sp,sp,48 - 151c: 00008067 ret - -00001520 : - 1520: ff010113 addi sp,sp,-16 - 1524: 00112623 sw ra,12(sp) - 1528: 00812423 sw s0,8(sp) - 152c: 01010413 addi s0,sp,16 - 1530: fea42a23 sw a0,-12(s0) - 1534: feb42823 sw a1,-16(s0) - 1538: ff042503 lw a0,-16(s0) - 153c: 00c52503 lw a0,12(a0) - 1540: ff442583 lw a1,-12(s0) - 1544: 00a5a623 sw a0,12(a1) - 1548: ff042503 lw a0,-16(s0) - 154c: 00052503 lw a0,0(a0) - 1550: ff442583 lw a1,-12(s0) - 1554: 00a5a023 sw a0,0(a1) - 1558: ff042503 lw a0,-16(s0) - 155c: 00452503 lw a0,4(a0) - 1560: ff442583 lw a1,-12(s0) - 1564: 00a5a223 sw a0,4(a1) - 1568: ff042503 lw a0,-16(s0) - 156c: 00852503 lw a0,8(a0) - 1570: ff442583 lw a1,-12(s0) - 1574: 00a5a423 sw a0,8(a1) - 1578: 00812403 lw s0,8(sp) - 157c: 00c12083 lw ra,12(sp) - 1580: 01010113 addi sp,sp,16 - 1584: 00008067 ret - -00001588 : - 1588: fd010113 addi sp,sp,-48 - 158c: 02112623 sw ra,44(sp) - 1590: 02812423 sw s0,40(sp) - 1594: 03010413 addi s0,sp,48 - 1598: fea42823 sw a0,-16(s0) - 159c: ff042503 lw a0,-16(s0) - 15a0: 00c52503 lw a0,12(a0) - 15a4: fea42623 sw a0,-20(s0) - 15a8: fec42503 lw a0,-20(s0) - 15ac: 00357513 andi a0,a0,3 - 15b0: fea42423 sw a0,-24(s0) - 15b4: fec42503 lw a0,-20(s0) - 15b8: 00c57513 andi a0,a0,12 - 15bc: 00255513 srli a0,a0,0x2 - 15c0: fea42223 sw a0,-28(s0) - 15c4: fec42503 lw a0,-20(s0) - 15c8: 000015b7 lui a1,0x1 - 15cc: ff058593 addi a1,a1,-16 # ff0 <_start-0x10> - 15d0: 00b57533 and a0,a0,a1 - 15d4: 00455513 srli a0,a0,0x4 - 15d8: fea42023 sw a0,-32(s0) - 15dc: fec42503 lw a0,-20(s0) - 15e0: 01051513 slli a0,a0,0x10 - 15e4: 01c55513 srli a0,a0,0x1c - 15e8: fca42e23 sw a0,-36(s0) - 15ec: 00000513 li a0,0 - 15f0: fca42c23 sw a0,-40(s0) - 15f4: 0040006f j 15f8 - 15f8: fd842583 lw a1,-40(s0) - 15fc: fe842503 lw a0,-24(s0) - 1600: 0cb56463 bltu a0,a1,16c8 - 1604: 0040006f j 1608 - 1608: 00000513 li a0,0 - 160c: fca42a23 sw a0,-44(s0) - 1610: 0040006f j 1614 - 1614: fd442583 lw a1,-44(s0) - 1618: fe442503 lw a0,-28(s0) - 161c: 08b56c63 bltu a0,a1,16b4 - 1620: 0040006f j 1624 - 1624: ff042503 lw a0,-16(s0) - 1628: fd842583 lw a1,-40(s0) - 162c: fd442603 lw a2,-44(s0) - 1630: 00000097 auipc ra,0x0 - 1634: db8080e7 jalr -584(ra) # 13e8 - 1638: 00000593 li a1,0 - 163c: 06b50263 beq a0,a1,16a0 - 1640: 0040006f j 1644 - 1644: 00003537 lui a0,0x3 - 1648: 07c52503 lw a0,124(a0) # 307c <_end> - 164c: fca42823 sw a0,-48(s0) - 1650: fe042503 lw a0,-32(s0) - 1654: fd842583 lw a1,-40(s0) - 1658: 00b50533 add a0,a0,a1 - 165c: 00a00593 li a1,10 - 1660: 00000097 auipc ra,0x0 - 1664: ae8080e7 jalr -1304(ra) # 1148 - 1668: 00050593 mv a1,a0 - 166c: fd042503 lw a0,-48(s0) - 1670: fdc42603 lw a2,-36(s0) - 1674: 00c585b3 add a1,a1,a2 - 1678: fd442603 lw a2,-44(s0) - 167c: 00c585b3 add a1,a1,a2 - 1680: 00b50533 add a0,a0,a1 - 1684: 00054503 lbu a0,0(a0) - 1688: 00000593 li a1,0 - 168c: 00b50a63 beq a0,a1,16a0 - 1690: 0040006f j 1694 - 1694: 00000513 li a0,0 - 1698: fea42a23 sw a0,-12(s0) - 169c: 0380006f j 16d4 - 16a0: 0040006f j 16a4 - 16a4: fd442503 lw a0,-44(s0) - 16a8: 00150513 addi a0,a0,1 - 16ac: fca42a23 sw a0,-44(s0) - 16b0: f65ff06f j 1614 - 16b4: 0040006f j 16b8 - 16b8: fd842503 lw a0,-40(s0) - 16bc: 00150513 addi a0,a0,1 - 16c0: fca42c23 sw a0,-40(s0) - 16c4: f35ff06f j 15f8 - 16c8: 00100513 li a0,1 - 16cc: fea42a23 sw a0,-12(s0) - 16d0: 0040006f j 16d4 - 16d4: ff442503 lw a0,-12(s0) - 16d8: 02812403 lw s0,40(sp) - 16dc: 02c12083 lw ra,44(sp) - 16e0: 03010113 addi sp,sp,48 - 16e4: 00008067 ret - -000016e8 : - 16e8: fe010113 addi sp,sp,-32 - 16ec: 00112e23 sw ra,28(sp) - 16f0: 00812c23 sw s0,24(sp) - 16f4: 02010413 addi s0,sp,32 - 16f8: fea42a23 sw a0,-12(s0) - 16fc: feb42823 sw a1,-16(s0) - 1700: fec407a3 sb a2,-17(s0) - 1704: fef40503 lb a0,-17(s0) - 1708: fea42423 sw a0,-24(s0) - 170c: ff042503 lw a0,-16(s0) - 1710: 00350513 addi a0,a0,3 - 1714: 05000593 li a1,80 - 1718: 00000097 auipc ra,0x0 - 171c: a30080e7 jalr -1488(ra) # 1148 - 1720: 00050593 mv a1,a0 - 1724: fe842503 lw a0,-24(s0) - 1728: ff442603 lw a2,-12(s0) - 172c: 00c585b3 add a1,a1,a2 - 1730: 20000637 lui a2,0x20000 - 1734: 01c60613 addi a2,a2,28 # 2000001c - 1738: 00c585b3 add a1,a1,a2 - 173c: 00a58023 sb a0,0(a1) - 1740: 01812403 lw s0,24(sp) - 1744: 01c12083 lw ra,28(sp) - 1748: 02010113 addi sp,sp,32 - 174c: 00008067 ret - -00001750 : - 1750: fd010113 addi sp,sp,-48 - 1754: 02112623 sw ra,44(sp) - 1758: 02812423 sw s0,40(sp) - 175c: 03010413 addi s0,sp,48 - 1760: fea42a23 sw a0,-12(s0) - 1764: feb42823 sw a1,-16(s0) - 1768: ff442503 lw a0,-12(s0) - 176c: 00c52503 lw a0,12(a0) - 1770: fea42623 sw a0,-20(s0) - 1774: fec42503 lw a0,-20(s0) - 1778: 00357513 andi a0,a0,3 - 177c: fea42423 sw a0,-24(s0) - 1780: fec42503 lw a0,-20(s0) - 1784: 00c57513 andi a0,a0,12 - 1788: 00255513 srli a0,a0,0x2 - 178c: fea42223 sw a0,-28(s0) - 1790: fec42503 lw a0,-20(s0) - 1794: 000015b7 lui a1,0x1 - 1798: ff058593 addi a1,a1,-16 # ff0 <_start-0x10> - 179c: 00b57533 and a0,a0,a1 - 17a0: 00455513 srli a0,a0,0x4 - 17a4: fea42023 sw a0,-32(s0) - 17a8: fec42503 lw a0,-20(s0) - 17ac: 01051513 slli a0,a0,0x10 - 17b0: 01c55513 srli a0,a0,0x1c - 17b4: fca42e23 sw a0,-36(s0) - 17b8: ff042503 lw a0,-16(s0) - 17bc: fca42c23 sw a0,-40(s0) - 17c0: 00000593 li a1,0 - 17c4: 02b50463 beq a0,a1,17ec - 17c8: 0040006f j 17cc - 17cc: fd842503 lw a0,-40(s0) - 17d0: 00100593 li a1,1 - 17d4: 02b50463 beq a0,a1,17fc - 17d8: 0040006f j 17dc - 17dc: fd842503 lw a0,-40(s0) - 17e0: 00200593 li a1,2 - 17e4: 02b50463 beq a0,a1,180c - 17e8: 0340006f j 181c - 17ec: fdc42503 lw a0,-36(s0) - 17f0: fff50513 addi a0,a0,-1 - 17f4: fca42e23 sw a0,-36(s0) - 17f8: 0280006f j 1820 - 17fc: fdc42503 lw a0,-36(s0) - 1800: 00150513 addi a0,a0,1 - 1804: fca42e23 sw a0,-36(s0) - 1808: 0180006f j 1820 - 180c: fe042503 lw a0,-32(s0) - 1810: 00150513 addi a0,a0,1 - 1814: fea42023 sw a0,-32(s0) - 1818: 0080006f j 1820 - 181c: 0040006f j 1820 - 1820: fdc42503 lw a0,-36(s0) - 1824: 00c51513 slli a0,a0,0xc - 1828: fe042583 lw a1,-32(s0) - 182c: 00459593 slli a1,a1,0x4 - 1830: 00b56533 or a0,a0,a1 - 1834: fe442583 lw a1,-28(s0) - 1838: 00259593 slli a1,a1,0x2 - 183c: 00b56533 or a0,a0,a1 - 1840: fe842583 lw a1,-24(s0) - 1844: 00b56533 or a0,a0,a1 - 1848: ff442583 lw a1,-12(s0) - 184c: 00a5a623 sw a0,12(a1) - 1850: 02812403 lw s0,40(sp) - 1854: 02c12083 lw ra,44(sp) - 1858: 03010113 addi sp,sp,48 - 185c: 00008067 ret - -00001860 : - 1860: fd010113 addi sp,sp,-48 - 1864: 02112623 sw ra,44(sp) - 1868: 02812423 sw s0,40(sp) - 186c: 03010413 addi s0,sp,48 - 1870: fea42823 sw a0,-16(s0) - 1874: feb42623 sw a1,-20(s0) - 1878: ff042583 lw a1,-16(s0) - 187c: fd840513 addi a0,s0,-40 - 1880: fca42a23 sw a0,-44(s0) - 1884: 00000097 auipc ra,0x0 - 1888: c9c080e7 jalr -868(ra) # 1520 - 188c: fd442503 lw a0,-44(s0) - 1890: fec42583 lw a1,-20(s0) - 1894: 00000097 auipc ra,0x0 - 1898: ebc080e7 jalr -324(ra) # 1750 - 189c: fd442503 lw a0,-44(s0) - 18a0: 00000097 auipc ra,0x0 - 18a4: b9c080e7 jalr -1124(ra) # 143c - 18a8: 00000593 li a1,0 - 18ac: 02b50e63 beq a0,a1,18e8 - 18b0: 0040006f j 18b4 - 18b4: fd840513 addi a0,s0,-40 - 18b8: 00000097 auipc ra,0x0 - 18bc: cd0080e7 jalr -816(ra) # 1588 - 18c0: 00000593 li a1,0 - 18c4: 02b50263 beq a0,a1,18e8 - 18c8: 0040006f j 18cc - 18cc: ff042503 lw a0,-16(s0) - 18d0: fd840593 addi a1,s0,-40 - 18d4: 00000097 auipc ra,0x0 - 18d8: c4c080e7 jalr -948(ra) # 1520 - 18dc: 00100513 li a0,1 - 18e0: fea42a23 sw a0,-12(s0) - 18e4: 0100006f j 18f4 - 18e8: 00000513 li a0,0 - 18ec: fea42a23 sw a0,-12(s0) - 18f0: 0040006f j 18f4 - 18f4: ff442503 lw a0,-12(s0) - 18f8: 02812403 lw s0,40(sp) - 18fc: 02c12083 lw ra,44(sp) - 1900: 03010113 addi sp,sp,48 - 1904: 00008067 ret - -00001908 : - 1908: fa010113 addi sp,sp,-96 - 190c: 04112e23 sw ra,92(sp) - 1910: 04812c23 sw s0,88(sp) - 1914: 06010413 addi s0,sp,96 - 1918: fea42a23 sw a0,-12(s0) - 191c: feb42823 sw a1,-16(s0) - 1920: ff442503 lw a0,-12(s0) - 1924: 00c52503 lw a0,12(a0) - 1928: fea42623 sw a0,-20(s0) - 192c: fec42503 lw a0,-20(s0) - 1930: 00357513 andi a0,a0,3 - 1934: fea42423 sw a0,-24(s0) - 1938: fec42503 lw a0,-20(s0) - 193c: 00c57513 andi a0,a0,12 - 1940: 00255513 srli a0,a0,0x2 - 1944: fea42223 sw a0,-28(s0) - 1948: fec42503 lw a0,-20(s0) - 194c: 000015b7 lui a1,0x1 - 1950: ff058593 addi a1,a1,-16 # ff0 <_start-0x10> - 1954: 00b57533 and a0,a0,a1 - 1958: 00455513 srli a0,a0,0x4 - 195c: fea42023 sw a0,-32(s0) - 1960: fec42503 lw a0,-20(s0) - 1964: 01051513 slli a0,a0,0x10 - 1968: 01c55513 srli a0,a0,0x1c - 196c: fca42e23 sw a0,-36(s0) - 1970: fdc42503 lw a0,-36(s0) - 1974: fe042583 lw a1,-32(s0) - 1978: fe842603 lw a2,-24(s0) - 197c: fe442683 lw a3,-28(s0) - 1980: 00000097 auipc ra,0x0 - 1984: 858080e7 jalr -1960(ra) # 11d8 - 1988: fca42c23 sw a0,-40(s0) - 198c: 00000593 li a1,0 - 1990: fcb42a23 sw a1,-44(s0) - 1994: fcb42823 sw a1,-48(s0) - 1998: fcb42623 sw a1,-52(s0) - 199c: ff042503 lw a0,-16(s0) - 19a0: 0cb50463 beq a0,a1,1a68 - 19a4: 0040006f j 19a8 - 19a8: 00000513 li a0,0 - 19ac: fca42423 sw a0,-56(s0) - 19b0: 0040006f j 19b4 - 19b4: fc842583 lw a1,-56(s0) - 19b8: fe842503 lw a0,-24(s0) - 19bc: 0ab56463 bltu a0,a1,1a64 - 19c0: 0040006f j 19c4 - 19c4: 00000513 li a0,0 - 19c8: fca42223 sw a0,-60(s0) - 19cc: 0040006f j 19d0 - 19d0: fc442583 lw a1,-60(s0) - 19d4: fe442503 lw a0,-28(s0) - 19d8: 06b56c63 bltu a0,a1,1a50 - 19dc: 0040006f j 19e0 - 19e0: fc442603 lw a2,-60(s0) - 19e4: 00261593 slli a1,a2,0x2 - 19e8: fcc40513 addi a0,s0,-52 - 19ec: faa42a23 sw a0,-76(s0) - 19f0: 00b50533 add a0,a0,a1 - 19f4: 00052503 lw a0,0(a0) - 19f8: faa42c23 sw a0,-72(s0) - 19fc: ff442503 lw a0,-12(s0) - 1a00: fc842583 lw a1,-56(s0) - 1a04: 00000097 auipc ra,0x0 - 1a08: 9e4080e7 jalr -1564(ra) # 13e8 - 1a0c: fb442583 lw a1,-76(s0) - 1a10: 00050613 mv a2,a0 - 1a14: fb842503 lw a0,-72(s0) - 1a18: fe842683 lw a3,-24(s0) - 1a1c: fc842703 lw a4,-56(s0) - 1a20: 40e686b3 sub a3,a3,a4 - 1a24: 00d61633 sll a2,a2,a3 - 1a28: 00c56533 or a0,a0,a2 - 1a2c: fc442603 lw a2,-60(s0) - 1a30: 00261613 slli a2,a2,0x2 - 1a34: 00c585b3 add a1,a1,a2 - 1a38: 00a5a023 sw a0,0(a1) - 1a3c: 0040006f j 1a40 - 1a40: fc442503 lw a0,-60(s0) - 1a44: 00150513 addi a0,a0,1 - 1a48: fca42223 sw a0,-60(s0) - 1a4c: f85ff06f j 19d0 - 1a50: 0040006f j 1a54 - 1a54: fc842503 lw a0,-56(s0) - 1a58: 00150513 addi a0,a0,1 - 1a5c: fca42423 sw a0,-56(s0) - 1a60: f55ff06f j 19b4 - 1a64: 0cc0006f j 1b30 - 1a68: 00000513 li a0,0 - 1a6c: fca42023 sw a0,-64(s0) - 1a70: 0040006f j 1a74 - 1a74: fc042583 lw a1,-64(s0) - 1a78: fe842503 lw a0,-24(s0) - 1a7c: 0ab56863 bltu a0,a1,1b2c - 1a80: 0040006f j 1a84 - 1a84: 00000513 li a0,0 - 1a88: faa42e23 sw a0,-68(s0) - 1a8c: 0040006f j 1a90 - 1a90: fbc42583 lw a1,-68(s0) - 1a94: fe442503 lw a0,-28(s0) - 1a98: 08b56063 bltu a0,a1,1b18 - 1a9c: 0040006f j 1aa0 - 1aa0: fe442503 lw a0,-28(s0) - 1aa4: fbc42603 lw a2,-68(s0) - 1aa8: 40c50533 sub a0,a0,a2 - 1aac: 00251593 slli a1,a0,0x2 - 1ab0: fcc40513 addi a0,s0,-52 - 1ab4: faa42623 sw a0,-84(s0) - 1ab8: 00b50533 add a0,a0,a1 - 1abc: 00052503 lw a0,0(a0) - 1ac0: faa42823 sw a0,-80(s0) - 1ac4: ff442503 lw a0,-12(s0) - 1ac8: fc042583 lw a1,-64(s0) - 1acc: 00000097 auipc ra,0x0 - 1ad0: 91c080e7 jalr -1764(ra) # 13e8 - 1ad4: fac42583 lw a1,-84(s0) - 1ad8: 00050613 mv a2,a0 - 1adc: fb042503 lw a0,-80(s0) - 1ae0: fc042683 lw a3,-64(s0) - 1ae4: 00d61633 sll a2,a2,a3 - 1ae8: 00c56533 or a0,a0,a2 - 1aec: fe442603 lw a2,-28(s0) - 1af0: fbc42683 lw a3,-68(s0) - 1af4: 40d60633 sub a2,a2,a3 - 1af8: 00261613 slli a2,a2,0x2 - 1afc: 00c585b3 add a1,a1,a2 - 1b00: 00a5a023 sw a0,0(a1) - 1b04: 0040006f j 1b08 - 1b08: fbc42503 lw a0,-68(s0) - 1b0c: 00150513 addi a0,a0,1 - 1b10: faa42e23 sw a0,-68(s0) - 1b14: f7dff06f j 1a90 - 1b18: 0040006f j 1b1c - 1b1c: fc042503 lw a0,-64(s0) - 1b20: 00150513 addi a0,a0,1 - 1b24: fca42023 sw a0,-64(s0) - 1b28: f4dff06f j 1a74 - 1b2c: 0040006f j 1b30 - 1b30: fcc42503 lw a0,-52(s0) - 1b34: ff442583 lw a1,-12(s0) - 1b38: 00a5a023 sw a0,0(a1) - 1b3c: fd042503 lw a0,-48(s0) - 1b40: ff442583 lw a1,-12(s0) - 1b44: 00a5a223 sw a0,4(a1) - 1b48: fd442503 lw a0,-44(s0) - 1b4c: ff442583 lw a1,-12(s0) - 1b50: 00a5a423 sw a0,8(a1) - 1b54: fd842503 lw a0,-40(s0) - 1b58: ff442583 lw a1,-12(s0) - 1b5c: 00a5a623 sw a0,12(a1) - 1b60: 05812403 lw s0,88(sp) - 1b64: 05c12083 lw ra,92(sp) - 1b68: 06010113 addi sp,sp,96 - 1b6c: 00008067 ret - -00001b70 : - 1b70: fc010113 addi sp,sp,-64 - 1b74: 02112e23 sw ra,60(sp) - 1b78: 02812c23 sw s0,56(sp) - 1b7c: 04010413 addi s0,sp,64 - 1b80: fea42a23 sw a0,-12(s0) - 1b84: feb42823 sw a1,-16(s0) - 1b88: ff442583 lw a1,-12(s0) - 1b8c: fe040513 addi a0,s0,-32 - 1b90: fca42423 sw a0,-56(s0) - 1b94: 00000097 auipc ra,0x0 - 1b98: 98c080e7 jalr -1652(ra) # 1520 - 1b9c: fc842503 lw a0,-56(s0) - 1ba0: ff042583 lw a1,-16(s0) - 1ba4: 00000097 auipc ra,0x0 - 1ba8: d64080e7 jalr -668(ra) # 1908 - 1bac: fc842503 lw a0,-56(s0) - 1bb0: 00000097 auipc ra,0x0 - 1bb4: 88c080e7 jalr -1908(ra) # 143c - 1bb8: 00000593 li a1,0 - 1bbc: 02b50a63 beq a0,a1,1bf0 - 1bc0: 0040006f j 1bc4 - 1bc4: fe040513 addi a0,s0,-32 - 1bc8: 00000097 auipc ra,0x0 - 1bcc: 9c0080e7 jalr -1600(ra) # 1588 - 1bd0: 00000593 li a1,0 - 1bd4: 00b50e63 beq a0,a1,1bf0 - 1bd8: 0040006f j 1bdc - 1bdc: ff442503 lw a0,-12(s0) - 1be0: fe040593 addi a1,s0,-32 - 1be4: 00000097 auipc ra,0x0 - 1be8: 93c080e7 jalr -1732(ra) # 1520 - 1bec: 0dc0006f j 1cc8 - 1bf0: fec42503 lw a0,-20(s0) - 1bf4: fca42e23 sw a0,-36(s0) - 1bf8: fdc42503 lw a0,-36(s0) - 1bfc: 00357513 andi a0,a0,3 - 1c00: fca42c23 sw a0,-40(s0) - 1c04: fdc42503 lw a0,-36(s0) - 1c08: 00c57513 andi a0,a0,12 - 1c0c: 00255513 srli a0,a0,0x2 - 1c10: fca42a23 sw a0,-44(s0) - 1c14: fdc42503 lw a0,-36(s0) - 1c18: 000015b7 lui a1,0x1 - 1c1c: ff058593 addi a1,a1,-16 # ff0 <_start-0x10> - 1c20: 00b57533 and a0,a0,a1 - 1c24: 00455513 srli a0,a0,0x4 - 1c28: fca42823 sw a0,-48(s0) - 1c2c: fdc42503 lw a0,-36(s0) - 1c30: 01051513 slli a0,a0,0x10 - 1c34: 01c55513 srli a0,a0,0x1c - 1c38: fca42623 sw a0,-52(s0) - 1c3c: fcc42503 lw a0,-52(s0) - 1c40: fd442583 lw a1,-44(s0) - 1c44: 00b50533 add a0,a0,a1 - 1c48: 00a00593 li a1,10 - 1c4c: 00b56e63 bltu a0,a1,1c68 - 1c50: 0040006f j 1c54 - 1c54: fd442583 lw a1,-44(s0) - 1c58: 00900513 li a0,9 - 1c5c: 40b50533 sub a0,a0,a1 - 1c60: fca42623 sw a0,-52(s0) - 1c64: 0040006f j 1c68 - 1c68: fcc42503 lw a0,-52(s0) - 1c6c: fd042583 lw a1,-48(s0) - 1c70: fd442603 lw a2,-44(s0) - 1c74: fd842683 lw a3,-40(s0) - 1c78: fffff097 auipc ra,0xfffff - 1c7c: 560080e7 jalr 1376(ra) # 11d8 - 1c80: fea42623 sw a0,-20(s0) - 1c84: fe040513 addi a0,s0,-32 - 1c88: fffff097 auipc ra,0xfffff - 1c8c: 7b4080e7 jalr 1972(ra) # 143c - 1c90: 00000593 li a1,0 - 1c94: 02b50a63 beq a0,a1,1cc8 - 1c98: 0040006f j 1c9c - 1c9c: fe040513 addi a0,s0,-32 - 1ca0: 00000097 auipc ra,0x0 - 1ca4: 8e8080e7 jalr -1816(ra) # 1588 - 1ca8: 00000593 li a1,0 - 1cac: 00b50e63 beq a0,a1,1cc8 - 1cb0: 0040006f j 1cb4 - 1cb4: ff442503 lw a0,-12(s0) - 1cb8: fe040593 addi a1,s0,-32 - 1cbc: 00000097 auipc ra,0x0 - 1cc0: 864080e7 jalr -1948(ra) # 1520 - 1cc4: 0040006f j 1cc8 - 1cc8: 03812403 lw s0,56(sp) - 1ccc: 03c12083 lw ra,60(sp) - 1cd0: 04010113 addi sp,sp,64 - 1cd4: 00008067 ret - -00001cd8 : - 1cd8: ff010113 addi sp,sp,-16 - 1cdc: 00112623 sw ra,12(sp) - 1ce0: 00812423 sw s0,8(sp) - 1ce4: 01010413 addi s0,sp,16 - 1ce8: 00000513 li a0,0 - 1cec: fea42a23 sw a0,-12(s0) - 1cf0: 01600513 li a0,22 - 1cf4: 00a00593 li a1,10 - 1cf8: fffff097 auipc ra,0xfffff - 1cfc: 450080e7 jalr 1104(ra) # 1148 - 1d00: fea42823 sw a0,-16(s0) - 1d04: 0040006f j 1d08 - 1d08: ff442503 lw a0,-12(s0) - 1d0c: ff042583 lw a1,-16(s0) - 1d10: 02b55a63 bge a0,a1,1d44 - 1d14: 0040006f j 1d18 - 1d18: 00003537 lui a0,0x3 - 1d1c: 07c52503 lw a0,124(a0) # 307c <_end> - 1d20: ff442583 lw a1,-12(s0) - 1d24: 00b505b3 add a1,a0,a1 - 1d28: 00000513 li a0,0 - 1d2c: 00a58023 sb a0,0(a1) - 1d30: 0040006f j 1d34 - 1d34: ff442503 lw a0,-12(s0) - 1d38: 00150513 addi a0,a0,1 - 1d3c: fea42a23 sw a0,-12(s0) - 1d40: fc9ff06f j 1d08 - 1d44: 00812403 lw s0,8(sp) - 1d48: 00c12083 lw ra,12(sp) - 1d4c: 01010113 addi sp,sp,16 - 1d50: 00008067 ret - -00001d54 : - 1d54: fd010113 addi sp,sp,-48 - 1d58: 02112623 sw ra,44(sp) - 1d5c: 02812423 sw s0,40(sp) - 1d60: 03010413 addi s0,sp,48 - 1d64: fea42a23 sw a0,-12(s0) - 1d68: ff442503 lw a0,-12(s0) - 1d6c: 00c52503 lw a0,12(a0) - 1d70: fea42823 sw a0,-16(s0) - 1d74: ff042503 lw a0,-16(s0) - 1d78: 00357513 andi a0,a0,3 - 1d7c: fea42623 sw a0,-20(s0) - 1d80: ff042503 lw a0,-16(s0) - 1d84: 00c57513 andi a0,a0,12 - 1d88: 00255513 srli a0,a0,0x2 - 1d8c: fea42423 sw a0,-24(s0) - 1d90: ff042503 lw a0,-16(s0) - 1d94: 000015b7 lui a1,0x1 - 1d98: ff058593 addi a1,a1,-16 # ff0 <_start-0x10> - 1d9c: 00b57533 and a0,a0,a1 - 1da0: 00455513 srli a0,a0,0x4 - 1da4: fea42223 sw a0,-28(s0) - 1da8: ff042503 lw a0,-16(s0) - 1dac: 01051513 slli a0,a0,0x10 - 1db0: 01c55513 srli a0,a0,0x1c - 1db4: fea42023 sw a0,-32(s0) - 1db8: 00000513 li a0,0 - 1dbc: fca42e23 sw a0,-36(s0) - 1dc0: 0040006f j 1dc4 - 1dc4: fdc42583 lw a1,-36(s0) - 1dc8: fec42503 lw a0,-20(s0) - 1dcc: 0ab56c63 bltu a0,a1,1e84 - 1dd0: 0040006f j 1dd4 - 1dd4: 00000513 li a0,0 - 1dd8: fca42c23 sw a0,-40(s0) - 1ddc: 0040006f j 1de0 - 1de0: fd842583 lw a1,-40(s0) - 1de4: fe842503 lw a0,-24(s0) - 1de8: 08b56463 bltu a0,a1,1e70 - 1dec: 0040006f j 1df0 - 1df0: ff442503 lw a0,-12(s0) - 1df4: fdc42583 lw a1,-36(s0) - 1df8: fd842603 lw a2,-40(s0) - 1dfc: fffff097 auipc ra,0xfffff - 1e00: 5ec080e7 jalr 1516(ra) # 13e8 - 1e04: 00000593 li a1,0 - 1e08: 04b50a63 beq a0,a1,1e5c - 1e0c: 0040006f j 1e10 - 1e10: 00003537 lui a0,0x3 - 1e14: 07c52503 lw a0,124(a0) # 307c <_end> - 1e18: fca42a23 sw a0,-44(s0) - 1e1c: fe442503 lw a0,-28(s0) - 1e20: fdc42583 lw a1,-36(s0) - 1e24: 00b50533 add a0,a0,a1 - 1e28: 00a00593 li a1,10 - 1e2c: fffff097 auipc ra,0xfffff - 1e30: 31c080e7 jalr 796(ra) # 1148 - 1e34: 00050593 mv a1,a0 - 1e38: fd442503 lw a0,-44(s0) - 1e3c: fe042603 lw a2,-32(s0) - 1e40: 00c585b3 add a1,a1,a2 - 1e44: fd842603 lw a2,-40(s0) - 1e48: 00c585b3 add a1,a1,a2 - 1e4c: 00b505b3 add a1,a0,a1 - 1e50: 00100513 li a0,1 - 1e54: 00a58023 sb a0,0(a1) - 1e58: 0040006f j 1e5c - 1e5c: 0040006f j 1e60 - 1e60: fd842503 lw a0,-40(s0) - 1e64: 00150513 addi a0,a0,1 - 1e68: fca42c23 sw a0,-40(s0) - 1e6c: f75ff06f j 1de0 - 1e70: 0040006f j 1e74 - 1e74: fdc42503 lw a0,-36(s0) - 1e78: 00150513 addi a0,a0,1 - 1e7c: fca42e23 sw a0,-36(s0) - 1e80: f45ff06f j 1dc4 - 1e84: 02812403 lw s0,40(sp) - 1e88: 02c12083 lw ra,44(sp) - 1e8c: 03010113 addi sp,sp,48 - 1e90: 00008067 ret - -00001e94 : - 1e94: fe010113 addi sp,sp,-32 - 1e98: 00112e23 sw ra,28(sp) - 1e9c: 00812c23 sw s0,24(sp) - 1ea0: 02010413 addi s0,sp,32 - 1ea4: 00800513 li a0,8 - 1ea8: fea42a23 sw a0,-12(s0) - 1eac: ff442503 lw a0,-12(s0) - 1eb0: 00150593 addi a1,a0,1 - 1eb4: feb42a23 sw a1,-12(s0) - 1eb8: ffe00593 li a1,-2 - 1ebc: feb42223 sw a1,-28(s0) - 1ec0: 05300613 li a2,83 - 1ec4: 00000097 auipc ra,0x0 - 1ec8: 824080e7 jalr -2012(ra) # 16e8 - 1ecc: fe442583 lw a1,-28(s0) - 1ed0: ff442503 lw a0,-12(s0) - 1ed4: 00150613 addi a2,a0,1 - 1ed8: fec42a23 sw a2,-12(s0) - 1edc: 04300613 li a2,67 - 1ee0: 00000097 auipc ra,0x0 - 1ee4: 808080e7 jalr -2040(ra) # 16e8 - 1ee8: fe442583 lw a1,-28(s0) - 1eec: ff442503 lw a0,-12(s0) - 1ef0: 00150613 addi a2,a0,1 - 1ef4: fec42a23 sw a2,-12(s0) - 1ef8: 04f00613 li a2,79 - 1efc: fffff097 auipc ra,0xfffff - 1f00: 7ec080e7 jalr 2028(ra) # 16e8 - 1f04: fe442583 lw a1,-28(s0) - 1f08: ff442503 lw a0,-12(s0) - 1f0c: 00150613 addi a2,a0,1 - 1f10: fec42a23 sw a2,-12(s0) - 1f14: 05200613 li a2,82 - 1f18: fffff097 auipc ra,0xfffff - 1f1c: 7d0080e7 jalr 2000(ra) # 16e8 - 1f20: fe442583 lw a1,-28(s0) - 1f24: ff442503 lw a0,-12(s0) - 1f28: 00150613 addi a2,a0,1 - 1f2c: fec42a23 sw a2,-12(s0) - 1f30: 04500613 li a2,69 - 1f34: fffff097 auipc ra,0xfffff - 1f38: 7b4080e7 jalr 1972(ra) # 16e8 - 1f3c: 00000513 li a0,0 - 1f40: fea42823 sw a0,-16(s0) - 1f44: 0040006f j 1f48 - 1f48: ff042583 lw a1,-16(s0) - 1f4c: 00400513 li a0,4 - 1f50: 06b54a63 blt a0,a1,1fc4 - 1f54: 0040006f j 1f58 - 1f58: ff042503 lw a0,-16(s0) - 1f5c: 00251593 slli a1,a0,0x2 - 1f60: 00f00513 li a0,15 - 1f64: 00b51533 sll a0,a0,a1 - 1f68: fea42623 sw a0,-20(s0) - 1f6c: 00003537 lui a0,0x3 - 1f70: 08052503 lw a0,128(a0) # 3080 - 1f74: fec42583 lw a1,-20(s0) - 1f78: 00b57533 and a0,a0,a1 - 1f7c: ff042583 lw a1,-16(s0) - 1f80: 00259593 slli a1,a1,0x2 - 1f84: 00b55533 srl a0,a0,a1 - 1f88: fea42423 sw a0,-24(s0) - 1f8c: ff042583 lw a1,-16(s0) - 1f90: 00c00513 li a0,12 - 1f94: 40b50533 sub a0,a0,a1 - 1f98: fe842583 lw a1,-24(s0) - 1f9c: 03058593 addi a1,a1,48 - 1fa0: 0ff5f613 andi a2,a1,255 - 1fa4: fff00593 li a1,-1 - 1fa8: fffff097 auipc ra,0xfffff - 1fac: 740080e7 jalr 1856(ra) # 16e8 - 1fb0: 0040006f j 1fb4 - 1fb4: ff042503 lw a0,-16(s0) - 1fb8: 00150513 addi a0,a0,1 - 1fbc: fea42823 sw a0,-16(s0) - 1fc0: f89ff06f j 1f48 - 1fc4: 01812403 lw s0,24(sp) - 1fc8: 01c12083 lw ra,28(sp) - 1fcc: 02010113 addi sp,sp,32 - 1fd0: 00008067 ret - -00001fd4 : - 1fd4: fc010113 addi sp,sp,-64 - 1fd8: 02112e23 sw ra,60(sp) - 1fdc: 02812c23 sw s0,56(sp) - 1fe0: 04010413 addi s0,sp,64 - 1fe4: 00000513 li a0,0 - 1fe8: fea42a23 sw a0,-12(s0) - 1fec: 0040006f j 1ff0 - 1ff0: ff442583 lw a1,-12(s0) - 1ff4: 01500513 li a0,21 - 1ff8: 10b54463 blt a0,a1,2100 - 1ffc: 0040006f j 2000 - 2000: 00000513 li a0,0 - 2004: fea42823 sw a0,-16(s0) - 2008: 0040006f j 200c - 200c: ff042583 lw a1,-16(s0) - 2010: 00900513 li a0,9 - 2014: 0cb54c63 blt a0,a1,20ec - 2018: 0040006f j 201c - 201c: 00003537 lui a0,0x3 - 2020: 07c52503 lw a0,124(a0) # 307c <_end> - 2024: fca42823 sw a0,-48(s0) - 2028: ff442503 lw a0,-12(s0) - 202c: 00a00593 li a1,10 - 2030: fffff097 auipc ra,0xfffff - 2034: 118080e7 jalr 280(ra) # 1148 - 2038: 00050593 mv a1,a0 - 203c: fd042503 lw a0,-48(s0) - 2040: ff042603 lw a2,-16(s0) - 2044: 00c585b3 add a1,a1,a2 - 2048: 00b50533 add a0,a0,a1 - 204c: 00054503 lbu a0,0(a0) - 2050: 00100593 li a1,1 - 2054: 04b51263 bne a0,a1,2098 - 2058: 0040006f j 205c - 205c: ff042503 lw a0,-16(s0) - 2060: 00151513 slli a0,a0,0x1 - 2064: 00156513 ori a0,a0,1 - 2068: ff442583 lw a1,-12(s0) - 206c: 05b00613 li a2,91 - 2070: fffff097 auipc ra,0xfffff - 2074: 678080e7 jalr 1656(ra) # 16e8 - 2078: ff042503 lw a0,-16(s0) - 207c: 00151513 slli a0,a0,0x1 - 2080: 00250513 addi a0,a0,2 - 2084: ff442583 lw a1,-12(s0) - 2088: 05d00613 li a2,93 - 208c: fffff097 auipc ra,0xfffff - 2090: 65c080e7 jalr 1628(ra) # 16e8 - 2094: 0440006f j 20d8 - 2098: ff042503 lw a0,-16(s0) - 209c: 00151513 slli a0,a0,0x1 - 20a0: 00156513 ori a0,a0,1 - 20a4: ff442583 lw a1,-12(s0) - 20a8: 02000613 li a2,32 - 20ac: fcc42623 sw a2,-52(s0) - 20b0: fffff097 auipc ra,0xfffff - 20b4: 638080e7 jalr 1592(ra) # 16e8 - 20b8: fcc42603 lw a2,-52(s0) - 20bc: ff042503 lw a0,-16(s0) - 20c0: 00151513 slli a0,a0,0x1 - 20c4: 00250513 addi a0,a0,2 - 20c8: ff442583 lw a1,-12(s0) - 20cc: fffff097 auipc ra,0xfffff - 20d0: 61c080e7 jalr 1564(ra) # 16e8 - 20d4: 0040006f j 20d8 - 20d8: 0040006f j 20dc - 20dc: ff042503 lw a0,-16(s0) - 20e0: 00150513 addi a0,a0,1 - 20e4: fea42823 sw a0,-16(s0) - 20e8: f25ff06f j 200c - 20ec: 0040006f j 20f0 - 20f0: ff442503 lw a0,-12(s0) - 20f4: 00150513 addi a0,a0,1 - 20f8: fea42a23 sw a0,-12(s0) - 20fc: ef5ff06f j 1ff0 - 2100: 00003537 lui a0,0x3 - 2104: 06c50513 addi a0,a0,108 # 306c - 2108: 00c52503 lw a0,12(a0) - 210c: fea42623 sw a0,-20(s0) - 2110: fec42503 lw a0,-20(s0) - 2114: 00357513 andi a0,a0,3 - 2118: fea42423 sw a0,-24(s0) - 211c: fec42503 lw a0,-20(s0) - 2120: 00c57513 andi a0,a0,12 - 2124: 00255513 srli a0,a0,0x2 - 2128: fea42223 sw a0,-28(s0) - 212c: fec42503 lw a0,-20(s0) - 2130: 000015b7 lui a1,0x1 - 2134: ff058593 addi a1,a1,-16 # ff0 <_start-0x10> - 2138: 00b57533 and a0,a0,a1 - 213c: 00455513 srli a0,a0,0x4 - 2140: fea42023 sw a0,-32(s0) - 2144: fec42503 lw a0,-20(s0) - 2148: 01051513 slli a0,a0,0x10 - 214c: 01c55513 srli a0,a0,0x1c - 2150: fca42e23 sw a0,-36(s0) - 2154: 00000513 li a0,0 - 2158: fca42c23 sw a0,-40(s0) - 215c: 0040006f j 2160 - 2160: fd842583 lw a1,-40(s0) - 2164: fe842503 lw a0,-24(s0) - 2168: 0cb56663 bltu a0,a1,2234 - 216c: 0040006f j 2170 - 2170: 00000513 li a0,0 - 2174: fca42a23 sw a0,-44(s0) - 2178: 0040006f j 217c - 217c: fd442583 lw a1,-44(s0) - 2180: fe442503 lw a0,-28(s0) - 2184: 08b56e63 bltu a0,a1,2220 - 2188: 0040006f j 218c - 218c: fd842583 lw a1,-40(s0) - 2190: fd442603 lw a2,-44(s0) - 2194: 00003537 lui a0,0x3 - 2198: 06c50513 addi a0,a0,108 # 306c - 219c: fffff097 auipc ra,0xfffff - 21a0: 24c080e7 jalr 588(ra) # 13e8 - 21a4: 00000593 li a1,0 - 21a8: 06b50263 beq a0,a1,220c - 21ac: 0040006f j 21b0 - 21b0: fd442503 lw a0,-44(s0) - 21b4: fdc42583 lw a1,-36(s0) - 21b8: 00b50533 add a0,a0,a1 - 21bc: 00151513 slli a0,a0,0x1 - 21c0: 00156513 ori a0,a0,1 - 21c4: fd842583 lw a1,-40(s0) - 21c8: fe042603 lw a2,-32(s0) - 21cc: 00c585b3 add a1,a1,a2 - 21d0: 05b00613 li a2,91 - 21d4: fffff097 auipc ra,0xfffff - 21d8: 514080e7 jalr 1300(ra) # 16e8 - 21dc: fd442503 lw a0,-44(s0) - 21e0: fdc42583 lw a1,-36(s0) - 21e4: 00b50533 add a0,a0,a1 - 21e8: 00151513 slli a0,a0,0x1 - 21ec: 00250513 addi a0,a0,2 - 21f0: fd842583 lw a1,-40(s0) - 21f4: fe042603 lw a2,-32(s0) - 21f8: 00c585b3 add a1,a1,a2 - 21fc: 05d00613 li a2,93 - 2200: fffff097 auipc ra,0xfffff - 2204: 4e8080e7 jalr 1256(ra) # 16e8 - 2208: 0040006f j 220c - 220c: 0040006f j 2210 - 2210: fd442503 lw a0,-44(s0) - 2214: 00150513 addi a0,a0,1 - 2218: fca42a23 sw a0,-44(s0) - 221c: f61ff06f j 217c - 2220: 0040006f j 2224 - 2224: fd842503 lw a0,-40(s0) - 2228: 00150513 addi a0,a0,1 - 222c: fca42c23 sw a0,-40(s0) - 2230: f31ff06f j 2160 - 2234: 00000097 auipc ra,0x0 - 2238: c60080e7 jalr -928(ra) # 1e94 - 223c: 03812403 lw s0,56(sp) - 2240: 03c12083 lw ra,60(sp) - 2244: 04010113 addi sp,sp,64 - 2248: 00008067 ret - -0000224c : - 224c: fe010113 addi sp,sp,-32 - 2250: 00112e23 sw ra,28(sp) - 2254: 00812c23 sw s0,24(sp) - 2258: 02010413 addi s0,sp,32 - 225c: fea42a23 sw a0,-12(s0) - 2260: ff442603 lw a2,-12(s0) - 2264: 000035b7 lui a1,0x3 - 2268: 0805a503 lw a0,128(a1) # 3080 - 226c: 00c50533 add a0,a0,a2 - 2270: 08a5a023 sw a0,128(a1) - 2274: 00000513 li a0,0 - 2278: fea42823 sw a0,-16(s0) - 227c: fea42623 sw a0,-20(s0) - 2280: 0040006f j 2284 - 2284: ff042583 lw a1,-16(s0) - 2288: 01f00513 li a0,31 - 228c: 0ab56e63 bltu a0,a1,2348 - 2290: 0040006f j 2294 - 2294: ff042583 lw a1,-16(s0) - 2298: 00f00513 li a0,15 - 229c: 00b51533 sll a0,a0,a1 - 22a0: fea42423 sw a0,-24(s0) - 22a4: 00003537 lui a0,0x3 - 22a8: 08052503 lw a0,128(a0) # 3080 - 22ac: fe842583 lw a1,-24(s0) - 22b0: 00b57533 and a0,a0,a1 - 22b4: ff042583 lw a1,-16(s0) - 22b8: 00b55533 srl a0,a0,a1 - 22bc: fea42223 sw a0,-28(s0) - 22c0: fec42583 lw a1,-20(s0) - 22c4: fe442503 lw a0,-28(s0) - 22c8: 00b50533 add a0,a0,a1 - 22cc: fea42223 sw a0,-28(s0) - 22d0: fe442503 lw a0,-28(s0) - 22d4: 00a00593 li a1,10 - 22d8: 02b56063 bltu a0,a1,22f8 - 22dc: 0040006f j 22e0 - 22e0: 00100513 li a0,1 - 22e4: fea42623 sw a0,-20(s0) - 22e8: fe442503 lw a0,-28(s0) - 22ec: ff650513 addi a0,a0,-10 - 22f0: fea42223 sw a0,-28(s0) - 22f4: 0100006f j 2304 - 22f8: 00000513 li a0,0 - 22fc: fea42623 sw a0,-20(s0) - 2300: 0040006f j 2304 - 2304: fe842503 lw a0,-24(s0) - 2308: fff54613 not a2,a0 - 230c: 000035b7 lui a1,0x3 - 2310: 0805a503 lw a0,128(a1) # 3080 - 2314: 00c57533 and a0,a0,a2 - 2318: 08a5a023 sw a0,128(a1) - 231c: fe442503 lw a0,-28(s0) - 2320: ff042603 lw a2,-16(s0) - 2324: 00c51633 sll a2,a0,a2 - 2328: 0805a503 lw a0,128(a1) - 232c: 00c56533 or a0,a0,a2 - 2330: 08a5a023 sw a0,128(a1) - 2334: 0040006f j 2338 - 2338: ff042503 lw a0,-16(s0) - 233c: 00450513 addi a0,a0,4 - 2340: fea42823 sw a0,-16(s0) - 2344: f41ff06f j 2284 - 2348: 01812403 lw s0,24(sp) - 234c: 01c12083 lw ra,28(sp) - 2350: 02010113 addi sp,sp,32 - 2354: 00008067 ret - -00002358 : - 2358: fc010113 addi sp,sp,-64 - 235c: 02112e23 sw ra,60(sp) - 2360: 02812c23 sw s0,56(sp) - 2364: 04010413 addi s0,sp,64 - 2368: 00003537 lui a0,0x3 - 236c: 06c50513 addi a0,a0,108 # 306c - 2370: 00c52583 lw a1,12(a0) - 2374: 00001637 lui a2,0x1 - 2378: ff060613 addi a2,a2,-16 # ff0 <_start-0x10> - 237c: 00c5f5b3 and a1,a1,a2 - 2380: 0045d593 srli a1,a1,0x4 - 2384: feb42a23 sw a1,-12(s0) - 2388: 00c52503 lw a0,12(a0) - 238c: 00357513 andi a0,a0,3 - 2390: fea42823 sw a0,-16(s0) - 2394: ff442503 lw a0,-12(s0) - 2398: ff042583 lw a1,-16(s0) - 239c: 00b50533 add a0,a0,a1 - 23a0: fea42623 sw a0,-20(s0) - 23a4: 0040006f j 23a8 - 23a8: fec42503 lw a0,-20(s0) - 23ac: ff442583 lw a1,-12(s0) - 23b0: 1ab56c63 bltu a0,a1,2568 - 23b4: 0040006f j 23b8 - 23b8: 00000513 li a0,0 - 23bc: fea42423 sw a0,-24(s0) - 23c0: fea42223 sw a0,-28(s0) - 23c4: 0040006f j 23c8 - 23c8: fe442583 lw a1,-28(s0) - 23cc: 00900513 li a0,9 - 23d0: 06b54663 blt a0,a1,243c - 23d4: 0040006f j 23d8 - 23d8: 00003537 lui a0,0x3 - 23dc: 07c52503 lw a0,124(a0) # 307c <_end> - 23e0: fca42c23 sw a0,-40(s0) - 23e4: fec42503 lw a0,-20(s0) - 23e8: 00a00593 li a1,10 - 23ec: fffff097 auipc ra,0xfffff - 23f0: d5c080e7 jalr -676(ra) # 1148 - 23f4: 00050593 mv a1,a0 - 23f8: fd842503 lw a0,-40(s0) - 23fc: fe442603 lw a2,-28(s0) - 2400: 00c585b3 add a1,a1,a2 - 2404: 00b50533 add a0,a0,a1 - 2408: 00054503 lbu a0,0(a0) - 240c: 00000593 li a1,0 - 2410: 00b50c63 beq a0,a1,2428 - 2414: 0040006f j 2418 - 2418: fe842503 lw a0,-24(s0) - 241c: 00150513 addi a0,a0,1 - 2420: fea42423 sw a0,-24(s0) - 2424: 0040006f j 2428 - 2428: 0040006f j 242c - 242c: fe442503 lw a0,-28(s0) - 2430: 00150513 addi a0,a0,1 - 2434: fea42223 sw a0,-28(s0) - 2438: f91ff06f j 23c8 - 243c: fe842503 lw a0,-24(s0) - 2440: 00a00593 li a1,10 - 2444: 10b51863 bne a0,a1,2554 - 2448: 0040006f j 244c - 244c: 00100513 li a0,1 - 2450: 00000097 auipc ra,0x0 - 2454: dfc080e7 jalr -516(ra) # 224c - 2458: fec42503 lw a0,-20(s0) - 245c: fff50513 addi a0,a0,-1 - 2460: fea42023 sw a0,-32(s0) - 2464: 0040006f j 2468 - 2468: fe042583 lw a1,-32(s0) - 246c: 00000513 li a0,0 - 2470: 0cb55463 bge a0,a1,2538 - 2474: 0040006f j 2478 - 2478: 00000513 li a0,0 - 247c: fca42e23 sw a0,-36(s0) - 2480: 0040006f j 2484 - 2484: fdc42583 lw a1,-36(s0) - 2488: 00900513 li a0,9 - 248c: 08b54c63 blt a0,a1,2524 - 2490: 0040006f j 2494 - 2494: 00003537 lui a0,0x3 - 2498: fca42623 sw a0,-52(s0) - 249c: 07c52503 lw a0,124(a0) # 307c <_end> - 24a0: fca42223 sw a0,-60(s0) - 24a4: fe042503 lw a0,-32(s0) - 24a8: 00a00593 li a1,10 - 24ac: fcb42423 sw a1,-56(s0) - 24b0: fffff097 auipc ra,0xfffff - 24b4: c98080e7 jalr -872(ra) # 1148 - 24b8: fc442603 lw a2,-60(s0) - 24bc: fc842583 lw a1,-56(s0) - 24c0: 00050693 mv a3,a0 - 24c4: fcc42503 lw a0,-52(s0) - 24c8: fdc42703 lw a4,-36(s0) - 24cc: 00e686b3 add a3,a3,a4 - 24d0: 00d60633 add a2,a2,a3 - 24d4: 00060603 lb a2,0(a2) - 24d8: fcc42a23 sw a2,-44(s0) - 24dc: 07c52503 lw a0,124(a0) - 24e0: fca42823 sw a0,-48(s0) - 24e4: fe042503 lw a0,-32(s0) - 24e8: 00150513 addi a0,a0,1 - 24ec: fffff097 auipc ra,0xfffff - 24f0: c5c080e7 jalr -932(ra) # 1148 - 24f4: fd042583 lw a1,-48(s0) - 24f8: 00050613 mv a2,a0 - 24fc: fd442503 lw a0,-44(s0) - 2500: fdc42683 lw a3,-36(s0) - 2504: 00d60633 add a2,a2,a3 - 2508: 00c585b3 add a1,a1,a2 - 250c: 00a58023 sb a0,0(a1) - 2510: 0040006f j 2514 - 2514: fdc42503 lw a0,-36(s0) - 2518: 00150513 addi a0,a0,1 - 251c: fca42e23 sw a0,-36(s0) - 2520: f65ff06f j 2484 - 2524: 0040006f j 2528 - 2528: fe042503 lw a0,-32(s0) - 252c: fff50513 addi a0,a0,-1 - 2530: fea42023 sw a0,-32(s0) - 2534: f35ff06f j 2468 - 2538: fec42503 lw a0,-20(s0) - 253c: 00150513 addi a0,a0,1 - 2540: fea42623 sw a0,-20(s0) - 2544: ff442503 lw a0,-12(s0) - 2548: 00150513 addi a0,a0,1 - 254c: fea42a23 sw a0,-12(s0) - 2550: 0040006f j 2554 - 2554: 0040006f j 2558 - 2558: fec42503 lw a0,-20(s0) - 255c: fff50513 addi a0,a0,-1 - 2560: fea42623 sw a0,-20(s0) - 2564: e45ff06f j 23a8 - 2568: 03812403 lw s0,56(sp) - 256c: 03c12083 lw ra,60(sp) - 2570: 04010113 addi sp,sp,64 - 2574: 00008067 ret - -00002578 : - 2578: ff010113 addi sp,sp,-16 - 257c: 00112623 sw ra,12(sp) - 2580: 00812423 sw s0,8(sp) - 2584: 01010413 addi s0,sp,16 - 2588: 00003537 lui a0,0x3 - 258c: fea42a23 sw a0,-12(s0) - 2590: 06852583 lw a1,104(a0) # 3068 - 2594: 41c65537 lui a0,0x41c65 - 2598: e6d50513 addi a0,a0,-403 # 41c64e6d - 259c: fffff097 auipc ra,0xfffff - 25a0: bac080e7 jalr -1108(ra) # 1148 - 25a4: 00050593 mv a1,a0 - 25a8: ff442503 lw a0,-12(s0) - 25ac: 00003637 lui a2,0x3 - 25b0: 03960613 addi a2,a2,57 # 3039 <.LJTI21_0+0x1d> - 25b4: 00c585b3 add a1,a1,a2 - 25b8: 80000637 lui a2,0x80000 - 25bc: fff60613 addi a2,a2,-1 # 7fffffff - 25c0: 00c5f5b3 and a1,a1,a2 - 25c4: 06b52423 sw a1,104(a0) - 25c8: 06852503 lw a0,104(a0) - 25cc: 00812403 lw s0,8(sp) - 25d0: 00c12083 lw ra,12(sp) - 25d4: 01010113 addi sp,sp,16 - 25d8: 00008067 ret - -000025dc : - 25dc: ff010113 addi sp,sp,-16 - 25e0: 00112623 sw ra,12(sp) - 25e4: 00812423 sw s0,8(sp) - 25e8: 01010413 addi s0,sp,16 - 25ec: 00000097 auipc ra,0x0 - 25f0: f8c080e7 jalr -116(ra) # 2578 - 25f4: 00757513 andi a0,a0,7 - 25f8: fea42a23 sw a0,-12(s0) - 25fc: 0040006f j 2600 - 2600: ff442503 lw a0,-12(s0) - 2604: 00700593 li a1,7 - 2608: 00b51e63 bne a0,a1,2624 - 260c: 0040006f j 2610 - 2610: 00000097 auipc ra,0x0 - 2614: f68080e7 jalr -152(ra) # 2578 - 2618: 00757513 andi a0,a0,7 - 261c: fea42a23 sw a0,-12(s0) - 2620: fe1ff06f j 2600 - 2624: ff442503 lw a0,-12(s0) - 2628: 00812403 lw s0,8(sp) - 262c: 00c12083 lw ra,12(sp) - 2630: 01010113 addi sp,sp,16 - 2634: 00008067 ret - -00002638 : - 2638: ff010113 addi sp,sp,-16 - 263c: 00112623 sw ra,12(sp) - 2640: 00812423 sw s0,8(sp) - 2644: 01010413 addi s0,sp,16 - 2648: 00003537 lui a0,0x3 - 264c: 06c50513 addi a0,a0,108 # 306c - 2650: 00200593 li a1,2 - 2654: fffff097 auipc ra,0xfffff - 2658: 20c080e7 jalr 524(ra) # 1860 - 265c: 00000593 li a1,0 - 2660: 04b51463 bne a0,a1,26a8 - 2664: 0040006f j 2668 - 2668: 00003537 lui a0,0x3 - 266c: 06c50513 addi a0,a0,108 # 306c - 2670: fea42a23 sw a0,-12(s0) - 2674: fffff097 auipc ra,0xfffff - 2678: 6e0080e7 jalr 1760(ra) # 1d54 - 267c: 00000097 auipc ra,0x0 - 2680: cdc080e7 jalr -804(ra) # 2358 - 2684: 00000097 auipc ra,0x0 - 2688: f58080e7 jalr -168(ra) # 25dc - 268c: 00050593 mv a1,a0 - 2690: ff442503 lw a0,-12(s0) - 2694: 00400613 li a2,4 - 2698: 00000693 li a3,0 - 269c: fffff097 auipc ra,0xfffff - 26a0: b94080e7 jalr -1132(ra) # 1230 - 26a4: 0040006f j 26a8 - 26a8: 00812403 lw s0,8(sp) - 26ac: 00c12083 lw ra,12(sp) - 26b0: 01010113 addi sp,sp,16 - 26b4: 00008067 ret - -000026b8 : - 26b8: ff010113 addi sp,sp,-16 - 26bc: 00112623 sw ra,12(sp) - 26c0: 00812423 sw s0,8(sp) - 26c4: 01010413 addi s0,sp,16 - 26c8: fea42a23 sw a0,-12(s0) - 26cc: ff442503 lw a0,-12(s0) - 26d0: f9f50593 addi a1,a0,-97 - 26d4: feb42823 sw a1,-16(s0) - 26d8: 01200513 li a0,18 - 26dc: 08b56663 bltu a0,a1,2768 <.LBB21_7> - 26e0: ff042503 lw a0,-16(s0) - 26e4: 00251513 slli a0,a0,0x2 - 26e8: 000035b7 lui a1,0x3 - 26ec: 01c58593 addi a1,a1,28 # 301c <.LJTI21_0> - 26f0: 00b50533 add a0,a0,a1 - 26f4: 00052503 lw a0,0(a0) - 26f8: 00050067 jr a0 - -000026fc <.LBB21_2>: - 26fc: 00000097 auipc ra,0x0 - 2700: f3c080e7 jalr -196(ra) # 2638 - 2704: 0640006f j 2768 <.LBB21_7> - -00002708 <.LBB21_3>: - 2708: 00003537 lui a0,0x3 - 270c: 06c50513 addi a0,a0,108 # 306c - 2710: 00000593 li a1,0 - 2714: fffff097 auipc ra,0xfffff - 2718: 14c080e7 jalr 332(ra) # 1860 - 271c: 04c0006f j 2768 <.LBB21_7> - -00002720 <.LBB21_4>: - 2720: 00003537 lui a0,0x3 - 2724: 06c50513 addi a0,a0,108 # 306c - 2728: 00100593 li a1,1 - 272c: fffff097 auipc ra,0xfffff - 2730: 134080e7 jalr 308(ra) # 1860 - 2734: 0340006f j 2768 <.LBB21_7> - -00002738 <.LBB21_5>: - 2738: 00003537 lui a0,0x3 - 273c: 06c50513 addi a0,a0,108 # 306c - 2740: 00000593 li a1,0 - 2744: fffff097 auipc ra,0xfffff - 2748: 42c080e7 jalr 1068(ra) # 1b70 - 274c: 01c0006f j 2768 <.LBB21_7> - -00002750 <.LBB21_6>: - 2750: 00003537 lui a0,0x3 - 2754: 06c50513 addi a0,a0,108 # 306c - 2758: 00100593 li a1,1 - 275c: fffff097 auipc ra,0xfffff - 2760: 414080e7 jalr 1044(ra) # 1b70 - 2764: 0040006f j 2768 <.LBB21_7> - -00002768 <.LBB21_7>: - 2768: 00000097 auipc ra,0x0 - 276c: 86c080e7 jalr -1940(ra) # 1fd4 - 2770: 00812403 lw s0,8(sp) - 2774: 00c12083 lw ra,12(sp) - 2778: 01010113 addi sp,sp,16 - 277c: 00008067 ret - -00002780 : - 2780: ff010113 addi sp,sp,-16 - 2784: 00112623 sw ra,12(sp) - 2788: 00812423 sw s0,8(sp) - 278c: 01010413 addi s0,sp,16 - 2790: 00000097 auipc ra,0x0 - 2794: ea8080e7 jalr -344(ra) # 2638 - 2798: 00000097 auipc ra,0x0 - 279c: 83c080e7 jalr -1988(ra) # 1fd4 - 27a0: 00812403 lw s0,8(sp) - 27a4: 00c12083 lw ra,12(sp) - 27a8: 01010113 addi sp,sp,16 - 27ac: 00008067 ret - -000027b0 : - 27b0: fe010113 addi sp,sp,-32 - 27b4: 00112e23 sw ra,28(sp) - 27b8: 00812c23 sw s0,24(sp) - 27bc: 02010413 addi s0,sp,32 - 27c0: fea42a23 sw a0,-12(s0) - 27c4: feb42823 sw a1,-16(s0) - 27c8: ff042503 lw a0,-16(s0) - 27cc: 800005b7 lui a1,0x80000 - 27d0: 00758593 addi a1,a1,7 # 80000007 - 27d4: 00b51a63 bne a0,a1,27e8 - 27d8: 0040006f j 27dc - 27dc: 00000097 auipc ra,0x0 - 27e0: fa4080e7 jalr -92(ra) # 2780 - 27e4: 0280006f j 280c - 27e8: 400005b7 lui a1,0x40000 - 27ec: 00c5a503 lw a0,12(a1) # 4000000c - 27f0: fea42623 sw a0,-20(s0) - 27f4: fec42503 lw a0,-20(s0) - 27f8: 00a5a823 sw a0,16(a1) - 27fc: fec42503 lw a0,-20(s0) - 2800: 00000097 auipc ra,0x0 - 2804: eb8080e7 jalr -328(ra) # 26b8 - 2808: 0040006f j 280c - 280c: 01812403 lw s0,24(sp) - 2810: 01c12083 lw ra,28(sp) - 2814: 02010113 addi sp,sp,32 - 2818: 00008067 ret - -0000281c : - 281c: fc010113 addi sp,sp,-64 - 2820: 02112e23 sw ra,60(sp) - 2824: 02812c23 sw s0,56(sp) - 2828: 04010413 addi s0,sp,64 - 282c: fffff097 auipc ra,0xfffff - 2830: 4ac080e7 jalr 1196(ra) # 1cd8 - 2834: 00000513 li a0,0 - 2838: fea42a23 sw a0,-12(s0) - 283c: 0040006f j 2840 - 2840: ff442583 lw a1,-12(s0) - 2844: 01500513 li a0,21 - 2848: 04b54463 blt a0,a1,2890 - 284c: 0040006f j 2850 - 2850: ff442583 lw a1,-12(s0) - 2854: 00000513 li a0,0 - 2858: 07c00613 li a2,124 - 285c: fec42423 sw a2,-24(s0) - 2860: fffff097 auipc ra,0xfffff - 2864: e88080e7 jalr -376(ra) # 16e8 - 2868: fe842603 lw a2,-24(s0) - 286c: ff442583 lw a1,-12(s0) - 2870: 01500513 li a0,21 - 2874: fffff097 auipc ra,0xfffff - 2878: e74080e7 jalr -396(ra) # 16e8 - 287c: 0040006f j 2880 - 2880: ff442503 lw a0,-12(s0) - 2884: 00150513 addi a0,a0,1 - 2888: fea42a23 sw a0,-12(s0) - 288c: fb5ff06f j 2840 - 2890: 00000513 li a0,0 - 2894: fea42823 sw a0,-16(s0) - 2898: 0040006f j 289c - 289c: ff042583 lw a1,-16(s0) - 28a0: 00001537 lui a0,0x1 - 28a4: 80150513 addi a0,a0,-2047 # 801 <_start-0x7ff> - 28a8: 02b54863 blt a0,a1,28d8 - 28ac: 0040006f j 28b0 - 28b0: ff042503 lw a0,-16(s0) - 28b4: 01600593 li a1,22 - 28b8: 02d00613 li a2,45 - 28bc: fffff097 auipc ra,0xfffff - 28c0: e2c080e7 jalr -468(ra) # 16e8 - 28c4: 0040006f j 28c8 - 28c8: ff042503 lw a0,-16(s0) - 28cc: 00150513 addi a0,a0,1 - 28d0: fea42823 sw a0,-16(s0) - 28d4: fc9ff06f j 289c - 28d8: 00800513 li a0,8 - 28dc: fea42623 sw a0,-20(s0) - 28e0: fec42503 lw a0,-20(s0) - 28e4: 00150593 addi a1,a0,1 - 28e8: feb42623 sw a1,-20(s0) - 28ec: 01700593 li a1,23 - 28f0: fcb42823 sw a1,-48(s0) - 28f4: 05400613 li a2,84 - 28f8: fcc42623 sw a2,-52(s0) - 28fc: fffff097 auipc ra,0xfffff - 2900: dec080e7 jalr -532(ra) # 16e8 - 2904: fd042583 lw a1,-48(s0) - 2908: fec42503 lw a0,-20(s0) - 290c: 00150613 addi a2,a0,1 - 2910: fec42623 sw a2,-20(s0) - 2914: 04500613 li a2,69 - 2918: fffff097 auipc ra,0xfffff - 291c: dd0080e7 jalr -560(ra) # 16e8 - 2920: fcc42603 lw a2,-52(s0) - 2924: fd042583 lw a1,-48(s0) - 2928: fec42503 lw a0,-20(s0) - 292c: 00150693 addi a3,a0,1 - 2930: fed42623 sw a3,-20(s0) - 2934: fffff097 auipc ra,0xfffff - 2938: db4080e7 jalr -588(ra) # 16e8 - 293c: fd042583 lw a1,-48(s0) - 2940: fec42503 lw a0,-20(s0) - 2944: 00150613 addi a2,a0,1 - 2948: fec42623 sw a2,-20(s0) - 294c: 05200613 li a2,82 - 2950: fffff097 auipc ra,0xfffff - 2954: d98080e7 jalr -616(ra) # 16e8 - 2958: fd042583 lw a1,-48(s0) - 295c: fec42503 lw a0,-20(s0) - 2960: 00150613 addi a2,a0,1 - 2964: fec42623 sw a2,-20(s0) - 2968: 04900613 li a2,73 - 296c: fffff097 auipc ra,0xfffff - 2970: d7c080e7 jalr -644(ra) # 16e8 - 2974: fd042583 lw a1,-48(s0) - 2978: fec42503 lw a0,-20(s0) - 297c: 00150613 addi a2,a0,1 - 2980: fec42623 sw a2,-20(s0) - 2984: 05300613 li a2,83 - 2988: fffff097 auipc ra,0xfffff - 298c: d60080e7 jalr -672(ra) # 16e8 - 2990: 00600513 li a0,6 - 2994: fea42623 sw a0,-20(s0) - 2998: fec42503 lw a0,-20(s0) - 299c: 00150593 addi a1,a0,1 - 29a0: feb42623 sw a1,-20(s0) - 29a4: 01900593 li a1,25 - 29a8: fcb42c23 sw a1,-40(s0) - 29ac: 04800613 li a2,72 - 29b0: fffff097 auipc ra,0xfffff - 29b4: d38080e7 jalr -712(ra) # 16e8 - 29b8: fd842583 lw a1,-40(s0) - 29bc: fec42503 lw a0,-20(s0) - 29c0: 00150613 addi a2,a0,1 - 29c4: fec42623 sw a2,-20(s0) - 29c8: 06f00613 li a2,111 - 29cc: fffff097 auipc ra,0xfffff - 29d0: d1c080e7 jalr -740(ra) # 16e8 - 29d4: fd842583 lw a1,-40(s0) - 29d8: fec42503 lw a0,-20(s0) - 29dc: 00150613 addi a2,a0,1 - 29e0: fec42623 sw a2,-20(s0) - 29e4: 07700613 li a2,119 - 29e8: fffff097 auipc ra,0xfffff - 29ec: d00080e7 jalr -768(ra) # 16e8 - 29f0: fd842583 lw a1,-40(s0) - 29f4: fec42503 lw a0,-20(s0) - 29f8: 00150613 addi a2,a0,1 - 29fc: fec42623 sw a2,-20(s0) - 2a00: 06100613 li a2,97 - 2a04: fcc42a23 sw a2,-44(s0) - 2a08: fffff097 auipc ra,0xfffff - 2a0c: ce0080e7 jalr -800(ra) # 16e8 - 2a10: fd842583 lw a1,-40(s0) - 2a14: fec42503 lw a0,-20(s0) - 2a18: 00150613 addi a2,a0,1 - 2a1c: fec42623 sw a2,-20(s0) - 2a20: 07200613 li a2,114 - 2a24: fffff097 auipc ra,0xfffff - 2a28: cc4080e7 jalr -828(ra) # 16e8 - 2a2c: fd842583 lw a1,-40(s0) - 2a30: fec42503 lw a0,-20(s0) - 2a34: 00150613 addi a2,a0,1 - 2a38: fec42623 sw a2,-20(s0) - 2a3c: 06400613 li a2,100 - 2a40: fffff097 auipc ra,0xfffff - 2a44: ca8080e7 jalr -856(ra) # 16e8 - 2a48: fd842583 lw a1,-40(s0) - 2a4c: fec42503 lw a0,-20(s0) - 2a50: 00150513 addi a0,a0,1 - 2a54: fea42623 sw a0,-20(s0) - 2a58: fec42503 lw a0,-20(s0) - 2a5c: 00150613 addi a2,a0,1 - 2a60: fec42623 sw a2,-20(s0) - 2a64: 04c00613 li a2,76 - 2a68: fffff097 auipc ra,0xfffff - 2a6c: c80080e7 jalr -896(ra) # 16e8 - 2a70: fd442603 lw a2,-44(s0) - 2a74: fd842583 lw a1,-40(s0) - 2a78: fec42503 lw a0,-20(s0) - 2a7c: 00150693 addi a3,a0,1 - 2a80: fed42623 sw a3,-20(s0) - 2a84: fffff097 auipc ra,0xfffff - 2a88: c64080e7 jalr -924(ra) # 16e8 - 2a8c: fd842583 lw a1,-40(s0) - 2a90: fec42503 lw a0,-20(s0) - 2a94: 00150613 addi a2,a0,1 - 2a98: fec42623 sw a2,-20(s0) - 2a9c: 07500613 li a2,117 - 2aa0: fffff097 auipc ra,0xfffff - 2aa4: c48080e7 jalr -952(ra) # 16e8 - 2aa8: 00900513 li a0,9 - 2aac: fea42623 sw a0,-20(s0) - 2ab0: fec42503 lw a0,-20(s0) - 2ab4: 00150593 addi a1,a0,1 - 2ab8: feb42623 sw a1,-20(s0) - 2abc: 01a00593 li a1,26 - 2ac0: feb42023 sw a1,-32(s0) - 2ac4: 03200613 li a2,50 - 2ac8: fcc42e23 sw a2,-36(s0) - 2acc: fffff097 auipc ra,0xfffff - 2ad0: c1c080e7 jalr -996(ra) # 16e8 - 2ad4: fe042583 lw a1,-32(s0) - 2ad8: fec42503 lw a0,-20(s0) - 2adc: 00150613 addi a2,a0,1 - 2ae0: fec42623 sw a2,-20(s0) - 2ae4: 03000613 li a2,48 - 2ae8: fffff097 auipc ra,0xfffff - 2aec: c00080e7 jalr -1024(ra) # 16e8 - 2af0: fdc42603 lw a2,-36(s0) - 2af4: fe042583 lw a1,-32(s0) - 2af8: fec42503 lw a0,-20(s0) - 2afc: 00150693 addi a3,a0,1 - 2b00: fed42623 sw a3,-20(s0) - 2b04: fffff097 auipc ra,0xfffff - 2b08: be4080e7 jalr -1052(ra) # 16e8 - 2b0c: fe042583 lw a1,-32(s0) - 2b10: fec42503 lw a0,-20(s0) - 2b14: 00150613 addi a2,a0,1 - 2b18: fec42623 sw a2,-20(s0) - 2b1c: 03100613 li a2,49 - 2b20: fffff097 auipc ra,0xfffff - 2b24: bc8080e7 jalr -1080(ra) # 16e8 - 2b28: 00000097 auipc ra,0x0 - 2b2c: ab4080e7 jalr -1356(ra) # 25dc - 2b30: 00050593 mv a1,a0 - 2b34: 00003537 lui a0,0x3 - 2b38: 06c50513 addi a0,a0,108 # 306c - 2b3c: 00400613 li a2,4 - 2b40: 00000693 li a3,0 - 2b44: fed42223 sw a3,-28(s0) - 2b48: ffffe097 auipc ra,0xffffe - 2b4c: 6e8080e7 jalr 1768(ra) # 1230 - 2b50: fe442503 lw a0,-28(s0) - 2b54: 000035b7 lui a1,0x3 - 2b58: 08a5a023 sw a0,128(a1) # 3080 - 2b5c: fffff097 auipc ra,0xfffff - 2b60: 478080e7 jalr 1144(ra) # 1fd4 - 2b64: 03812403 lw s0,56(sp) - 2b68: 03c12083 lw ra,60(sp) - 2b6c: 04010113 addi sp,sp,64 - 2b70: 00008067 ret - -00002b74 : - 2b74: ff010113 addi sp,sp,-16 - 2b78: 00112623 sw ra,12(sp) - 2b7c: 00812423 sw s0,8(sp) - 2b80: 01010413 addi s0,sp,16 - 2b84: 20000537 lui a0,0x20000 - 2b88: fea42a23 sw a0,-12(s0) - 2b8c: 00000513 li a0,0 - 2b90: fea42823 sw a0,-16(s0) - 2b94: 0040006f j 2b98 - 2b98: ff042583 lw a1,-16(s0) - 2b9c: 25700513 li a0,599 - 2ba0: 02b54c63 blt a0,a1,2bd8 - 2ba4: 0040006f j 2ba8 - 2ba8: ff442503 lw a0,-12(s0) - 2bac: ff042583 lw a1,-16(s0) - 2bb0: 00259593 slli a1,a1,0x2 - 2bb4: 00b505b3 add a1,a0,a1 - 2bb8: 20202537 lui a0,0x20202 - 2bbc: 02050513 addi a0,a0,32 # 20202020 - 2bc0: 00a5a023 sw a0,0(a1) - 2bc4: 0040006f j 2bc8 - 2bc8: ff042503 lw a0,-16(s0) - 2bcc: 00150513 addi a0,a0,1 - 2bd0: fea42823 sw a0,-16(s0) - 2bd4: fc5ff06f j 2b98 - 2bd8: 00812403 lw s0,8(sp) - 2bdc: 00c12083 lw ra,12(sp) - 2be0: 01010113 addi sp,sp,16 - 2be4: 00008067 ret - -00002be8
: - 2be8: ff010113 addi sp,sp,-16 - 2bec: 00112623 sw ra,12(sp) - 2bf0: 00812423 sw s0,8(sp) - 2bf4: 01010413 addi s0,sp,16 - 2bf8: 00000513 li a0,0 - 2bfc: fea42a23 sw a0,-12(s0) - 2c00: 000035b7 lui a1,0x3 - 2c04: 00004537 lui a0,0x4 - 2c08: 06a5ae23 sw a0,124(a1) # 307c <_end> - 2c0c: 00000097 auipc ra,0x0 - 2c10: f68080e7 jalr -152(ra) # 2b74 - 2c14: 00000097 auipc ra,0x0 - 2c18: c08080e7 jalr -1016(ra) # 281c - 2c1c: deadc537 lui a0,0xdeadc - 2c20: eef50513 addi a0,a0,-273 # deadbeef - 2c24: 00a02223 sw a0,4(zero) # 4 <_start-0xffc> - 2c28: ffffe097 auipc ra,0xffffe - 2c2c: 3e8080e7 jalr 1000(ra) # 1010 - 2c30: 800005b7 lui a1,0x80000 - 2c34: 00100513 li a0,1 - 2c38: 00a5a423 sw a0,8(a1) # 80000008 - 2c3c: 02faf537 lui a0,0x2faf - 2c40: 08050513 addi a0,a0,128 # 2faf080 - 2c44: 00a5a223 sw a0,4(a1) - 2c48: 0040006f j 2c4c - 2c4c: 0000006f j 2c4c - -Disassembly of section .data: - -00003000 <.LJTI2_0>: - 3000: 12a0 addi s0,sp,360 - 3002: 0000 unimp - 3004: 12c0 addi s0,sp,356 - 3006: 0000 unimp - 3008: 12e4 addi s1,sp,364 - 300a: 0000 unimp - 300c: 1310 addi a2,sp,416 - 300e: 0000 unimp - 3010: 1338 addi a4,sp,424 - 3012: 0000 unimp - 3014: 1360 addi s0,sp,428 - 3016: 0000 unimp - 3018: 138c addi a1,sp,480 - ... - -0000301c <.LJTI21_0>: - 301c: 2708 fld fa0,8(a4) - 301e: 0000 unimp - 3020: 2768 fld fa0,200(a4) - 3022: 0000 unimp - 3024: 2768 fld fa0,200(a4) - 3026: 0000 unimp - 3028: 2720 fld fs0,72(a4) - 302a: 0000 unimp - 302c: 2768 fld fa0,200(a4) - 302e: 0000 unimp - 3030: 2768 fld fa0,200(a4) - 3032: 0000 unimp - 3034: 2768 fld fa0,200(a4) - 3036: 0000 unimp - 3038: 2768 fld fa0,200(a4) - 303a: 0000 unimp - 303c: 2768 fld fa0,200(a4) - 303e: 0000 unimp - 3040: 2738 fld fa4,72(a4) - 3042: 0000 unimp - 3044: 2750 fld fa2,136(a4) - 3046: 0000 unimp - 3048: 2768 fld fa0,200(a4) - 304a: 0000 unimp - 304c: 2768 fld fa0,200(a4) - 304e: 0000 unimp - 3050: 2768 fld fa0,200(a4) - 3052: 0000 unimp - 3054: 2768 fld fa0,200(a4) - 3056: 0000 unimp - 3058: 2768 fld fa0,200(a4) - 305a: 0000 unimp - 305c: 2768 fld fa0,200(a4) - 305e: 0000 unimp - 3060: 2768 fld fa0,200(a4) - 3062: 0000 unimp - 3064: 26fc fld fa5,200(a3) - ... - -00003068 : - 3068: 000f1c6b 0xf1c6b - -Disassembly of section .bss: - -0000306c : - ... - -Disassembly of section .sbss: - -0000307c : - 307c: 0000 unimp - ... - -00003080 : - 3080: 0000 unimp - ... - -Disassembly of section .comment: - -00000000 <.comment>: - 0: 6e616c63 bltu sp,t1,6f8 <_start-0x908> - 4: 65762067 0x65762067 - 8: 7372 flw ft6,60(sp) - a: 6f69 lui t5,0x1a - c: 206e fld ft0,216(sp) - e: 3331 jal fffffd1a - 10: 302e fld ft0,232(sp) - 12: 312e fld ft2,232(sp) - 14: 4c00 lw s0,24(s0) - 16: 6e69 lui t3,0x1a - 18: 3a72656b 0x3a72656b - 1c: 4c20 lw s0,88(s0) - 1e: 444c lw a1,12(s0) - 20: 3120 fld fs0,96(a0) - 22: 2e302e33 0x2e302e33 - 26: 0031 c.nop 12 - ... - -Disassembly of section .riscv.attributes: - -00000000 <.riscv.attributes>: - 0: 1b41 addi s6,s6,-16 - 2: 0000 unimp - 4: 7200 flw fs0,32(a2) - 6: 7369 lui t1,0xffffa - 8: 01007663 bgeu zero,a6,14 <_start-0xfec> - c: 0011 c.nop 4 - e: 0000 unimp - 10: 1004 addi s1,sp,32 - 12: 7205 lui tp,0xfffe1 - 14: 3376 fld ft6,376(sp) - 16: 6932 flw fs2,12(sp) - 18: 7032 flw ft0,44(sp) - 1a: 0030 addi a2,sp,8 diff --git a/lab2/csrc/tetris.c b/lab2/csrc/tetris.c index 2b37550..6ce1f3a 100644 --- a/lab2/csrc/tetris.c +++ b/lab2/csrc/tetris.c @@ -395,7 +395,7 @@ void on_timer() { void trap_handler(void *epc, unsigned int cause) { if (cause == 0x80000007) { on_timer(); - } else { + } else if (cause == 0x8000000B){ unsigned int ch = *UART_RECV; *UART_SEND = ch; on_input(ch); diff --git a/lab2/csrc/tetris_mmu.c b/lab2/csrc/tetris_mmu.c new file mode 100644 index 0000000..b9ce7a4 --- /dev/null +++ b/lab2/csrc/tetris_mmu.c @@ -0,0 +1,568 @@ +// Copyright 2021 Howard Lau +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifdef DEBUG +#include +#endif + +#include "mmio.h" +#include "mm.h" + +#define FALL_TIMER_LIMIT 50000000 +#define ROWS 22 +#define COLS 10 +#define OFFSET_X 28 +#define OFFSET_Y 3 +#define SCREEN_COLS 80 +#define SCREEN_ROWS 30 + + +struct block { + unsigned int shape[3]; + unsigned int xywh; +}; + +struct block current; + +unsigned int score; + +unsigned char *board; + + + +int pm[8]; //板子上有32kb内存,八个页 +int timercount=0; +// void (*putch_at)(int,int,unsigned char); +#define PAGEDIR_BASE 0x5000 + +#ifdef DEBUG +unsigned char screen[SCREEN_COLS * SCREEN_ROWS]; +#endif + +int wk_mul(int a, int b) { + int r = 0; + for (; b; a <<= 1, b >>= 1) + if (b & 1) + r += a; + return r; +} + +unsigned int make_xywh(unsigned int x, unsigned int y, unsigned int w, unsigned int h) { + return (x << 12) | (y << 4) | (w << 2) | h; +} + +void init_block(struct block *block, int type, int x, int y) { + int w = 0; int h = 0; + block->shape[0] = block->shape[1] = block->shape[2] = 0; + switch(type) { + case 0: // I + block->shape[0] = 0xF; + w = 3; h = 0; + break; + case 1: // O + block->shape[0] = 0x3; + block->shape[1] = 0x3; + w = 1; h = 1; + break; + case 2: // J + block->shape[0] = 0x4; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 3: // T + block->shape[0] = 0x2; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 4: // L + block->shape[0] = 0x1; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 5: // Z + block->shape[0] = 0x6; + block->shape[1] = 0x3; + w = 2; h = 1; + break; + case 6: // S + block->shape[0] = 0x3; + block->shape[1] = 0x6; + w = 2; h = 1; + break; + } + block->xywh = make_xywh(x, y, w, h); +} + +unsigned int get_shape(struct block *block, unsigned int r, unsigned int c) { + return (block->shape[r] & (1 << c)) >> c; +} + +unsigned int check_bounds(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + if (x < 0 || x + w >= COLS) return 0; + if (y < 0 || y + h >= ROWS) return 0; + return 1; +} + +void copy_block(struct block *dst, struct block *src) { + dst->xywh = src->xywh; + dst->shape[0] = src->shape[0]; + dst->shape[1] = src->shape[1]; + dst->shape[2] = src->shape[2]; +} + +unsigned int check_collision(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(block, r, c) && + board[wk_mul(y + r, COLS) + x + c]) + return 0; + } + } + return 1; +} + +void putch_at(int x, int y, unsigned char ch) { +#ifdef DEBUG + screen[wk_mul(OFFSET_Y + y, SCREEN_COLS) + x + OFFSET_X] = ch; +#else + VA_VRAM[wk_mul(OFFSET_Y + y, SCREEN_COLS) + x + OFFSET_X] = ch; +#endif +} + + +void block_move(struct block *block, int dir) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + switch(dir) { + case 0: // Left + x--; + break; + case 1: // Right + x++; + break; + case 2: // Down + y++; + break; + default: + break; + } + block->xywh = (x << 12) | (y << 4) | (w << 2) | h; +} + +unsigned int move(struct block *block, int dir) { + struct block moved; + copy_block(&moved, block); + block_move(&moved, dir); + if (check_bounds(&moved) && check_collision(&moved)) { + copy_block(block, &moved); + return 1; + } + return 0; +} + +void block_rotate(struct block *block, unsigned int clock) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + unsigned int xyhw = make_xywh(x, y, h, w); + unsigned int shape[3] = {0, 0, 0}; + if (clock) { + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + shape[c] = shape[c] | (get_shape(block, r, c) << (h - r)); + } + } + + } else { + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + shape[w - c] = shape[w - c] | (get_shape(block, r, c) << r); + } + } + } + block->shape[0] = shape[0]; + block->shape[1] = shape[1]; + block->shape[2] = shape[2]; + block->xywh = xyhw; +} + + +void rotate(struct block *block, int clock) { + struct block rotated; + copy_block(&rotated, block); + block_rotate(&rotated, clock); + if (check_bounds(&rotated) && check_collision(&rotated)) { + copy_block(block, &rotated); + return; + } + unsigned int xywh = rotated.xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; + if (x + w >= COLS) { + x = COLS - w - 1; + } + rotated.xywh = make_xywh(x, y, w, h); + if (check_bounds(&rotated) && check_collision(&rotated)) { + copy_block(block, &rotated); + } +} + +void clear_board() { + for (int i = 0, s = wk_mul(ROWS, COLS); i < s; ++i) { + board[i] = 0; + } +} + +void fix_block(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; +#ifdef DEBUG + printf("%d %d %d %d\n", x, y, w, h); +#endif + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(block, r, c)) { + board[wk_mul(y + r, COLS) + x + c] = 1; + } + } + } +} + +void print_score() { + int c = 8; + putch_at(c++, -2, 'S'); + putch_at(c++, -2, 'C'); + putch_at(c++, -2, 'O'); + putch_at(c++, -2, 'R'); + putch_at(c++, -2, 'E'); + for (int i = 0; i < 5; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (score & mask) >> (i * 4); + putch_at(12 - i, -1, num + '0'); + } +} + +void draw_board() { + for (int r = 0; r < ROWS; ++r) { + for (int c = 0; c < COLS; ++c) { + if (board[wk_mul(r , COLS) + c] == 1) { + putch_at((c << 1) + 1, r, '['); + putch_at((c << 1) + 2, r, ']'); + } else { + putch_at((c << 1) + 1, r, ' '); + putch_at((c << 1)+ 2, r, ' '); + } + } + } + unsigned int xywh = current.xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(¤t, r, c)) { + putch_at(((c + x) << 1) + 1, r + y, '['); + putch_at(((c + x) << 1) + 2, r + y, ']'); + } + } + } + print_score(); +} + + +void add_score(unsigned int delta) { + score += delta; + for (unsigned int i = 0, carry = 0; i < 32; i += 4) { + unsigned int mask = 0xF << i; + unsigned int num = (score & mask) >> i; + num += carry; + if (num >= 10) { + carry = 1; + num -= 10; + } else { + carry = 0; + } + score &= ~(mask); + score |= (num << i); + } +} + +void check_clear() { + unsigned int y = (current.xywh & 0xff0) >> 4; + unsigned int h = current.xywh & 0x3; + for (int r = y + h; r >= y; --r) { + unsigned int count = 0; + for (int c = 0; c < COLS; ++c) { + if (board[wk_mul(r , COLS) + c]) ++count; + } + if (count == COLS) { + add_score(1); + for (int nr = r - 1; nr > 0; --nr) { + for (int c = 0; c < COLS; ++c) { + board[wk_mul(nr + 1, COLS) + c] = board[wk_mul(nr, COLS) + c]; + } + } + ++r; ++y; + } + } +} + +unsigned int rand() { + static unsigned int seed = 990315; + seed = (wk_mul(1103515245 , seed) + 12345) & 0x7FFFFFFF; + return seed; +} + +unsigned int rand_type() { + unsigned int type = rand() & 0x7; + while (type == 7) { + type = rand() & 0x7; + } + return type; +} + +void fall() { + if (move(¤t, 2) == 0) { + fix_block(¤t); + check_clear(); + init_block(¤t, rand_type(), 4, 0); + } +} + +#ifdef DEBUG +void print_screen() { + for (int r = 0; r < SCREEN_ROWS; ++r) { + for (int c = 0; c < SCREEN_COLS; ++c) { + printf("%c", screen[wk_mul(r, SCREEN_COLS) + c]); + } + printf("\n"); + } + printf("\n"); +} +#endif + +void on_input(unsigned int ch) { + switch (ch) { + case 's': + fall(); + break; + case 'a': + move(¤t, 0); + break; + case 'd': + move(¤t, 1); + break; + case 'j': + rotate(¤t, 0); + break; + case 'k': + rotate(¤t, 1); + break; + } + draw_board(); +#ifdef DEBUG + print_screen(); +#endif +} + +void on_timer() { + fall(); + draw_board(); +} + +void trap_handler(void *epc, unsigned int cause) { + if (cause == 0x80000007) { + on_timer(); + } else if (cause == 0x8000000B){ + unsigned int ch = *VA_UART_RECV; + *VA_UART_SEND = ch; + on_input(ch); + } +} + +void init() { + clear_board(); + // Draw border + for (int r = 0; r < ROWS; ++r) { + putch_at(0, r, '|'); + putch_at(COLS << 1 | 1, r, '|'); + } + for (int c = 0; c <= (2 << COLS | 1); ++c) { + putch_at(c, ROWS, '-'); + } + int c = 8; + putch_at(c++, ROWS + 1, 'B'); + putch_at(c++, ROWS + 1, 'e'); + putch_at(c++, ROWS + 1, 'g'); + putch_at(c++, ROWS + 1, 'i'); + putch_at(c++, ROWS + 1, 'n'); + putch_at(c++, ROWS + 1, ' '); + c = 6; + putch_at(c++, ROWS + 3, 'P'); + putch_at(c++, ROWS + 3, 'a'); + putch_at(c++, ROWS + 3, 'g'); + putch_at(c++, ROWS + 3, 'i'); + putch_at(c++, ROWS + 3, 'n'); + putch_at(c++, ROWS + 3, 'g'); + c++; + putch_at(c++, ROWS + 3, 'h'); + putch_at(c++, ROWS + 3, 'r'); + putch_at(c++, ROWS + 3, 'p'); + c = 9; + putch_at(c++, ROWS + 4, '2'); + putch_at(c++, ROWS + 4, '0'); + putch_at(c++, ROWS + 4, '2'); + putch_at(c++, ROWS + 4, '2'); + init_block(¤t, rand_type(), 4, 0); + score = 0; + draw_board(); +} + +int alloc(){ + int index = 0; + int max = 8; + while(index < max){ + if(pm[index] == 0){ + pm[index] = 1; + break; + } + index++; + } + return index == max ? -1 : index; +} + +int map(pagetable_t pgtbl,uint32 va,uint32 pa,int perm){ + int t; + if((pgtbl[PX(1,va)] & PTE_V )!= PTE_V){ //前缀不存在 + t=alloc(); //申请一个页给前缀页表 + if(t>=0){ + pgtbl[PX(1,va)] = PA2PTE(t<<12) | PTE_V; + }else{ + return -1; + } + } + int* n = (void*)PTE2PA(pgtbl[PX(1,va)]); + n[PX(0,va)] = PA2PTE(pa) | perm | PTE_V; + return 0; +} + +void kvminit(){ + //init global valuable + for(int i=0;i<8;i++){ + pm[i] = 0; + } + timercount = 0; + + pagetable_t pgtbl = (void*)PAGEDIR_BASE; + // memoryset(pgtbl,0,PGSIZE); //后面需要读这个内存,所以先初始化 + for(int i=0;i>2;i++){ + pgtbl[i]=0; + } + + pm[PAGEDIR_BASE >> 12] = 1; + pm[0]=1; + pm[1]=1; + pm[2]=1; + pm[3]=1; + pm[4]=1; + //create pte mmap for text + map(pgtbl,PAGEDIR_BASE,PAGEDIR_BASE,PTE_R | PTE_W); + map(pgtbl,0x0,0x0, PTE_W | PTE_R ); //kernel stack + map(pgtbl,0x1000,0x1000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x2000,0x2000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x3000,0x3000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x4000,0x4000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,VA_VRAM_BASE,VRAM_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_VRAM_BASE + PGSIZE,VRAM_BASE + PGSIZE, PTE_W | PTE_R); + map(pgtbl,VA_UART_BASE,UART_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_TIMER_BASE,TIMER_BASE, PTE_W | PTE_R ); // +} + +void clear_screen() { + int *vram = ((int *) VA_VRAM_BASE); + for (int i = 0; i < 600; ++i) vram[i] = 0x20202020; +} + +extern void enable_interrupt(); +extern void enable_paging(); + +int main() { +#ifdef DEBUG + unsigned char b[ROWS * COLS] = {0}; + board = b; + for (int i = 0; i < SCREEN_ROWS * SCREEN_COLS; ++i) screen[i] = '%'; + init(); +#else + kvminit(); + enable_paging(); + board = (unsigned char *) 16640; //0x4100 + clear_screen(); + init(); + *((unsigned int *) 4) = 0xDEADBEEF; + enable_interrupt(); + *VA_TIMER_ENABLED = 1; + *VA_TIMER_LIMIT = FALL_TIMER_LIMIT; + for (;;); +#endif +#ifdef DEBUG + on_input('a'); + on_input('a'); + on_input('s'); + on_input('s'); + on_input('s'); + for (int i = 21; i >= 0; --i) { + on_timer(); + } + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + for (int i = 21; i >= 0; --i) { + on_timer(); + } + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + for (int i = 21; i >= 0; --i) { + on_timer(); + add_score(10); + } + print_score(); + print_screen(); + return 0; +#endif +} diff --git a/lab2/src/main/resources/fibonacci.asmbin b/lab2/src/main/resources/fibonacci.asmbin index 45e994f..91f7740 100644 Binary files a/lab2/src/main/resources/fibonacci.asmbin and b/lab2/src/main/resources/fibonacci.asmbin differ diff --git a/lab2/src/main/resources/hello.asmbin b/lab2/src/main/resources/hello.asmbin index 8e9a27d..27a4e32 100644 Binary files a/lab2/src/main/resources/hello.asmbin and b/lab2/src/main/resources/hello.asmbin differ diff --git a/lab2/src/main/resources/mmio.asmbin b/lab2/src/main/resources/mmio.asmbin index b67851b..22cc8f4 100644 Binary files a/lab2/src/main/resources/mmio.asmbin and b/lab2/src/main/resources/mmio.asmbin differ diff --git a/lab2/src/main/resources/paging.asmbin b/lab2/src/main/resources/paging.asmbin new file mode 100644 index 0000000..45011d8 Binary files /dev/null and b/lab2/src/main/resources/paging.asmbin differ diff --git a/lab2/src/main/resources/quicksort.asmbin b/lab2/src/main/resources/quicksort.asmbin index d9a007a..60d10f4 100644 Binary files a/lab2/src/main/resources/quicksort.asmbin and b/lab2/src/main/resources/quicksort.asmbin differ diff --git a/lab2/src/main/resources/tetris.asmbin b/lab2/src/main/resources/tetris.asmbin index fc07ed8..fdeaeda 100644 Binary files a/lab2/src/main/resources/tetris.asmbin and b/lab2/src/main/resources/tetris.asmbin differ diff --git a/lab2/src/main/resources/tetris_mmu.asmbin b/lab2/src/main/resources/tetris_mmu.asmbin new file mode 100644 index 0000000..fe350f0 Binary files /dev/null and b/lab2/src/main/resources/tetris_mmu.asmbin differ diff --git a/lab3/csrc/CMakeLists.txt b/lab3/csrc/CMakeLists.txt index edbe658..ee07b00 100644 --- a/lab3/csrc/CMakeLists.txt +++ b/lab3/csrc/CMakeLists.txt @@ -5,8 +5,8 @@ project(yatcpu-programs C CXX ASM) # Setting variables set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 --target=riscv32-unknown-elf -march=rv32i -mabi=ilp32") set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O0 --target=riscv32-unknown-elf -march=rv32i -mabi=ilp32") -set(C_PROGRAMS tetris hello fibonacci quicksort) -set(ASM_PROGRAMS mmio sb hazard) +set(C_PROGRAMS tetris hello fibonacci quicksort paging tetris_mmu) +set(ASM_PROGRAMS mmio sb) set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/link.lds) set(LINKER_FLAGS -T ${LINKER_SCRIPT}) set(OBJCOPY_ARGS -O binary -j .text -j .data) @@ -32,8 +32,8 @@ foreach(program IN LISTS ASM_PROGRAMS) set_target_properties(${program} PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT}) endforeach() -# Copy the .text section to .asmbin files -foreach(program IN LISTS C_PROGRAMS ASM_PROGRAMS) +# Copy the .text and .data section to .asmbin files +foreach(program IN LISTS C_PROGRAMS ASM_PROGRAMS PROGRAMS) add_custom_command( TARGET ${program} POST_BUILD diff --git a/lab3/csrc/hazard.S b/lab3/csrc/hazard.S deleted file mode 100644 index 1d827ba..0000000 --- a/lab3/csrc/hazard.S +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2022 Canbin Huang -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -.globl _start -_start: - csrr a0, cycle - - addi t0, zero, 1 - sub t1, zero, t0 - and t2, t0, t1 - sw t2, 4(zero) - j skip1 - or t2, t0, t1 - xor t2, t0, t1 - -skip1: - addi t1, t2, 1 - add t2, t1, t2 - and t2, t1, t2 - lw t2, 2(t2) - or t3, t1, t2 - blt t2, t3, skip2 - or t3, t0, t0 - xor t3, t0, t1 - -skip2: - addi t4, zero, 3 - bne t3, t4, skip1 - sw t3, 8(zero) - auipc t4, 0 - jalr t4, 8(t4) - jalr t4, 4(t4) - csrr a1, cycle - sub ra, a1, a0 - -loop: - j loop \ No newline at end of file diff --git a/lab3/csrc/init.S b/lab3/csrc/init.S index 4534c78..1d4dbce 100644 --- a/lab3/csrc/init.S +++ b/lab3/csrc/init.S @@ -15,7 +15,7 @@ .section .text.init .globl _start _start: - li sp, 4096 # Initialize stack pointer + li sp, 0x10000000 # Initialize stack pointer call main # Jump to main function loop: j loop # Loop forever @@ -26,6 +26,16 @@ enable_interrupt: li t0, 0x1888 csrrw t1, mstatus, t0 # enable interrupt ret +.globl enable_paging +enable_paging: + li t0, 0x80000005 # ppn << 12 = 0x005000 + csrw satp, t0 + ret +.globl get_mtval +get_mtval: + csrr a0, mtval + ret + .globl get_epc get_epc: csrr a0, mepc diff --git a/lab3/csrc/link.lds b/lab3/csrc/link.lds index b5d8366..a166fc7 100644 --- a/lab3/csrc/link.lds +++ b/lab3/csrc/link.lds @@ -6,6 +6,7 @@ SECTIONS . = 0x00001000; .text : { *(.text.init) *(.text.startup) *(.text) } .data ALIGN(0x1000) : { *(.data*) *(.rodata*) *(.sdata*) } + . = 0x00100000; .bss : { *(.bss) } _end = .; } diff --git a/lab3/csrc/mm.h b/lab3/csrc/mm.h new file mode 100644 index 0000000..5d4c89a --- /dev/null +++ b/lab3/csrc/mm.h @@ -0,0 +1,43 @@ +// Copyright 2022 hrpccs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +typedef unsigned int uint32; +typedef uint32 pte_t; +typedef uint32* pagetable_t; + +#define PGSIZE 4096 // bytes per page +#define PGSHIFT 12 // bits of offset within a page + +#define PGROUNDUP(sz) (((sz)+PGSIZE-1) & ~(PGSIZE-1)) +#define PGROUNDDOWN(a) (((a)) & ~(PGSIZE-1)) + +#define PTE_V (1L << 0) // valid +#define PTE_R (1L << 1) +#define PTE_W (1L << 2) +#define PTE_X (1L << 3) +#define PTE_U (1L << 4) // 1 -> user can access + +// shift a physical address to the right place for a PTE. +#define PA2PTE(pa) ((((uint32)pa) >> 12) << 10) + +#define PTE2PA(pte) (((pte) >> 10) << 12) + +#define PTE_FLAGS(pte) ((pte) & 0x3FF) + +// extract the two 10-bit page table indices from a virtual address. +#define PXMASK 0x3FF // 10 bits +#define PXSHIFT(level) (PGSHIFT+(10*(level))) +#define PX(level, va) ((((uint32) (va)) >> PXSHIFT(level)) & PXMASK) + +#define MAXVA (1L << (10 + 10 + 12)) diff --git a/lab3/csrc/mmio.h b/lab3/csrc/mmio.h index b1222dd..fb0fa5f 100644 --- a/lab3/csrc/mmio.h +++ b/lab3/csrc/mmio.h @@ -21,3 +21,13 @@ #define UART_BAUDRATE ((volatile unsigned int *) (UART_BASE + 4)) #define UART_RECV ((volatile unsigned int *) (UART_BASE + 12)) #define UART_SEND ((volatile unsigned int *) (UART_BASE + 16)) +//remap the mmio to reduce memory usage of page table +#define VA_VRAM_BASE 0x00100000 +#define VA_VRAM ((volatile unsigned char *) VA_VRAM_BASE) +#define VA_TIMER_BASE 0x00200000 +#define VA_TIMER_LIMIT ((volatile unsigned int *) (VA_TIMER_BASE + 4)) +#define VA_TIMER_ENABLED ((volatile unsigned int *) (VA_TIMER_BASE + 8)) +#define VA_UART_BASE 0x00300000 +#define VA_UART_BAUDRATE ((volatile unsigned int *) (VA_UART_BASE + 4)) +#define VA_UART_RECV ((volatile unsigned int *) (VA_UART_BASE + 12)) +#define VA_UART_SEND ((volatile unsigned int *) (VA_UART_BASE + 16)) \ No newline at end of file diff --git a/lab3/csrc/paging.c b/lab3/csrc/paging.c new file mode 100644 index 0000000..d8d59d5 --- /dev/null +++ b/lab3/csrc/paging.c @@ -0,0 +1,191 @@ +// # Copyright 2022 hrpccs +// # +// # Licensed under the Apache License, Version 2.0 (the "License"); +// # you may not use this file except in compliance with the License. +// # You may obtain a copy of the License at +// # +// # http://www.apache.org/licenses/LICENSE-2.0 +// # +// # Unless required by applicable law or agreed to in writing, software +// # distributed under the License is distributed on an "AS IS" BASIS, +// # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// # See the License for the specific language governing permissions and +// # limitations under the License. + +#include "mm.h" +#include "mmio.h" + + + +#define SCREEN_COLS 80 +#define SCREEN_ROWS 30 +#define INT_TIMER_LIMIT 50000000 +#define PAGEDIR_BASE 0x5000 + +typedef unsigned int uint32; +typedef uint32 pte_t; +typedef uint32* pagetable_t; + +extern void enable_paging(); +extern void enable_interrupt(); +extern int get_mtval(); + +int wk_mul(int a, int b) { + int r = 0; + for (; b; a <<= 1, b >>= 1) + if (b & 1) + r += a; + return r; +} + +void memoryset(unsigned char *dest,unsigned char num, unsigned int size){ + for(unsigned int i=0;i=0){ + int* taddr = (int*)(t<<12); + for(int i=0;i>2;i++){ + taddr[i]=0; + } + pgtbl[PX(1,va)] = PA2PTE(t<<12) | PTE_V; + }else{ + while(1); + for(int i=0;i<14;i++){ + putch_at(i,22,"out of memory!"[i]); + } + while(1); + } + } + pagetable_t n = (void*)PTE2PA(pgtbl[PX(1,va)]); + n[PX(0,va)] = PA2PTE(pa) | perm | PTE_V; +} + + +void kvminit(){ + pagetable_t pgtbl = (void*)PAGEDIR_BASE; + // memoryset(pgtbl,0,PGSIZE); //后面需要读这个内存,所以先初始化 + for(int i=0;i>2;i++){ + pgtbl[i]=0; + } + + pm[PAGEDIR_BASE >> 12] = 1; + pm[0]=1; + pm[1]=1; + pm[2]=1; + pm[3]=1; + pm[4]=1; + //create pte mmap for text + pgtbl[1023] = PA2PTE(PAGEDIR_BASE) | PTE_R | PTE_W; + map(pgtbl,PAGEDIR_BASE,PAGEDIR_BASE,PTE_R | PTE_W); + map(pgtbl,0x0,0x0, PTE_W | PTE_R ); //kernel stack + map(pgtbl,0x1000,0x1000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x2000,0x2000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x3000,0x3000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x4000,0x4000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,VA_VRAM_BASE,VRAM_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_VRAM_BASE + PGSIZE,VRAM_BASE + PGSIZE, PTE_W | PTE_R); + map(pgtbl,VA_UART_BASE,UART_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_TIMER_BASE,TIMER_BASE, PTE_W | PTE_R ); // +} + +void clear_screen() { + int *vram = ((int *) VRAM_BASE); + for (int i = 0; i < 600; ++i) vram[i] = 0x20202020; +} + +void trap_handler(void *epc, unsigned int cause) { + if (cause == 10 || cause == 15 || cause == 13) { + for(int i=0;i<39;i++){ + putch_at(i,4,"A not handled page fault caused by : 0x"[i]); + } + int mtval = get_mtval(); + char ch; + for (int i = 0; i < 8; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (mtval & mask) >> (i * 4); + if(num >= 10){ + ch = num - 10 + 'A'; + }else{ + ch = num + '0'; + } + putch_at(39+7-i,4,ch); + } + while(1); //目前还没有处理page-fault,因为还没有建立完整的映射。 + } else if(cause == 0x80000007){ + for(int i=0;i<16;i++){ + putch_at(i,3,"timer count : 0x"[i]); + } + char ch; + for (int i = 0; i < 8; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (timercount & mask) >> (i * 4); + if(num >= 10){ + ch = num - 10 + 'A'; + }else{ + ch = num + '0'; + } + putch_at(16+7-i,3,ch); + } + timercount += 1; + + } +} + +int main(){ + putch_at = __putch_at; + for(int i=0;i<8;i++){ + pm[i] = 0; + } + timercount = 0; + clear_screen(); + for(int i=0;i<19;i++){ + putch_at(i,0,"print before paging"[i]); + } + kvminit(); + putch_at = __vputch_at; + enable_paging(); + for(int i=0;i<18;i++){ + putch_at(i,1,"print after paging"[i]); + } + enable_interrupt(); + *VA_TIMER_ENABLED = 1; + *VA_TIMER_LIMIT = INT_TIMER_LIMIT; + + while(1){ + if(timercount == 0x20){ + *(int*)0x11415 = 1130; + } + } + for(;;); +} \ No newline at end of file diff --git a/lab3/csrc/say_goodbye.c b/lab3/csrc/say_goodbye.c new file mode 100644 index 0000000..566e7e2 --- /dev/null +++ b/lab3/csrc/say_goodbye.c @@ -0,0 +1,44 @@ + +void uart_send_char(char c) +{ + *((volatile unsigned int *) (0x40000010)) = c; + // *((volatile unsigned int *) (0x40000000)) = c; +} + + +void waste_some_time(int cycle) { + unsigned int a = 135; + while (cycle--) { + a++; + } +} + +int main() { + + // const char* s = "abcd"; + const char* s = "Never gonna give you up~ Never gonna let you down~\n\ + Never gonna run around and~ desert you~\n"; + + while (1) { + + + // for (int i = 0; i < ; i++) { + // uart_send_char(s[i]); + // waste_some_time(100); + // } + + const char *p = s; + while (*p != 0) + { + uart_send_char(*p); + p++; + waste_some_time(100); + } + + waste_some_time(200); + + break; // print once, but pressing CPU reset can print again + } + + return 0; +} diff --git a/lab3/csrc/tetris.c b/lab3/csrc/tetris.c index 27b2b4c..6ce1f3a 100644 --- a/lab3/csrc/tetris.c +++ b/lab3/csrc/tetris.c @@ -395,7 +395,7 @@ void on_timer() { void trap_handler(void *epc, unsigned int cause) { if (cause == 0x80000007) { on_timer(); - } else { + } else if (cause == 0x8000000B){ unsigned int ch = *UART_RECV; *UART_SEND = ch; on_input(ch); @@ -409,7 +409,7 @@ void init() { putch_at(0, r, '|'); putch_at(COLS << 1 | 1, r, '|'); } - for (int c = 0; c <= (2 << COLS | 1); ++c) { + for (int c = 0; c <= (COLS << 1 | 1); ++c) { putch_at(c, ROWS, '-'); } int c = 8; @@ -455,6 +455,9 @@ int main() { init(); #else board = (unsigned char *) 16384; + for (int i = 0; i < 16384; i += 4) { + *((int*) (board + i)) = 0; + } clear_screen(); init(); *((unsigned int *) 4) = 0xDEADBEEF; diff --git a/lab3/csrc/tetris_mmu.c b/lab3/csrc/tetris_mmu.c new file mode 100644 index 0000000..b9ce7a4 --- /dev/null +++ b/lab3/csrc/tetris_mmu.c @@ -0,0 +1,568 @@ +// Copyright 2021 Howard Lau +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifdef DEBUG +#include +#endif + +#include "mmio.h" +#include "mm.h" + +#define FALL_TIMER_LIMIT 50000000 +#define ROWS 22 +#define COLS 10 +#define OFFSET_X 28 +#define OFFSET_Y 3 +#define SCREEN_COLS 80 +#define SCREEN_ROWS 30 + + +struct block { + unsigned int shape[3]; + unsigned int xywh; +}; + +struct block current; + +unsigned int score; + +unsigned char *board; + + + +int pm[8]; //板子上有32kb内存,八个页 +int timercount=0; +// void (*putch_at)(int,int,unsigned char); +#define PAGEDIR_BASE 0x5000 + +#ifdef DEBUG +unsigned char screen[SCREEN_COLS * SCREEN_ROWS]; +#endif + +int wk_mul(int a, int b) { + int r = 0; + for (; b; a <<= 1, b >>= 1) + if (b & 1) + r += a; + return r; +} + +unsigned int make_xywh(unsigned int x, unsigned int y, unsigned int w, unsigned int h) { + return (x << 12) | (y << 4) | (w << 2) | h; +} + +void init_block(struct block *block, int type, int x, int y) { + int w = 0; int h = 0; + block->shape[0] = block->shape[1] = block->shape[2] = 0; + switch(type) { + case 0: // I + block->shape[0] = 0xF; + w = 3; h = 0; + break; + case 1: // O + block->shape[0] = 0x3; + block->shape[1] = 0x3; + w = 1; h = 1; + break; + case 2: // J + block->shape[0] = 0x4; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 3: // T + block->shape[0] = 0x2; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 4: // L + block->shape[0] = 0x1; + block->shape[1] = 0x7; + w = 2; h = 1; + break; + case 5: // Z + block->shape[0] = 0x6; + block->shape[1] = 0x3; + w = 2; h = 1; + break; + case 6: // S + block->shape[0] = 0x3; + block->shape[1] = 0x6; + w = 2; h = 1; + break; + } + block->xywh = make_xywh(x, y, w, h); +} + +unsigned int get_shape(struct block *block, unsigned int r, unsigned int c) { + return (block->shape[r] & (1 << c)) >> c; +} + +unsigned int check_bounds(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + if (x < 0 || x + w >= COLS) return 0; + if (y < 0 || y + h >= ROWS) return 0; + return 1; +} + +void copy_block(struct block *dst, struct block *src) { + dst->xywh = src->xywh; + dst->shape[0] = src->shape[0]; + dst->shape[1] = src->shape[1]; + dst->shape[2] = src->shape[2]; +} + +unsigned int check_collision(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(block, r, c) && + board[wk_mul(y + r, COLS) + x + c]) + return 0; + } + } + return 1; +} + +void putch_at(int x, int y, unsigned char ch) { +#ifdef DEBUG + screen[wk_mul(OFFSET_Y + y, SCREEN_COLS) + x + OFFSET_X] = ch; +#else + VA_VRAM[wk_mul(OFFSET_Y + y, SCREEN_COLS) + x + OFFSET_X] = ch; +#endif +} + + +void block_move(struct block *block, int dir) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + switch(dir) { + case 0: // Left + x--; + break; + case 1: // Right + x++; + break; + case 2: // Down + y++; + break; + default: + break; + } + block->xywh = (x << 12) | (y << 4) | (w << 2) | h; +} + +unsigned int move(struct block *block, int dir) { + struct block moved; + copy_block(&moved, block); + block_move(&moved, dir); + if (check_bounds(&moved) && check_collision(&moved)) { + copy_block(block, &moved); + return 1; + } + return 0; +} + +void block_rotate(struct block *block, unsigned int clock) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xC) >> 2; + unsigned int y = (xywh & 0xFF0) >> 4; + unsigned int x = (xywh & 0xF000) >> 12; + unsigned int xyhw = make_xywh(x, y, h, w); + unsigned int shape[3] = {0, 0, 0}; + if (clock) { + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + shape[c] = shape[c] | (get_shape(block, r, c) << (h - r)); + } + } + + } else { + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + shape[w - c] = shape[w - c] | (get_shape(block, r, c) << r); + } + } + } + block->shape[0] = shape[0]; + block->shape[1] = shape[1]; + block->shape[2] = shape[2]; + block->xywh = xyhw; +} + + +void rotate(struct block *block, int clock) { + struct block rotated; + copy_block(&rotated, block); + block_rotate(&rotated, clock); + if (check_bounds(&rotated) && check_collision(&rotated)) { + copy_block(block, &rotated); + return; + } + unsigned int xywh = rotated.xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; + if (x + w >= COLS) { + x = COLS - w - 1; + } + rotated.xywh = make_xywh(x, y, w, h); + if (check_bounds(&rotated) && check_collision(&rotated)) { + copy_block(block, &rotated); + } +} + +void clear_board() { + for (int i = 0, s = wk_mul(ROWS, COLS); i < s; ++i) { + board[i] = 0; + } +} + +void fix_block(struct block *block) { + unsigned int xywh = block->xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; +#ifdef DEBUG + printf("%d %d %d %d\n", x, y, w, h); +#endif + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(block, r, c)) { + board[wk_mul(y + r, COLS) + x + c] = 1; + } + } + } +} + +void print_score() { + int c = 8; + putch_at(c++, -2, 'S'); + putch_at(c++, -2, 'C'); + putch_at(c++, -2, 'O'); + putch_at(c++, -2, 'R'); + putch_at(c++, -2, 'E'); + for (int i = 0; i < 5; ++i) { + unsigned int mask = 0xF << (i * 4); + unsigned int num = (score & mask) >> (i * 4); + putch_at(12 - i, -1, num + '0'); + } +} + +void draw_board() { + for (int r = 0; r < ROWS; ++r) { + for (int c = 0; c < COLS; ++c) { + if (board[wk_mul(r , COLS) + c] == 1) { + putch_at((c << 1) + 1, r, '['); + putch_at((c << 1) + 2, r, ']'); + } else { + putch_at((c << 1) + 1, r, ' '); + putch_at((c << 1)+ 2, r, ' '); + } + } + } + unsigned int xywh = current.xywh; + unsigned int h = xywh & 0x3; + unsigned int w = (xywh & 0xc) >> 2; + unsigned int y = (xywh & 0xff0) >> 4; + unsigned int x = (xywh & 0xf000) >> 12; + for (int r = 0; r <= h; ++r) { + for (int c = 0; c <= w; ++c) { + if (get_shape(¤t, r, c)) { + putch_at(((c + x) << 1) + 1, r + y, '['); + putch_at(((c + x) << 1) + 2, r + y, ']'); + } + } + } + print_score(); +} + + +void add_score(unsigned int delta) { + score += delta; + for (unsigned int i = 0, carry = 0; i < 32; i += 4) { + unsigned int mask = 0xF << i; + unsigned int num = (score & mask) >> i; + num += carry; + if (num >= 10) { + carry = 1; + num -= 10; + } else { + carry = 0; + } + score &= ~(mask); + score |= (num << i); + } +} + +void check_clear() { + unsigned int y = (current.xywh & 0xff0) >> 4; + unsigned int h = current.xywh & 0x3; + for (int r = y + h; r >= y; --r) { + unsigned int count = 0; + for (int c = 0; c < COLS; ++c) { + if (board[wk_mul(r , COLS) + c]) ++count; + } + if (count == COLS) { + add_score(1); + for (int nr = r - 1; nr > 0; --nr) { + for (int c = 0; c < COLS; ++c) { + board[wk_mul(nr + 1, COLS) + c] = board[wk_mul(nr, COLS) + c]; + } + } + ++r; ++y; + } + } +} + +unsigned int rand() { + static unsigned int seed = 990315; + seed = (wk_mul(1103515245 , seed) + 12345) & 0x7FFFFFFF; + return seed; +} + +unsigned int rand_type() { + unsigned int type = rand() & 0x7; + while (type == 7) { + type = rand() & 0x7; + } + return type; +} + +void fall() { + if (move(¤t, 2) == 0) { + fix_block(¤t); + check_clear(); + init_block(¤t, rand_type(), 4, 0); + } +} + +#ifdef DEBUG +void print_screen() { + for (int r = 0; r < SCREEN_ROWS; ++r) { + for (int c = 0; c < SCREEN_COLS; ++c) { + printf("%c", screen[wk_mul(r, SCREEN_COLS) + c]); + } + printf("\n"); + } + printf("\n"); +} +#endif + +void on_input(unsigned int ch) { + switch (ch) { + case 's': + fall(); + break; + case 'a': + move(¤t, 0); + break; + case 'd': + move(¤t, 1); + break; + case 'j': + rotate(¤t, 0); + break; + case 'k': + rotate(¤t, 1); + break; + } + draw_board(); +#ifdef DEBUG + print_screen(); +#endif +} + +void on_timer() { + fall(); + draw_board(); +} + +void trap_handler(void *epc, unsigned int cause) { + if (cause == 0x80000007) { + on_timer(); + } else if (cause == 0x8000000B){ + unsigned int ch = *VA_UART_RECV; + *VA_UART_SEND = ch; + on_input(ch); + } +} + +void init() { + clear_board(); + // Draw border + for (int r = 0; r < ROWS; ++r) { + putch_at(0, r, '|'); + putch_at(COLS << 1 | 1, r, '|'); + } + for (int c = 0; c <= (2 << COLS | 1); ++c) { + putch_at(c, ROWS, '-'); + } + int c = 8; + putch_at(c++, ROWS + 1, 'B'); + putch_at(c++, ROWS + 1, 'e'); + putch_at(c++, ROWS + 1, 'g'); + putch_at(c++, ROWS + 1, 'i'); + putch_at(c++, ROWS + 1, 'n'); + putch_at(c++, ROWS + 1, ' '); + c = 6; + putch_at(c++, ROWS + 3, 'P'); + putch_at(c++, ROWS + 3, 'a'); + putch_at(c++, ROWS + 3, 'g'); + putch_at(c++, ROWS + 3, 'i'); + putch_at(c++, ROWS + 3, 'n'); + putch_at(c++, ROWS + 3, 'g'); + c++; + putch_at(c++, ROWS + 3, 'h'); + putch_at(c++, ROWS + 3, 'r'); + putch_at(c++, ROWS + 3, 'p'); + c = 9; + putch_at(c++, ROWS + 4, '2'); + putch_at(c++, ROWS + 4, '0'); + putch_at(c++, ROWS + 4, '2'); + putch_at(c++, ROWS + 4, '2'); + init_block(¤t, rand_type(), 4, 0); + score = 0; + draw_board(); +} + +int alloc(){ + int index = 0; + int max = 8; + while(index < max){ + if(pm[index] == 0){ + pm[index] = 1; + break; + } + index++; + } + return index == max ? -1 : index; +} + +int map(pagetable_t pgtbl,uint32 va,uint32 pa,int perm){ + int t; + if((pgtbl[PX(1,va)] & PTE_V )!= PTE_V){ //前缀不存在 + t=alloc(); //申请一个页给前缀页表 + if(t>=0){ + pgtbl[PX(1,va)] = PA2PTE(t<<12) | PTE_V; + }else{ + return -1; + } + } + int* n = (void*)PTE2PA(pgtbl[PX(1,va)]); + n[PX(0,va)] = PA2PTE(pa) | perm | PTE_V; + return 0; +} + +void kvminit(){ + //init global valuable + for(int i=0;i<8;i++){ + pm[i] = 0; + } + timercount = 0; + + pagetable_t pgtbl = (void*)PAGEDIR_BASE; + // memoryset(pgtbl,0,PGSIZE); //后面需要读这个内存,所以先初始化 + for(int i=0;i>2;i++){ + pgtbl[i]=0; + } + + pm[PAGEDIR_BASE >> 12] = 1; + pm[0]=1; + pm[1]=1; + pm[2]=1; + pm[3]=1; + pm[4]=1; + //create pte mmap for text + map(pgtbl,PAGEDIR_BASE,PAGEDIR_BASE,PTE_R | PTE_W); + map(pgtbl,0x0,0x0, PTE_W | PTE_R ); //kernel stack + map(pgtbl,0x1000,0x1000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x2000,0x2000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x3000,0x3000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,0x4000,0x4000, PTE_W | PTE_R | PTE_X ); // + map(pgtbl,VA_VRAM_BASE,VRAM_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_VRAM_BASE + PGSIZE,VRAM_BASE + PGSIZE, PTE_W | PTE_R); + map(pgtbl,VA_UART_BASE,UART_BASE, PTE_W | PTE_R ); // + map(pgtbl,VA_TIMER_BASE,TIMER_BASE, PTE_W | PTE_R ); // +} + +void clear_screen() { + int *vram = ((int *) VA_VRAM_BASE); + for (int i = 0; i < 600; ++i) vram[i] = 0x20202020; +} + +extern void enable_interrupt(); +extern void enable_paging(); + +int main() { +#ifdef DEBUG + unsigned char b[ROWS * COLS] = {0}; + board = b; + for (int i = 0; i < SCREEN_ROWS * SCREEN_COLS; ++i) screen[i] = '%'; + init(); +#else + kvminit(); + enable_paging(); + board = (unsigned char *) 16640; //0x4100 + clear_screen(); + init(); + *((unsigned int *) 4) = 0xDEADBEEF; + enable_interrupt(); + *VA_TIMER_ENABLED = 1; + *VA_TIMER_LIMIT = FALL_TIMER_LIMIT; + for (;;); +#endif +#ifdef DEBUG + on_input('a'); + on_input('a'); + on_input('s'); + on_input('s'); + on_input('s'); + for (int i = 21; i >= 0; --i) { + on_timer(); + } + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + for (int i = 21; i >= 0; --i) { + on_timer(); + } + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + on_input('d'); + for (int i = 21; i >= 0; --i) { + on_timer(); + add_score(10); + } + print_score(); + print_screen(); + return 0; +#endif +} diff --git a/lab3/src/main/resources/fibonacci.asmbin b/lab3/src/main/resources/fibonacci.asmbin index 6406933..91f7740 100644 Binary files a/lab3/src/main/resources/fibonacci.asmbin and b/lab3/src/main/resources/fibonacci.asmbin differ diff --git a/lab3/src/main/resources/hello.asmbin b/lab3/src/main/resources/hello.asmbin index 3ae6a55..27a4e32 100644 Binary files a/lab3/src/main/resources/hello.asmbin and b/lab3/src/main/resources/hello.asmbin differ diff --git a/lab3/src/main/resources/paging.asmbin b/lab3/src/main/resources/paging.asmbin new file mode 100644 index 0000000..45011d8 Binary files /dev/null and b/lab3/src/main/resources/paging.asmbin differ diff --git a/lab3/src/main/resources/quicksort.asmbin b/lab3/src/main/resources/quicksort.asmbin index ae8f834..60d10f4 100644 Binary files a/lab3/src/main/resources/quicksort.asmbin and b/lab3/src/main/resources/quicksort.asmbin differ diff --git a/lab3/src/main/resources/tetris.asmbin b/lab3/src/main/resources/tetris.asmbin index 4c9ee9a..fdeaeda 100644 Binary files a/lab3/src/main/resources/tetris.asmbin and b/lab3/src/main/resources/tetris.asmbin differ diff --git a/lab3/src/main/resources/tetris_mmu.asmbin b/lab3/src/main/resources/tetris_mmu.asmbin new file mode 100644 index 0000000..fe350f0 Binary files /dev/null and b/lab3/src/main/resources/tetris_mmu.asmbin differ diff --git a/lab4/csrc/CMakeLists.txt b/lab4/csrc/CMakeLists.txt index a445640..ee07b00 100644 --- a/lab4/csrc/CMakeLists.txt +++ b/lab4/csrc/CMakeLists.txt @@ -32,29 +32,6 @@ foreach(program IN LISTS ASM_PROGRAMS) set_target_properties(${program} PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT}) endforeach() -set(PROGRAMS litenes) -# NES Emulator -include_directories(${CMAKE_SOURCE_DIR}/LiteNES/include) -add_definitions(-DYATCPU) -add_library(fce - ${CMAKE_SOURCE_DIR}/LiteNES/src/fce/common.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/fce/cpu-addressing.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/fce/cpu.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/fce/fce.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/fce/memory.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/fce/mmc.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/fce/ppu.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/fce/psg.c -) -target_compile_options(fce PRIVATE "-O3") -add_executable(litenes - ${CMAKE_SOURCE_DIR}/LiteNES/src/main.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/hal.c - ${CMAKE_SOURCE_DIR}/LiteNES/src/rom.c -) -set_target_properties(litenes PROPERTIES LINK_DEPENDS ${LINKER_SCRIPT}) -target_link_libraries(litenes prelude fce ${LINKER_FLAGS}) - # Copy the .text and .data section to .asmbin files foreach(program IN LISTS C_PROGRAMS ASM_PROGRAMS PROGRAMS) add_custom_command( diff --git a/lab4/src/main/resources/fibonacci.asmbin b/lab4/src/main/resources/fibonacci.asmbin index 529496d..91f7740 100644 Binary files a/lab4/src/main/resources/fibonacci.asmbin and b/lab4/src/main/resources/fibonacci.asmbin differ diff --git a/lab4/src/main/resources/hello.asmbin b/lab4/src/main/resources/hello.asmbin index cbd1665..27a4e32 100644 Binary files a/lab4/src/main/resources/hello.asmbin and b/lab4/src/main/resources/hello.asmbin differ diff --git a/lab4/src/main/resources/paging.asmbin b/lab4/src/main/resources/paging.asmbin new file mode 100644 index 0000000..45011d8 Binary files /dev/null and b/lab4/src/main/resources/paging.asmbin differ diff --git a/lab4/src/main/resources/quicksort.asmbin b/lab4/src/main/resources/quicksort.asmbin index ddf0f04..60d10f4 100644 Binary files a/lab4/src/main/resources/quicksort.asmbin and b/lab4/src/main/resources/quicksort.asmbin differ diff --git a/lab4/src/main/resources/tetris.asmbin b/lab4/src/main/resources/tetris.asmbin index 3d31324..fdeaeda 100644 Binary files a/lab4/src/main/resources/tetris.asmbin and b/lab4/src/main/resources/tetris.asmbin differ diff --git a/lab4/src/main/resources/tetris_mmu.asmbin b/lab4/src/main/resources/tetris_mmu.asmbin new file mode 100644 index 0000000..fe350f0 Binary files /dev/null and b/lab4/src/main/resources/tetris_mmu.asmbin differ