
qsys_tutorial_hexs.elf:     file format elf32-littlenios2
qsys_tutorial_hexs.elf
architecture: nios2, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x00000020

Program Header:
    LOAD off    0x00001000 vaddr 0x00000000 paddr 0x00000000 align 2**12
         filesz 0x00000020 memsz 0x00000020 flags r-x
    LOAD off    0x00001020 vaddr 0x00000020 paddr 0x00000020 align 2**12
         filesz 0x00000f68 memsz 0x00000f68 flags r-x
    LOAD off    0x00001f88 vaddr 0x00000f88 paddr 0x00000f90 align 2**12
         filesz 0x00000008 memsz 0x00000008 flags rw-
    LOAD off    0x00001f98 vaddr 0x00000f98 paddr 0x00000f98 align 2**12
         filesz 0x00000000 memsz 0x00000064 flags rw-

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .entry        00000020  00000000  00000000  00001000  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .text         00000cbc  00000020  00000020  00001020  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  2 .rodata       000002ac  00000cdc  00000cdc  00001cdc  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .rwdata       00000008  00000f88  00000f90  00001f88  2**2
                  CONTENTS, ALLOC, LOAD, DATA, SMALL_DATA
  4 .bss          00000064  00000f98  00000f98  00001f98  2**2
                  ALLOC, SMALL_DATA
  5 .comment      00000026  00000000  00000000  00001f90  2**0
                  CONTENTS, READONLY
  6 .debug_aranges 00000248  00000000  00000000  00001fb8  2**3
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_pubnames 000003a2  00000000  00000000  00002200  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_info   00001254  00000000  00000000  000025a2  2**0
                  CONTENTS, READONLY, DEBUGGING
  9 .debug_abbrev 00000aa5  00000000  00000000  000037f6  2**0
                  CONTENTS, READONLY, DEBUGGING
 10 .debug_line   0000204a  00000000  00000000  0000429b  2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .debug_frame  00000384  00000000  00000000  000062e8  2**2
                  CONTENTS, READONLY, DEBUGGING
 12 .debug_str    00000895  00000000  00000000  0000666c  2**0
                  CONTENTS, READONLY, DEBUGGING
 13 .debug_loc    00000b67  00000000  00000000  00006f01  2**0
                  CONTENTS, READONLY, DEBUGGING
 14 .debug_alt_sim_info 00000010  00000000  00000000  00007a68  2**2
                  CONTENTS, READONLY, DEBUGGING
 15 .debug_ranges 00000020  00000000  00000000  00007a78  2**3
                  CONTENTS, READONLY, DEBUGGING
 16 .thread_model 00000003  00000000  00000000  00008b60  2**0
                  CONTENTS, READONLY
 17 .cpu          0000000f  00000000  00000000  00008b63  2**0
                  CONTENTS, READONLY
 18 .qsys         00000001  00000000  00000000  00008b72  2**0
                  CONTENTS, READONLY
 19 .simulation_enabled 00000001  00000000  00000000  00008b73  2**0
                  CONTENTS, READONLY
 20 .stderr_dev   00000009  00000000  00000000  00008b74  2**0
                  CONTENTS, READONLY
 21 .stdin_dev    00000009  00000000  00000000  00008b7d  2**0
                  CONTENTS, READONLY
 22 .stdout_dev   00000009  00000000  00000000  00008b86  2**0
                  CONTENTS, READONLY
 23 .sopc_system_name 0000000b  00000000  00000000  00008b8f  2**0
                  CONTENTS, READONLY
 24 .quartus_project_dir 00000030  00000000  00000000  00008b9a  2**0
                  CONTENTS, READONLY
 25 .sopcinfo     0006c868  00000000  00000000  00008bca  2**0
                  CONTENTS, READONLY
SYMBOL TABLE:
00000000 l    d  .entry	00000000 .entry
00000020 l    d  .text	00000000 .text
00000cdc l    d  .rodata	00000000 .rodata
00000f88 l    d  .rwdata	00000000 .rwdata
00000f98 l    d  .bss	00000000 .bss
00000000 l    d  .comment	00000000 .comment
00000000 l    d  .debug_aranges	00000000 .debug_aranges
00000000 l    d  .debug_pubnames	00000000 .debug_pubnames
00000000 l    d  .debug_info	00000000 .debug_info
00000000 l    d  .debug_abbrev	00000000 .debug_abbrev
00000000 l    d  .debug_line	00000000 .debug_line
00000000 l    d  .debug_frame	00000000 .debug_frame
00000000 l    d  .debug_str	00000000 .debug_str
00000000 l    d  .debug_loc	00000000 .debug_loc
00000000 l    d  .debug_alt_sim_info	00000000 .debug_alt_sim_info
00000000 l    d  .debug_ranges	00000000 .debug_ranges
00000058 l       .text	00000000 alt_after_alt_main
00000000 l    df *ABS*	00000000 hello_world_small.c
00000000 l    df *ABS*	00000000 hex_encoder.c
00000000 l    df *ABS*	00000000 hex_out.c
00000000 l    df *ABS*	00000000 input_int.c
00000f99 l     O .bss	00000001 status.1370
00000000 l    df *ABS*	00000000 sys_memory.c
00000fac l     O .bss	00000040 memory
00000000 l    df *ABS*	00000000 sys_register.c
00000000 l    df *ABS*	00000000 system.c
00000000 l    df *ABS*	00000000 lib2-divmod.c
000008dc l     F .text	0000007c udivmodsi4
00000000 l    df *ABS*	00000000 ctype_.c
00000e05 l     O .rodata	00000180 _ctype_b
00000000 l    df *ABS*	00000000 alt_load.c
00000a28 l     F .text	00000020 alt_load_section
00000000 l    df *ABS*	00000000 alt_main.c
00000000 l    df *ABS*	00000000 alt_printf.c
00000000 l    df *ABS*	00000000 alt_putchar.c
00000000 l    df *ABS*	00000000 alt_sys_init.c
00000000 l    df *ABS*	00000000 altera_avalon_jtag_uart_write.c
00000000 l    df *ABS*	00000000 alt_dcache_flush_all.c
00000000 l    df *ABS*	00000000 alt_icache_flush_all.c
00000000 l    df *ABS*	00000000 altera_nios2_qsys_irq.c
00000ab4 g     F .text	0000002c alt_main
00000f90 g       *ABS*	00000000 __flash_rwdata_start
00000588 g     F .text	00000050 clear_block
00000f8c g     O .rwdata	00000004 jtag_uart
00000000 g     F .entry	0000000c __reset
00000020 g       *ABS*	00000000 __flash_exceptions_start
00000fa4 g     O .bss	00000004 alt_argv
00008f88 g       *ABS*	00000000 _gp
00000a18 g     F .text	00000008 __udivsi3
00000824 g     F .text	00000070 memory_store
00000ffc g       *ABS*	00000000 __bss_end
00000f88 g     O .rwdata	00000004 __ctype_ptr
00000ccc g     F .text	00000004 alt_dcache_flush_all
00000fec g     O .bss	0000000d global_registers
00000f90 g       *ABS*	00000000 __ram_rwdata_end
00000000 g       *ABS*	00000000 __alt_mem_onchip_memory
00000f88 g       *ABS*	00000000 __ram_rodata_end
00000a20 g     F .text	00000008 __umodsi3
00000ffc g       *ABS*	00000000 end
00001000 g       *ABS*	00000000 __alt_stack_pointer
00000c98 g     F .text	00000034 altera_avalon_jtag_uart_write
00000ae0 g     F .text	00000144 alt_printf
000005d8 g     F .text	000000fc print_number
00000020 g     F .text	0000003c _start
000004ac g     F .text	000000dc print_block
00000c74 g     F .text	00000004 alt_sys_init
00000f88 g       *ABS*	00000000 __ram_rwdata_start
00000cdc g       *ABS*	00000000 __ram_rodata_start
000008b0 g     F .text	0000002c panic
00000ffc g       *ABS*	00000000 __alt_stack_base
0000005c g     F .text	00000084 init
00000f98 g       *ABS*	00000000 __bss_start
000000e0 g     F .text	00000014 main
00000fa8 g     O .bss	00000004 alt_envp
000000f4 g     F .text	00000124 encodeNumHex
0000076c g     F .text	00000004 in_int
00000958 g     F .text	00000060 __divsi3
00000cdc g       *ABS*	00000000 __flash_rodata_start
00000c78 g     F .text	00000020 alt_irq_init
000006d4 g     F .text	00000098 push_int
00000fa0 g     O .bss	00000004 alt_argc
00000f9c g     O .bss	00000004 global_current_memory
00000020 g       *ABS*	00000000 __ram_exceptions_start
00000218 g     F .text	00000294 encodeLatHex
00000f90 g       *ABS*	00000000 _edata
00000ffc g       *ABS*	00000000 _end
00000020 g       *ABS*	00000000 __ram_exceptions_end
00000770 g     F .text	00000044 memory_init
00000cd4 g     F .text	00000008 altera_nios2_qsys_irq_init
0000000c g       .entry	00000000 exit
000007b4 g     F .text	00000070 memory_load
000009b8 g     F .text	00000060 __modsi3
00001000 g       *ABS*	00000000 __alt_data_end
00000d04 g     O .rodata	00000101 _ctype_
00000894 g     F .text	0000001c registers_init
0000000c g       .entry	00000000 _exit
00000c24 g     F .text	00000050 alt_putchar
00000cd0 g     F .text	00000004 alt_icache_flush_all
00000a48 g     F .text	0000006c alt_load
00000f98 g     O .bss	00000001 PUSH_EVENT



Disassembly of section .entry:

00000000 <__reset>:
 * Jump to the _start entry point in the .text section if reset code
 * is allowed or if optimizing for RTL simulation.
 */
#if defined(ALT_ALLOW_CODE_AT_RESET) || defined(ALT_SIM_OPTIMIZE)
    /* Jump to the _start entry point in the .text section. */
    movhi r1, %hi(_start)
   0:	00400034 	movhi	at,0
    ori r1, r1, %lo(_start)
   4:	08400814 	ori	at,at,32
    jmp r1
   8:	0800683a 	jmp	at

0000000c <_exit>:
	...

Disassembly of section .text:

00000020 <_start>:
#if (NIOS2_NUM_OF_SHADOW_REG_SETS == 0)    
    /*
     * Now that the caches are initialized, set up the stack pointer.
     * The value provided by the linker is assumed to be correctly aligned.
     */
    movhi sp, %hi(__alt_stack_pointer)
  20:	06c00034 	movhi	sp,0
    ori sp, sp, %lo(__alt_stack_pointer)
  24:	dec40014 	ori	sp,sp,4096

    /* Set up the global pointer. */
    movhi gp, %hi(_gp)
  28:	06800034 	movhi	gp,0
    ori gp, gp, %lo(_gp)
  2c:	d6a3e214 	ori	gp,gp,36744
 */
#ifndef ALT_SIM_OPTIMIZE
    /* Log that the BSS is about to be cleared. */
    ALT_LOG_PUTS(alt_log_msg_bss)

    movhi r2, %hi(__bss_start)
  30:	00800034 	movhi	r2,0
    ori r2, r2, %lo(__bss_start)
  34:	1083e614 	ori	r2,r2,3992

    movhi r3, %hi(__bss_end)
  38:	00c00034 	movhi	r3,0
    ori r3, r3, %lo(__bss_end)
  3c:	18c3ff14 	ori	r3,r3,4092

    beq r2, r3, 1f
  40:	10c00326 	beq	r2,r3,50 <_start+0x30>

0:
    stw zero, (r2)
  44:	10000015 	stw	zero,0(r2)
    addi r2, r2, 4
  48:	10800104 	addi	r2,r2,4
    bltu r2, r3, 0b
  4c:	10fffd36 	bltu	r2,r3,44 <_start+0x24>
     * section aren't defined until alt_load() has been called).
     */
    mov   et, zero
#endif

    call alt_load
  50:	0000a480 	call	a48 <alt_load>

    /* Log that alt_main is about to be called. */
    ALT_LOG_PUTS(alt_log_msg_alt_main)

    /* Call the C entry point. It should never return. */
    call alt_main
  54:	0000ab40 	call	ab4 <alt_main>

00000058 <alt_after_alt_main>:

    /* Wait in infinite loop in case alt_main does return. */
alt_after_alt_main:
    br alt_after_alt_main
  58:	003fff06 	br	58 <alt_after_alt_main>

0000005c <init>:

#define ledrs (volatile int *) 0x00020a0
#define push_switches (volatile char *) 0x0002080


void init() {
  5c:	defffd04 	addi	sp,sp,-12
  60:	dfc00215 	stw	ra,8(sp)
  64:	dc400115 	stw	r17,4(sp)
  68:	dc000015 	stw	r16,0(sp)
	registers_init();
  6c:	00008940 	call	894 <registers_init>
	memory_init();
  70:	00007700 	call	770 <memory_init>
	clear_block(HEX0_3); clear_block(HEX4_5); clear_block(HEX6_7);
  74:	04400044 	movi	r17,1
  78:	0009883a 	mov	r4,zero
  7c:	00005880 	call	588 <clear_block>
  80:	04000084 	movi	r16,2
  84:	8809883a 	mov	r4,r17
  88:	00005880 	call	588 <clear_block>
  8c:	8009883a 	mov	r4,r16
  90:	00005880 	call	588 <clear_block>
	print_block("he", 2, HEX6_7);
  94:	800b883a 	mov	r5,r16
  98:	800d883a 	mov	r6,r16
  9c:	01000034 	movhi	r4,0
  a0:	21033704 	addi	r4,r4,3292
  a4:	00004ac0 	call	4ac <print_block>
	print_block("lo", 2, HEX4_5);
  a8:	800b883a 	mov	r5,r16
  ac:	880d883a 	mov	r6,r17
  b0:	01000034 	movhi	r4,0
  b4:	21033804 	addi	r4,r4,3296
  b8:	00004ac0 	call	4ac <print_block>
	print_block("you1", 4, HEX0_3);
  bc:	01000034 	movhi	r4,0
  c0:	21033904 	addi	r4,r4,3300
  c4:	01400104 	movi	r5,4
  c8:	000d883a 	mov	r6,zero
}
  cc:	dfc00217 	ldw	ra,8(sp)
  d0:	dc400117 	ldw	r17,4(sp)
  d4:	dc000017 	ldw	r16,0(sp)
  d8:	dec00304 	addi	sp,sp,12
	registers_init();
	memory_init();
	clear_block(HEX0_3); clear_block(HEX4_5); clear_block(HEX6_7);
	print_block("he", 2, HEX6_7);
	print_block("lo", 2, HEX4_5);
	print_block("you1", 4, HEX0_3);
  dc:	00004ac1 	jmpi	4ac <print_block>

000000e0 <main>:
}

int main()
{
  e0:	deffff04 	addi	sp,sp,-4
  e4:	dfc00015 	stw	ra,0(sp)
	init();
  e8:	000005c0 	call	5c <init>
	while(1) {
		// interrupt
		in_int();
  ec:	000076c0 	call	76c <in_int>
  f0:	003ffe06 	br	ec <main+0xc>

000000f4 <encodeNumHex>:
#include "hex_encoder.h"
#include <ctype.h>

void encodeNumHex(int hex_i, int num) {
	char encoded = 0;
	switch (num) {
  f4:	00800244 	movi	r2,9
  f8:	11401336 	bltu	r2,r5,148 <encodeNumHex+0x54>
  fc:	2945883a 	add	r2,r5,r5
 100:	1085883a 	add	r2,r2,r2
 104:	00c00034 	movhi	r3,0
 108:	18c04604 	addi	r3,r3,280
 10c:	10c5883a 	add	r2,r2,r3
 110:	10800017 	ldw	r2,0(r2)
 114:	1000683a 	jmp	r2
 118:	00000150 	cmplti	zero,zero,5
 11c:	00000158 	cmpnei	zero,zero,5
 120:	00000160 	cmpeqi	zero,zero,5
 124:	00000168 	cmpgeui	zero,zero,5
 128:	00000170 	cmpltui	zero,zero,5
 12c:	00000178 	rdprs	zero,zero,5
 130:	00000180 	call	18 <_exit+0xc>
 134:	00000188 	cmpgei	zero,zero,6
 138:	00000148 	cmpgei	zero,zero,5
 13c:	00000140 	call	14 <_exit+0x8>
 140:	01400404 	movi	r5,16
 144:	00001106 	br	18c <encodeNumHex+0x98>
 148:	000b883a 	mov	r5,zero
 14c:	00000f06 	br	18c <encodeNumHex+0x98>
 150:	01401004 	movi	r5,64
 154:	00000d06 	br	18c <encodeNumHex+0x98>
	case 0:
		encoded = (char)0x40;	// 100 0000
		break;
 158:	017ffe44 	movi	r5,-7
 15c:	00000b06 	br	18c <encodeNumHex+0x98>
	case 1:
		encoded = (char)0xF9;	// 111 1001
		break;
 160:	01400904 	movi	r5,36
 164:	00000906 	br	18c <encodeNumHex+0x98>
	case 2:
		encoded = (char)0x24;	// 010 0100
		break;
 168:	01400c04 	movi	r5,48
 16c:	00000706 	br	18c <encodeNumHex+0x98>
	case 3:
		encoded = (char)0x30;	// 011 0000
		break;
 170:	01400644 	movi	r5,25
 174:	00000506 	br	18c <encodeNumHex+0x98>
	case 4:
		encoded = (char)0x19;	// 001 1001
		break;
 178:	01400484 	movi	r5,18
 17c:	00000306 	br	18c <encodeNumHex+0x98>
	case 5:
		encoded = (char)0x12;	// 001 0010
		break;
 180:	01400084 	movi	r5,2
 184:	00000106 	br	18c <encodeNumHex+0x98>
	case 6:
		encoded = (char)0x02;	// 000 0010
		break;
 188:	01401604 	movi	r5,88
	default:
		encoded = 0;
		break;
	}

	switch (hex_i) {
 18c:	008001c4 	movi	r2,7
 190:	11002036 	bltu	r2,r4,214 <encodeNumHex+0x120>
 194:	2105883a 	add	r2,r4,r4
 198:	1085883a 	add	r2,r2,r2
 19c:	00c00034 	movhi	r3,0
 1a0:	18c06c04 	addi	r3,r3,432
 1a4:	10c5883a 	add	r2,r2,r3
 1a8:	10800017 	ldw	r2,0(r2)
 1ac:	1000683a 	jmp	r2
 1b0:	000001d0 	cmplti	zero,zero,7
 1b4:	000001d8 	cmpnei	zero,zero,7
 1b8:	000001e0 	cmpeqi	zero,zero,7
 1bc:	000001e8 	cmpgeui	zero,zero,7
 1c0:	000001f0 	cmpltui	zero,zero,7
 1c4:	000001f8 	rdprs	zero,zero,7
 1c8:	00000200 	call	20 <_start>
 1cc:	0000020c 	andi	zero,zero,8
	case 0:
		*hex0 = encoded;
 1d0:	00881c04 	movi	r2,8304
 1d4:	00000b06 	br	204 <encodeNumHex+0x110>
		break;
	case 1:
		*hex1 = encoded;
 1d8:	00881804 	movi	r2,8288
 1dc:	00000906 	br	204 <encodeNumHex+0x110>
		break;
	case 2:
		*hex2 = encoded;
 1e0:	00881404 	movi	r2,8272
 1e4:	00000706 	br	204 <encodeNumHex+0x110>
		break;
	case 3:
		*hex3 = encoded;
 1e8:	00881004 	movi	r2,8256
 1ec:	00000506 	br	204 <encodeNumHex+0x110>
		break;
	case 4:
		*hex4 = encoded;
 1f0:	00880c04 	movi	r2,8240
 1f4:	00000306 	br	204 <encodeNumHex+0x110>
		break;
	case 5:
		*hex5 = encoded;
 1f8:	00880804 	movi	r2,8224
 1fc:	00000106 	br	204 <encodeNumHex+0x110>
		break;
	case 6:
		*hex6 = encoded;
 200:	00880404 	movi	r2,8208
 204:	11400005 	stb	r5,0(r2)
 208:	f800283a 	ret
		break;
	case 7:
		*hex7 = encoded;
 20c:	00880004 	movi	r2,8192
 210:	11400005 	stb	r5,0(r2)
 214:	f800283a 	ret

00000218 <encodeLatHex>:
}

void encodeLatHex(int hex_i, char c) {
	char encoded = 0;

	if (isdigit(c)) {
 218:	00800034 	movhi	r2,0
 21c:	1083e204 	addi	r2,r2,3976
 220:	10800017 	ldw	r2,0(r2)
 224:	29403fcc 	andi	r5,r5,255
 228:	2940201c 	xori	r5,r5,128
 22c:	297fe004 	addi	r5,r5,-128
 230:	2885883a 	add	r2,r5,r2
 234:	10800003 	ldbu	r2,0(r2)
	default:
		break;
	}
}

void encodeLatHex(int hex_i, char c) {
 238:	2007883a 	mov	r3,r4
	char encoded = 0;

	if (isdigit(c)) {
 23c:	1080010c 	andi	r2,r2,4
 240:	10000226 	beq	r2,zero,24c <encodeLatHex+0x34>
		encodeNumHex(hex_i, c-'0');
 244:	297ff404 	addi	r5,r5,-48
 248:	00000f41 	jmpi	f4 <encodeNumHex>
		return;
	}

	switch (c) {
 24c:	00801b44 	movi	r2,109
 250:	28805a26 	beq	r5,r2,3bc <encodeLatHex+0x1a4>
 254:	11401d16 	blt	r2,r5,2cc <encodeLatHex+0xb4>
 258:	00801984 	movi	r2,102
 25c:	28804926 	beq	r5,r2,384 <encodeLatHex+0x16c>
 260:	11400e16 	blt	r2,r5,29c <encodeLatHex+0x84>
 264:	00801884 	movi	r2,98
 268:	28803e26 	beq	r5,r2,364 <encodeLatHex+0x14c>
 26c:	11400716 	blt	r2,r5,28c <encodeLatHex+0x74>
 270:	00800b44 	movi	r2,45
 274:	28803726 	beq	r5,r2,354 <encodeLatHex+0x13c>
 278:	00801844 	movi	r2,97
 27c:	28803726 	beq	r5,r2,35c <encodeLatHex+0x144>
 280:	00800804 	movi	r2,32
 284:	28802f1e 	bne	r5,r2,344 <encodeLatHex+0x12c>
 288:	00003006 	br	34c <encodeLatHex+0x134>
 28c:	00801904 	movi	r2,100
 290:	28803826 	beq	r5,r2,374 <encodeLatHex+0x15c>
 294:	11403916 	blt	r2,r5,37c <encodeLatHex+0x164>
 298:	00003406 	br	36c <encodeLatHex+0x154>
 29c:	00801a44 	movi	r2,105
 2a0:	28803e26 	beq	r5,r2,39c <encodeLatHex+0x184>
 2a4:	11400516 	blt	r2,r5,2bc <encodeLatHex+0xa4>
 2a8:	008019c4 	movi	r2,103
 2ac:	28803726 	beq	r5,r2,38c <encodeLatHex+0x174>
 2b0:	00801a04 	movi	r2,104
 2b4:	2880231e 	bne	r5,r2,344 <encodeLatHex+0x12c>
 2b8:	00003606 	br	394 <encodeLatHex+0x17c>
 2bc:	00801ac4 	movi	r2,107
 2c0:	28803a26 	beq	r5,r2,3ac <encodeLatHex+0x194>
 2c4:	11403b16 	blt	r2,r5,3b4 <encodeLatHex+0x19c>
 2c8:	00003606 	br	3a4 <encodeLatHex+0x18c>
 2cc:	00801d04 	movi	r2,116
 2d0:	28804826 	beq	r5,r2,3f4 <encodeLatHex+0x1dc>
 2d4:	11400c16 	blt	r2,r5,308 <encodeLatHex+0xf0>
 2d8:	00801c04 	movi	r2,112
 2dc:	28803d26 	beq	r5,r2,3d4 <encodeLatHex+0x1bc>
 2e0:	11400516 	blt	r2,r5,2f8 <encodeLatHex+0xe0>
 2e4:	00801b84 	movi	r2,110
 2e8:	28803626 	beq	r5,r2,3c4 <encodeLatHex+0x1ac>
 2ec:	00801bc4 	movi	r2,111
 2f0:	2880141e 	bne	r5,r2,344 <encodeLatHex+0x12c>
 2f4:	00003506 	br	3cc <encodeLatHex+0x1b4>
 2f8:	00801c84 	movi	r2,114
 2fc:	28803926 	beq	r5,r2,3e4 <encodeLatHex+0x1cc>
 300:	11403a16 	blt	r2,r5,3ec <encodeLatHex+0x1d4>
 304:	00003506 	br	3dc <encodeLatHex+0x1c4>
 308:	00801dc4 	movi	r2,119
 30c:	28803f26 	beq	r5,r2,40c <encodeLatHex+0x1f4>
 310:	11400516 	blt	r2,r5,328 <encodeLatHex+0x110>
 314:	00801d44 	movi	r2,117
 318:	28803826 	beq	r5,r2,3fc <encodeLatHex+0x1e4>
 31c:	00801d84 	movi	r2,118
 320:	2880081e 	bne	r5,r2,344 <encodeLatHex+0x12c>
 324:	00003706 	br	404 <encodeLatHex+0x1ec>
 328:	00801e44 	movi	r2,121
 32c:	28803b26 	beq	r5,r2,41c <encodeLatHex+0x204>
 330:	28803816 	blt	r5,r2,414 <encodeLatHex+0x1fc>
 334:	00801e84 	movi	r2,122
 338:	2880021e 	bne	r5,r2,344 <encodeLatHex+0x12c>
 33c:	01401904 	movi	r5,100
 340:	00003706 	br	420 <encodeLatHex+0x208>
 344:	000b883a 	mov	r5,zero
 348:	00003506 	br	420 <encodeLatHex+0x208>
 34c:	017fffc4 	movi	r5,-1
 350:	00003306 	br	420 <encodeLatHex+0x208>
	case ' ':
		encoded = (char)0xFF;	// 111 1111
		break;
 354:	01400fc4 	movi	r5,63
 358:	00003106 	br	420 <encodeLatHex+0x208>
	case '-':
		encoded = (char)0x3F;	// 011 1111
		break;
 35c:	01400204 	movi	r5,8
 360:	00002f06 	br	420 <encodeLatHex+0x208>
	case 'a':
		encoded = (char)0x08;	// 000 1000
		break;
 364:	014000c4 	movi	r5,3
 368:	00002d06 	br	420 <encodeLatHex+0x208>
	case 'b':
		encoded = (char)0x03;	// 000 0011
		break;
 36c:	014009c4 	movi	r5,39
 370:	00002b06 	br	420 <encodeLatHex+0x208>
	case 'c':
		encoded = (char)0x27;	// 010 0111
		break;
 374:	01400844 	movi	r5,33
 378:	00002906 	br	420 <encodeLatHex+0x208>
	case 'd':
		encoded = (char)0x21;	// 010 0001
		break;
 37c:	01400184 	movi	r5,6
 380:	00002706 	br	420 <encodeLatHex+0x208>
	case 'e':
		encoded = (char)0x06;	// 000 0110
		break;
 384:	01400384 	movi	r5,14
 388:	00002506 	br	420 <encodeLatHex+0x208>
	case 'f':
		encoded = (char)0x0E;	// 000 1110
		break;
 38c:	01401084 	movi	r5,66
 390:	00002306 	br	420 <encodeLatHex+0x208>
	case 'g':
		encoded = (char)0x42;	// 100 0010
		break;
 394:	014002c4 	movi	r5,11
 398:	00002106 	br	420 <encodeLatHex+0x208>
	case 'h':
		encoded = (char)0x0B;	// 000 1011
		break;
 39c:	017ffec4 	movi	r5,-5
 3a0:	00001f06 	br	420 <encodeLatHex+0x208>
	case 'i':
		encoded = (char)0xFB;	// 111 1011
		break;
 3a4:	01401844 	movi	r5,97
 3a8:	00001d06 	br	420 <encodeLatHex+0x208>
	case 'j':
		encoded = (char)0x61;	// 110 0001
		break;
 3ac:	01400284 	movi	r5,10
 3b0:	00001b06 	br	420 <encodeLatHex+0x208>
	case 'k':
		encoded = (char)0x0A;	// 000 1010
		break;
 3b4:	014011c4 	movi	r5,71
 3b8:	00001906 	br	420 <encodeLatHex+0x208>
	case 'l':
		encoded = (char)0x47;	// 100 0111
		break;
 3bc:	01401204 	movi	r5,72
 3c0:	00001706 	br	420 <encodeLatHex+0x208>
	case 'm':
		encoded = (char)0x48;	// 100 1000
		break;
 3c4:	01400ac4 	movi	r5,43
 3c8:	00001506 	br	420 <encodeLatHex+0x208>
	case 'n':
		encoded = (char)0x2B;	// 010 1011
		break;
 3cc:	014008c4 	movi	r5,35
 3d0:	00001306 	br	420 <encodeLatHex+0x208>
	case 'o':
		encoded = (char)0x23;	// 010 0011
		break;
 3d4:	01400304 	movi	r5,12
 3d8:	00001106 	br	420 <encodeLatHex+0x208>
	case 'p':
		encoded = (char)0x0C;	// 000 1100
		break;
 3dc:	01400104 	movi	r5,4
 3e0:	00000f06 	br	420 <encodeLatHex+0x208>
	case 'q':
		encoded = (char)0x04;	// 000 0100
		break;
 3e4:	01400bc4 	movi	r5,47
 3e8:	00000d06 	br	420 <encodeLatHex+0x208>
	case 'r':
		encoded = (char)0x2F;	// 010 1111
		break;
 3ec:	014004c4 	movi	r5,19
 3f0:	00000b06 	br	420 <encodeLatHex+0x208>
	case 's':
		encoded = (char)0x13;	// 001 0011
		break;
 3f4:	014001c4 	movi	r5,7
 3f8:	00000906 	br	420 <encodeLatHex+0x208>
	case 't':
		encoded = (char)0x07;	// 000 0111
		break;
 3fc:	014018c4 	movi	r5,99
 400:	00000706 	br	420 <encodeLatHex+0x208>
	case 'u':
		encoded = (char)0x63;	// 110 0011
		break;
 404:	01401044 	movi	r5,65
 408:	00000506 	br	420 <encodeLatHex+0x208>
	case 'v':
		encoded = (char)0x41;	// 100 0001
		break;
 40c:	01400044 	movi	r5,1
 410:	00000306 	br	420 <encodeLatHex+0x208>
	case 'w':
		encoded = (char)0x01;	// 000 0001
		break;
 414:	01400244 	movi	r5,9
 418:	00000106 	br	420 <encodeLatHex+0x208>
	case 'x':
		encoded = (char)0x09;	// 000 1001
		break;
 41c:	01400444 	movi	r5,17
	default:
		encoded = 0;
		break;
	}

	switch (hex_i) {
 420:	008001c4 	movi	r2,7
 424:	10c02036 	bltu	r2,r3,4a8 <encodeLatHex+0x290>
 428:	18c5883a 	add	r2,r3,r3
 42c:	1085883a 	add	r2,r2,r2
 430:	00c00034 	movhi	r3,0
 434:	18c11104 	addi	r3,r3,1092
 438:	10c5883a 	add	r2,r2,r3
 43c:	10800017 	ldw	r2,0(r2)
 440:	1000683a 	jmp	r2
 444:	00000464 	muli	zero,zero,17
 448:	0000046c 	andhi	zero,zero,17
 44c:	00000474 	movhi	zero,17
 450:	0000047c 	xorhi	zero,zero,17
 454:	00000484 	movi	zero,18
 458:	0000048c 	andi	zero,zero,18
 45c:	00000494 	movui	zero,18
 460:	000004a0 	cmpeqi	zero,zero,18
	case 0:
		*hex0 = encoded;
 464:	00881c04 	movi	r2,8304
 468:	00000b06 	br	498 <encodeLatHex+0x280>
		break;
	case 1:
		*hex1 = encoded;
 46c:	00881804 	movi	r2,8288
 470:	00000906 	br	498 <encodeLatHex+0x280>
		break;
	case 2:
		*hex2 = encoded;
 474:	00881404 	movi	r2,8272
 478:	00000706 	br	498 <encodeLatHex+0x280>
		break;
	case 3:
		*hex3 = encoded;
 47c:	00881004 	movi	r2,8256
 480:	00000506 	br	498 <encodeLatHex+0x280>
		break;
	case 4:
		*hex4 = encoded;
 484:	00880c04 	movi	r2,8240
 488:	00000306 	br	498 <encodeLatHex+0x280>
		break;
	case 5:
		*hex5 = encoded;
 48c:	00880804 	movi	r2,8224
 490:	00000106 	br	498 <encodeLatHex+0x280>
		break;
	case 6:
		*hex6 = encoded;
 494:	00880404 	movi	r2,8208
 498:	11400005 	stb	r5,0(r2)
 49c:	f800283a 	ret
		break;
	case 7:
		*hex7 = encoded;
 4a0:	00880004 	movi	r2,8192
 4a4:	11400005 	stb	r5,0(r2)
 4a8:	f800283a 	ret

000004ac <print_block>:
 */
#include "hex_out.h"
#include "hex_encoder.h"
#include "system.h"

void print_block(char * str, unsigned int size, enum BLOCK_N block_i) {
 4ac:	defffc04 	addi	sp,sp,-16
 4b0:	dc400115 	stw	r17,4(sp)
 4b4:	dc000015 	stw	r16,0(sp)
 4b8:	dfc00315 	stw	ra,12(sp)
 4bc:	dc800215 	stw	r18,8(sp)
 4c0:	2021883a 	mov	r16,r4
 4c4:	2823883a 	mov	r17,r5
	int i;
	if (block_i == HEX0_3) {
 4c8:	30000d1e 	bne	r6,zero,500 <print_block+0x54>
		if (size > 4) panic();
 4cc:	00800104 	movi	r2,4
 4d0:	1140012e 	bgeu	r2,r5,4d8 <print_block+0x2c>
 4d4:	00008b00 	call	8b0 <panic>
 4d8:	8461883a 	add	r16,r16,r17
 4dc:	0025883a 	mov	r18,zero
 4e0:	00000306 	br	4f0 <print_block+0x44>
		for (i = 0; i < size; i++) {
			encodeLatHex(i,str[size-1-i]);
 4e4:	81400007 	ldb	r5,0(r16)

void print_block(char * str, unsigned int size, enum BLOCK_N block_i) {
	int i;
	if (block_i == HEX0_3) {
		if (size > 4) panic();
		for (i = 0; i < size; i++) {
 4e8:	94800044 	addi	r18,r18,1
			encodeLatHex(i,str[size-1-i]);
 4ec:	00002180 	call	218 <encodeLatHex>
 4f0:	9009883a 	mov	r4,r18

void print_block(char * str, unsigned int size, enum BLOCK_N block_i) {
	int i;
	if (block_i == HEX0_3) {
		if (size > 4) panic();
		for (i = 0; i < size; i++) {
 4f4:	843fffc4 	addi	r16,r16,-1
 4f8:	947ffa1e 	bne	r18,r17,4e4 <print_block+0x38>
 4fc:	00001c06 	br	570 <print_block+0xc4>
			encodeLatHex(i,str[size-1-i]);
		}
	}
	else if (block_i == HEX4_5) {
 500:	00800044 	movi	r2,1
 504:	30800d1e 	bne	r6,r2,53c <print_block+0x90>
		if (size > 2) panic();
 508:	00800084 	movi	r2,2
 50c:	1140012e 	bgeu	r2,r5,514 <print_block+0x68>
 510:	00008b00 	call	8b0 <panic>
 514:	8461883a 	add	r16,r16,r17
 518:	0025883a 	mov	r18,zero
 51c:	00000306 	br	52c <print_block+0x80>
		for (i = 0; i < size; i++) {
			encodeLatHex(i+4,str[size-1-i]);
 520:	81400007 	ldb	r5,0(r16)
			encodeLatHex(i,str[size-1-i]);
		}
	}
	else if (block_i == HEX4_5) {
		if (size > 2) panic();
		for (i = 0; i < size; i++) {
 524:	94800044 	addi	r18,r18,1
			encodeLatHex(i+4,str[size-1-i]);
 528:	00002180 	call	218 <encodeLatHex>
 52c:	91000104 	addi	r4,r18,4
			encodeLatHex(i,str[size-1-i]);
		}
	}
	else if (block_i == HEX4_5) {
		if (size > 2) panic();
		for (i = 0; i < size; i++) {
 530:	843fffc4 	addi	r16,r16,-1
 534:	947ffa1e 	bne	r18,r17,520 <print_block+0x74>
 538:	00000d06 	br	570 <print_block+0xc4>
			encodeLatHex(i+4,str[size-1-i]);
		}
	}
	else if (block_i == HEX6_7) {
 53c:	00800084 	movi	r2,2
 540:	30800b1e 	bne	r6,r2,570 <print_block+0xc4>
		if (size > 2) panic();
 544:	3140012e 	bgeu	r6,r5,54c <print_block+0xa0>
 548:	00008b00 	call	8b0 <panic>
 54c:	8461883a 	add	r16,r16,r17
 550:	0025883a 	mov	r18,zero
 554:	00000306 	br	564 <print_block+0xb8>
		for (i = 0; i < size; i++) {
			encodeLatHex(i+6,str[size-1-i]);
 558:	81400007 	ldb	r5,0(r16)
			encodeLatHex(i+4,str[size-1-i]);
		}
	}
	else if (block_i == HEX6_7) {
		if (size > 2) panic();
		for (i = 0; i < size; i++) {
 55c:	94800044 	addi	r18,r18,1
			encodeLatHex(i+6,str[size-1-i]);
 560:	00002180 	call	218 <encodeLatHex>
 564:	91000184 	addi	r4,r18,6
			encodeLatHex(i+4,str[size-1-i]);
		}
	}
	else if (block_i == HEX6_7) {
		if (size > 2) panic();
		for (i = 0; i < size; i++) {
 568:	843fffc4 	addi	r16,r16,-1
 56c:	947ffa1e 	bne	r18,r17,558 <print_block+0xac>
			encodeLatHex(i+6,str[size-1-i]);
		}
	}
}
 570:	dfc00317 	ldw	ra,12(sp)
 574:	dc800217 	ldw	r18,8(sp)
 578:	dc400117 	ldw	r17,4(sp)
 57c:	dc000017 	ldw	r16,0(sp)
 580:	dec00404 	addi	sp,sp,16
 584:	f800283a 	ret

00000588 <clear_block>:

void clear_block(enum BLOCK_N block_i) {
 588:	2007883a 	mov	r3,r4
	if (block_i == HEX0_3) {
		print_block("    ", 4, HEX0_3);
 58c:	01400104 	movi	r5,4
 590:	000d883a 	mov	r6,zero
 594:	01000034 	movhi	r4,0
 598:	21033b04 	addi	r4,r4,3308
		}
	}
}

void clear_block(enum BLOCK_N block_i) {
	if (block_i == HEX0_3) {
 59c:	18000c26 	beq	r3,zero,5d0 <clear_block+0x48>
		print_block("    ", 4, HEX0_3);
	}
	else if (block_i == HEX4_5) {
 5a0:	00800044 	movi	r2,1
		print_block("  ", 2, HEX4_5);
 5a4:	180d883a 	mov	r6,r3
 5a8:	01000034 	movhi	r4,0
 5ac:	21033d04 	addi	r4,r4,3316
 5b0:	01400084 	movi	r5,2

void clear_block(enum BLOCK_N block_i) {
	if (block_i == HEX0_3) {
		print_block("    ", 4, HEX0_3);
	}
	else if (block_i == HEX4_5) {
 5b4:	18800626 	beq	r3,r2,5d0 <clear_block+0x48>
		print_block("  ", 2, HEX4_5);
	}
	else if (block_i == HEX6_7) {
 5b8:	00800084 	movi	r2,2
		print_block("  ", 2, HEX6_7);
 5bc:	180b883a 	mov	r5,r3
 5c0:	01000034 	movhi	r4,0
 5c4:	21033d04 	addi	r4,r4,3316
 5c8:	180d883a 	mov	r6,r3
		print_block("    ", 4, HEX0_3);
	}
	else if (block_i == HEX4_5) {
		print_block("  ", 2, HEX4_5);
	}
	else if (block_i == HEX6_7) {
 5cc:	1880011e 	bne	r3,r2,5d4 <clear_block+0x4c>
		print_block("  ", 2, HEX6_7);
 5d0:	00004ac1 	jmpi	4ac <print_block>
 5d4:	f800283a 	ret

000005d8 <print_number>:
	}
}

void print_number(char num) {
 5d8:	defff804 	addi	sp,sp,-32
 5dc:	dc800415 	stw	r18,16(sp)
 5e0:	dc400315 	stw	r17,12(sp)
 5e4:	dfc00715 	stw	ra,28(sp)
 5e8:	dd000615 	stw	r20,24(sp)
 5ec:	dcc00515 	stw	r19,20(sp)
 5f0:	dc000215 	stw	r16,8(sp)
 5f4:	2023883a 	mov	r17,r4
 5f8:	0025883a 	mov	r18,zero
	int i;
	char buf[5];
	char val;
	for (i = 0; i < 4; i++) {
		if (num < 0) {
 5fc:	88803fcc 	andi	r2,r17,255
 600:	1080201c 	xori	r2,r2,128
 604:	10bfe004 	addi	r2,r2,-128
			buf[0] = '-';
 608:	05000b44 	movi	r20,45
			val = -num;
 60c:	0461c83a 	sub	r16,zero,r17
void print_number(char num) {
	int i;
	char buf[5];
	char val;
	for (i = 0; i < 4; i++) {
		if (num < 0) {
 610:	10000216 	blt	r2,zero,61c <print_number+0x44>
			buf[0] = '-';
			val = -num;
		} else {
			buf[0] = ' ';
 614:	05000804 	movi	r20,32
 618:	8821883a 	mov	r16,r17
			val = num;
		}
		buf[1] = val/100%10 + '0';
 61c:	84003fcc 	andi	r16,r16,255
 620:	8400201c 	xori	r16,r16,128
 624:	843fe004 	addi	r16,r16,-128
 628:	8009883a 	mov	r4,r16
 62c:	01401904 	movi	r5,100
 630:	00009580 	call	958 <__divsi3>
 634:	11003fcc 	andi	r4,r2,255
 638:	2100201c 	xori	r4,r4,128
 63c:	213fe004 	addi	r4,r4,-128
 640:	01400284 	movi	r5,10
 644:	00009b80 	call	9b8 <__modsi3>
		buf[2] = val/10%10 + '0';
 648:	8009883a 	mov	r4,r16
 64c:	01400284 	movi	r5,10
			val = -num;
		} else {
			buf[0] = ' ';
			val = num;
		}
		buf[1] = val/100%10 + '0';
 650:	14c00c04 	addi	r19,r2,48
		buf[2] = val/10%10 + '0';
 654:	00009580 	call	958 <__divsi3>
 658:	11003fcc 	andi	r4,r2,255
 65c:	2100201c 	xori	r4,r4,128
 660:	213fe004 	addi	r4,r4,-128
 664:	01400284 	movi	r5,10
 668:	00009b80 	call	9b8 <__modsi3>
		buf[3] = val%10 + '0';
 66c:	8009883a 	mov	r4,r16
 670:	01400284 	movi	r5,10
		} else {
			buf[0] = ' ';
			val = num;
		}
		buf[1] = val/100%10 + '0';
		buf[2] = val/10%10 + '0';
 674:	14000c04 	addi	r16,r2,48
		buf[3] = val%10 + '0';
 678:	00009b80 	call	9b8 <__modsi3>
 67c:	10c00c04 	addi	r3,r2,48

void print_number(char num) {
	int i;
	char buf[5];
	char val;
	for (i = 0; i < 4; i++) {
 680:	94800044 	addi	r18,r18,1
 684:	00800104 	movi	r2,4
 688:	90bfdc1e 	bne	r18,r2,5fc <print_number+0x24>
		}
		buf[1] = val/100%10 + '0';
		buf[2] = val/10%10 + '0';
		buf[3] = val%10 + '0';
	}
	clear_block(HEX0_3);
 68c:	0009883a 	mov	r4,zero
 690:	d8c000c5 	stb	r3,3(sp)
 694:	dc000085 	stb	r16,2(sp)
 698:	dcc00045 	stb	r19,1(sp)
 69c:	dd000005 	stb	r20,0(sp)
 6a0:	00005880 	call	588 <clear_block>
	print_block(buf, 4, HEX0_3);
 6a4:	900b883a 	mov	r5,r18
 6a8:	d809883a 	mov	r4,sp
 6ac:	000d883a 	mov	r6,zero
 6b0:	00004ac0 	call	4ac <print_block>
}
 6b4:	dfc00717 	ldw	ra,28(sp)
 6b8:	dd000617 	ldw	r20,24(sp)
 6bc:	dcc00517 	ldw	r19,20(sp)
 6c0:	dc800417 	ldw	r18,16(sp)
 6c4:	dc400317 	ldw	r17,12(sp)
 6c8:	dc000217 	ldw	r16,8(sp)
 6cc:	dec00804 	addi	sp,sp,32
 6d0:	f800283a 	ret

000006d4 <push_int>:
void push_int() {
	static unsigned char status = 0;
	sw_t s;
	s.data = *switches;

	switch (status) {
 6d4:	d0e00443 	ldbu	r3,-32751(gp)
}

void push_int() {
	static unsigned char status = 0;
	sw_t s;
	s.data = *switches;
 6d8:	00882404 	movi	r2,8336

	switch (status) {
 6dc:	01000044 	movi	r4,1
	global_registers[Ssw_psel];
	global_registers[Ssw_rw];
	global_registers[Ssw_run];
}

void push_int() {
 6e0:	deffff04 	addi	sp,sp,-4
	static unsigned char status = 0;
	sw_t s;
	s.data = *switches;
 6e4:	11400017 	ldw	r5,0(r2)

	switch (status) {
 6e8:	19001226 	beq	r3,r4,734 <push_int+0x60>
 6ec:	19000336 	bltu	r3,r4,6fc <push_int+0x28>
 6f0:	00800084 	movi	r2,2
 6f4:	18801a1e 	bne	r3,r2,760 <push_int+0x8c>
 6f8:	00001806 	br	75c <push_int+0x88>
	case 0:
		PUSH_EVENT = 0;
		if (*push_switches != 7) status = 1;
 6fc:	00882004 	movi	r2,8320
 700:	10800003 	ldbu	r2,0(r2)
 704:	00c001c4 	movi	r3,7
	sw_t s;
	s.data = *switches;

	switch (status) {
	case 0:
		PUSH_EVENT = 0;
 708:	d0200405 	stb	zero,-32752(gp)
		if (*push_switches != 7) status = 1;
 70c:	10803fcc 	andi	r2,r2,255
 710:	1080201c 	xori	r2,r2,128
 714:	10bfe004 	addi	r2,r2,-128
 718:	10c00126 	beq	r2,r3,720 <push_int+0x4c>
 71c:	d1200445 	stb	r4,-32751(gp)
		//update_sw_reg(s);	// スイッチレジスタ更新
		alt_printf("%x", s.data);
 720:	01000034 	movhi	r4,0
 724:	21033e04 	addi	r4,r4,3320
}

void push_int() {
	static unsigned char status = 0;
	sw_t s;
	s.data = *switches;
 728:	d9400015 	stw	r5,0(sp)
		break;
	default:
		status = 0;
		break;
	}
}
 72c:	dec00104 	addi	sp,sp,4
	switch (status) {
	case 0:
		PUSH_EVENT = 0;
		if (*push_switches != 7) status = 1;
		//update_sw_reg(s);	// スイッチレジスタ更新
		alt_printf("%x", s.data);
 730:	0000ae01 	jmpi	ae0 <alt_printf>
		break;
	case 1:
		if (*push_switches == 7) status = 2;
 734:	00882004 	movi	r2,8320
 738:	10800003 	ldbu	r2,0(r2)
 73c:	00c001c4 	movi	r3,7
 740:	10803fcc 	andi	r2,r2,255
 744:	1080201c 	xori	r2,r2,128
 748:	10bfe004 	addi	r2,r2,-128
 74c:	10c0051e 	bne	r2,r3,764 <push_int+0x90>
 750:	00800084 	movi	r2,2
 754:	d0a00445 	stb	r2,-32751(gp)
 758:	00000206 	br	764 <push_int+0x90>
		break;
	case 2:
		PUSH_EVENT = 1;
 75c:	d1200405 	stb	r4,-32752(gp)
		status = 0;
		break;
	default:
		status = 0;
 760:	d0200445 	stb	zero,-32751(gp)
		break;
	}
}
 764:	dec00104 	addi	sp,sp,4
 768:	f800283a 	ret

0000076c <in_int>:
#include "sys_register.h"

unsigned char PUSH_EVENT = 0;

void in_int() {
	push_int();
 76c:	00006d41 	jmpi	6d4 <push_int>

00000770 <memory_init>:

/**************************************************
 *						Impl
 **************************************************/

void memory_init() {
 770:	000b883a 	mov	r5,zero
 774:	00000806 	br	798 <memory_init+0x28>
	int i, j;
	for (i = 0; i < MEMS_COUNT; i++)
	for (j = 0; j < MEM_SIZE; j++) {
 778:	21000044 	addi	r4,r4,1
 77c:	00800404 	movi	r2,16
		memory[i][j] = 0;
 780:	18000005 	stb	zero,0(r3)
 **************************************************/

void memory_init() {
	int i, j;
	for (i = 0; i < MEMS_COUNT; i++)
	for (j = 0; j < MEM_SIZE; j++) {
 784:	18c00044 	addi	r3,r3,1
 788:	20bffb1e 	bne	r4,r2,778 <memory_init+0x8>
 *						Impl
 **************************************************/

void memory_init() {
	int i, j;
	for (i = 0; i < MEMS_COUNT; i++)
 78c:	29400044 	addi	r5,r5,1
 790:	00800104 	movi	r2,4
 794:	28800626 	beq	r5,r2,7b0 <memory_init+0x40>
	for (j = 0; j < MEM_SIZE; j++) {
		memory[i][j] = 0;
	}
}
 798:	2806913a 	slli	r3,r5,4
 79c:	00800034 	movhi	r2,0
 7a0:	1083eb04 	addi	r2,r2,4012
 7a4:	0009883a 	mov	r4,zero
 7a8:	1887883a 	add	r3,r3,r2
 7ac:	003ff206 	br	778 <memory_init+0x8>
 7b0:	f800283a 	ret

000007b4 <memory_load>:
	if (!(mem_addr < MEM_SIZE)) panic();
	memory[global_current_memory][mem_addr] = global_registers[reg];
	return memory[global_current_memory][mem_addr];
}

char memory_load(unsigned int mem_addr, enum Register reg) {
 7b4:	defffd04 	addi	sp,sp,-12
	if (!(mem_addr < MEM_SIZE)) panic();
 7b8:	008003c4 	movi	r2,15
	if (!(mem_addr < MEM_SIZE)) panic();
	memory[global_current_memory][mem_addr] = global_registers[reg];
	return memory[global_current_memory][mem_addr];
}

char memory_load(unsigned int mem_addr, enum Register reg) {
 7bc:	dc400115 	stw	r17,4(sp)
 7c0:	dc000015 	stw	r16,0(sp)
 7c4:	dfc00215 	stw	ra,8(sp)
 7c8:	2021883a 	mov	r16,r4
 7cc:	2823883a 	mov	r17,r5
	if (!(mem_addr < MEM_SIZE)) panic();
 7d0:	1100012e 	bgeu	r2,r4,7d8 <memory_load+0x24>
 7d4:	00008b00 	call	8b0 <panic>
	global_registers[reg] = memory[global_current_memory][mem_addr];
 7d8:	d0a00517 	ldw	r2,-32748(gp)
 7dc:	00c00034 	movhi	r3,0
 7e0:	18c3eb04 	addi	r3,r3,4012
 7e4:	01000034 	movhi	r4,0
 7e8:	2103fb04 	addi	r4,r4,4076
 7ec:	1004913a 	slli	r2,r2,4
 7f0:	8909883a 	add	r4,r17,r4
 7f4:	10c5883a 	add	r2,r2,r3
 7f8:	1405883a 	add	r2,r2,r16
 7fc:	10800003 	ldbu	r2,0(r2)
 800:	20800005 	stb	r2,0(r4)
	return global_registers[reg];
}
 804:	10803fcc 	andi	r2,r2,255
 808:	1080201c 	xori	r2,r2,128
 80c:	10bfe004 	addi	r2,r2,-128
 810:	dfc00217 	ldw	ra,8(sp)
 814:	dc400117 	ldw	r17,4(sp)
 818:	dc000017 	ldw	r16,0(sp)
 81c:	dec00304 	addi	sp,sp,12
 820:	f800283a 	ret

00000824 <memory_store>:
	for (j = 0; j < MEM_SIZE; j++) {
		memory[i][j] = 0;
	}
}

char memory_store(unsigned int mem_addr, enum Register reg) {
 824:	defffd04 	addi	sp,sp,-12
	if (!(mem_addr < MEM_SIZE)) panic();
 828:	008003c4 	movi	r2,15
	for (j = 0; j < MEM_SIZE; j++) {
		memory[i][j] = 0;
	}
}

char memory_store(unsigned int mem_addr, enum Register reg) {
 82c:	dc400115 	stw	r17,4(sp)
 830:	dc000015 	stw	r16,0(sp)
 834:	dfc00215 	stw	ra,8(sp)
 838:	2023883a 	mov	r17,r4
 83c:	2821883a 	mov	r16,r5
	if (!(mem_addr < MEM_SIZE)) panic();
 840:	1100012e 	bgeu	r2,r4,848 <memory_store+0x24>
 844:	00008b00 	call	8b0 <panic>
	memory[global_current_memory][mem_addr] = global_registers[reg];
 848:	d0e00517 	ldw	r3,-32748(gp)
 84c:	00800034 	movhi	r2,0
 850:	1083fb04 	addi	r2,r2,4076
 854:	8085883a 	add	r2,r16,r2
 858:	1806913a 	slli	r3,r3,4
 85c:	10800003 	ldbu	r2,0(r2)
 860:	01000034 	movhi	r4,0
 864:	2103eb04 	addi	r4,r4,4012
 868:	1907883a 	add	r3,r3,r4
 86c:	1c47883a 	add	r3,r3,r17
 870:	18800005 	stb	r2,0(r3)
	return memory[global_current_memory][mem_addr];
}
 874:	10803fcc 	andi	r2,r2,255
 878:	1080201c 	xori	r2,r2,128
 87c:	10bfe004 	addi	r2,r2,-128
 880:	dfc00217 	ldw	ra,8(sp)
 884:	dc400117 	ldw	r17,4(sp)
 888:	dc000017 	ldw	r16,0(sp)
 88c:	dec00304 	addi	sp,sp,12
 890:	f800283a 	ret

00000894 <registers_init>:
 */
#include "sys_register.h"

char global_registers[REG_MAX_COUNT];

void registers_init() {
 894:	00800034 	movhi	r2,0
 898:	1083fb04 	addi	r2,r2,4076
 89c:	10c00344 	addi	r3,r2,13
	int i;
	for (i = 0; i < REG_MAX_COUNT; i++) global_registers[i] = 0;
 8a0:	10000005 	stb	zero,0(r2)
 8a4:	10800044 	addi	r2,r2,1
 8a8:	10fffd1e 	bne	r2,r3,8a0 <registers_init+0xc>
}
 8ac:	f800283a 	ret

000008b0 <panic>:
 *      Author: takayun
 */
#include "system.h"
#include "hex_out.h"

void panic() {
 8b0:	deffff04 	addi	sp,sp,-4
	clear_block(HEX0_3);
 8b4:	0009883a 	mov	r4,zero
 *      Author: takayun
 */
#include "system.h"
#include "hex_out.h"

void panic() {
 8b8:	dfc00015 	stw	ra,0(sp)
	clear_block(HEX0_3);
 8bc:	00005880 	call	588 <clear_block>
	print_block("err ", 4, HEX0_3);
 8c0:	01400104 	movi	r5,4
 8c4:	01000034 	movhi	r4,0
 8c8:	21033f04 	addi	r4,r4,3324
 8cc:	000d883a 	mov	r6,zero
}
 8d0:	dfc00017 	ldw	ra,0(sp)
 8d4:	dec00104 	addi	sp,sp,4
#include "system.h"
#include "hex_out.h"

void panic() {
	clear_block(HEX0_3);
	print_block("err ", 4, HEX0_3);
 8d8:	00004ac1 	jmpi	4ac <print_block>

000008dc <udivmodsi4>:
 8dc:	29001b2e 	bgeu	r5,r4,94c <udivmodsi4+0x70>
 8e0:	28001a16 	blt	r5,zero,94c <udivmodsi4+0x70>
 8e4:	00800044 	movi	r2,1
 8e8:	0007883a 	mov	r3,zero
 8ec:	01c007c4 	movi	r7,31
 8f0:	00000306 	br	900 <udivmodsi4+0x24>
 8f4:	19c01326 	beq	r3,r7,944 <udivmodsi4+0x68>
 8f8:	18c00044 	addi	r3,r3,1
 8fc:	28000416 	blt	r5,zero,910 <udivmodsi4+0x34>
 900:	294b883a 	add	r5,r5,r5
 904:	1085883a 	add	r2,r2,r2
 908:	293ffa36 	bltu	r5,r4,8f4 <udivmodsi4+0x18>
 90c:	10000d26 	beq	r2,zero,944 <udivmodsi4+0x68>
 910:	0007883a 	mov	r3,zero
 914:	21400236 	bltu	r4,r5,920 <udivmodsi4+0x44>
 918:	2149c83a 	sub	r4,r4,r5
 91c:	1886b03a 	or	r3,r3,r2
 920:	1004d07a 	srli	r2,r2,1
 924:	280ad07a 	srli	r5,r5,1
 928:	103ffa1e 	bne	r2,zero,914 <udivmodsi4+0x38>
 92c:	30000226 	beq	r6,zero,938 <udivmodsi4+0x5c>
 930:	2005883a 	mov	r2,r4
 934:	f800283a 	ret
 938:	1809883a 	mov	r4,r3
 93c:	2005883a 	mov	r2,r4
 940:	f800283a 	ret
 944:	0007883a 	mov	r3,zero
 948:	003ff806 	br	92c <udivmodsi4+0x50>
 94c:	00800044 	movi	r2,1
 950:	0007883a 	mov	r3,zero
 954:	003fef06 	br	914 <udivmodsi4+0x38>

00000958 <__divsi3>:
 958:	defffe04 	addi	sp,sp,-8
 95c:	dc000015 	stw	r16,0(sp)
 960:	dfc00115 	stw	ra,4(sp)
 964:	0021883a 	mov	r16,zero
 968:	20000c16 	blt	r4,zero,99c <__divsi3+0x44>
 96c:	000d883a 	mov	r6,zero
 970:	28000e16 	blt	r5,zero,9ac <__divsi3+0x54>
 974:	00008dc0 	call	8dc <udivmodsi4>
 978:	1007883a 	mov	r3,r2
 97c:	8005003a 	cmpeq	r2,r16,zero
 980:	1000011e 	bne	r2,zero,988 <__divsi3+0x30>
 984:	00c7c83a 	sub	r3,zero,r3
 988:	1805883a 	mov	r2,r3
 98c:	dfc00117 	ldw	ra,4(sp)
 990:	dc000017 	ldw	r16,0(sp)
 994:	dec00204 	addi	sp,sp,8
 998:	f800283a 	ret
 99c:	0109c83a 	sub	r4,zero,r4
 9a0:	04000044 	movi	r16,1
 9a4:	000d883a 	mov	r6,zero
 9a8:	283ff20e 	bge	r5,zero,974 <__divsi3+0x1c>
 9ac:	014bc83a 	sub	r5,zero,r5
 9b0:	8021003a 	cmpeq	r16,r16,zero
 9b4:	003fef06 	br	974 <__divsi3+0x1c>

000009b8 <__modsi3>:
 9b8:	deffff04 	addi	sp,sp,-4
 9bc:	dfc00015 	stw	ra,0(sp)
 9c0:	01800044 	movi	r6,1
 9c4:	2807883a 	mov	r3,r5
 9c8:	20000416 	blt	r4,zero,9dc <__modsi3+0x24>
 9cc:	28000c16 	blt	r5,zero,a00 <__modsi3+0x48>
 9d0:	dfc00017 	ldw	ra,0(sp)
 9d4:	dec00104 	addi	sp,sp,4
 9d8:	00008dc1 	jmpi	8dc <udivmodsi4>
 9dc:	0109c83a 	sub	r4,zero,r4
 9e0:	28000b16 	blt	r5,zero,a10 <__modsi3+0x58>
 9e4:	180b883a 	mov	r5,r3
 9e8:	01800044 	movi	r6,1
 9ec:	00008dc0 	call	8dc <udivmodsi4>
 9f0:	0085c83a 	sub	r2,zero,r2
 9f4:	dfc00017 	ldw	ra,0(sp)
 9f8:	dec00104 	addi	sp,sp,4
 9fc:	f800283a 	ret
 a00:	014bc83a 	sub	r5,zero,r5
 a04:	dfc00017 	ldw	ra,0(sp)
 a08:	dec00104 	addi	sp,sp,4
 a0c:	00008dc1 	jmpi	8dc <udivmodsi4>
 a10:	0147c83a 	sub	r3,zero,r5
 a14:	003ff306 	br	9e4 <__modsi3+0x2c>

00000a18 <__udivsi3>:
 a18:	000d883a 	mov	r6,zero
 a1c:	00008dc1 	jmpi	8dc <udivmodsi4>

00000a20 <__umodsi3>:
 a20:	01800044 	movi	r6,1
 a24:	00008dc1 	jmpi	8dc <udivmodsi4>

00000a28 <alt_load_section>:

static void ALT_INLINE alt_load_section (alt_u32* from, 
                                         alt_u32* to, 
                                         alt_u32* end)
{
  if (to != from)
 a28:	2900051e 	bne	r5,r4,a40 <alt_load_section+0x18>
 a2c:	f800283a 	ret
  {
    while( to != end )
    {
      *to++ = *from++;
 a30:	20800017 	ldw	r2,0(r4)
 a34:	21000104 	addi	r4,r4,4
 a38:	28800015 	stw	r2,0(r5)
 a3c:	29400104 	addi	r5,r5,4
                                         alt_u32* to, 
                                         alt_u32* end)
{
  if (to != from)
  {
    while( to != end )
 a40:	29bffb1e 	bne	r5,r6,a30 <alt_load_section+0x8>
 a44:	f800283a 	ret

00000a48 <alt_load>:
 * there is no bootloader, so this application is responsible for loading to
 * RAM any sections that are required.
 */  

void alt_load (void)
{
 a48:	deffff04 	addi	sp,sp,-4
  /* 
   * Copy the .rwdata section. 
   */

  alt_load_section (&__flash_rwdata_start, 
 a4c:	01000034 	movhi	r4,0
 a50:	2103e404 	addi	r4,r4,3984
 a54:	01400034 	movhi	r5,0
 a58:	2943e204 	addi	r5,r5,3976
 a5c:	01800034 	movhi	r6,0
 a60:	3183e404 	addi	r6,r6,3984
 * there is no bootloader, so this application is responsible for loading to
 * RAM any sections that are required.
 */  

void alt_load (void)
{
 a64:	dfc00015 	stw	ra,0(sp)
  /* 
   * Copy the .rwdata section. 
   */

  alt_load_section (&__flash_rwdata_start, 
 a68:	0000a280 	call	a28 <alt_load_section>

  /*
   * Copy the exception handler.
   */

  alt_load_section (&__flash_exceptions_start, 
 a6c:	01000034 	movhi	r4,0
 a70:	21000804 	addi	r4,r4,32
 a74:	01400034 	movhi	r5,0
 a78:	29400804 	addi	r5,r5,32
 a7c:	01800034 	movhi	r6,0
 a80:	31800804 	addi	r6,r6,32
 a84:	0000a280 	call	a28 <alt_load_section>

  /*
   * Copy the .rodata section.
   */

  alt_load_section (&__flash_rodata_start, 
 a88:	01000034 	movhi	r4,0
 a8c:	21033704 	addi	r4,r4,3292
 a90:	01400034 	movhi	r5,0
 a94:	29433704 	addi	r5,r5,3292
 a98:	01800034 	movhi	r6,0
 a9c:	3183e204 	addi	r6,r6,3976
 aa0:	0000a280 	call	a28 <alt_load_section>
  
  /*
   * Now ensure that the caches are in synch.
   */
  
  alt_dcache_flush_all();
 aa4:	0000ccc0 	call	ccc <alt_dcache_flush_all>
  alt_icache_flush_all();
}
 aa8:	dfc00017 	ldw	ra,0(sp)
 aac:	dec00104 	addi	sp,sp,4
  /*
   * Now ensure that the caches are in synch.
   */
  
  alt_dcache_flush_all();
  alt_icache_flush_all();
 ab0:	0000cd01 	jmpi	cd0 <alt_icache_flush_all>

00000ab4 <alt_main>:
 * devices/filesystems/components in the system; and call the entry point for
 * the users application, i.e. main().
 */

void alt_main (void)
{
 ab4:	deffff04 	addi	sp,sp,-4
#endif

  /* ALT LOG - please see HAL/sys/alt_log_printf.h for details */
  ALT_LOG_PRINT_BOOT("[alt_main.c] Entering alt_main, calling alt_irq_init.\r\n");
  /* Initialize the interrupt controller. */
  alt_irq_init (NULL);
 ab8:	0009883a 	mov	r4,zero
 * devices/filesystems/components in the system; and call the entry point for
 * the users application, i.e. main().
 */

void alt_main (void)
{
 abc:	dfc00015 	stw	ra,0(sp)
#endif

  /* ALT LOG - please see HAL/sys/alt_log_printf.h for details */
  ALT_LOG_PRINT_BOOT("[alt_main.c] Entering alt_main, calling alt_irq_init.\r\n");
  /* Initialize the interrupt controller. */
  alt_irq_init (NULL);
 ac0:	0000c780 	call	c78 <alt_irq_init>
  ALT_LOG_PRINT_BOOT("[alt_main.c] Done OS Init, calling alt_sem_create.\r\n");
  ALT_SEM_CREATE (&alt_fd_list_lock, 1);

  /* Initialize the device drivers/software components. */
  ALT_LOG_PRINT_BOOT("[alt_main.c] Calling alt_sys_init.\r\n");
  alt_sys_init();
 ac4:	0000c740 	call	c74 <alt_sys_init>
   */

  ALT_LOG_PRINT_BOOT("[alt_main.c] Calling main.\r\n");

#ifdef ALT_NO_EXIT
  main (alt_argc, alt_argv, alt_envp);
 ac8:	d1200617 	ldw	r4,-32744(gp)
 acc:	d1600717 	ldw	r5,-32740(gp)
 ad0:	d1a00817 	ldw	r6,-32736(gp)
  close(STDOUT_FILENO);
  exit (result);
#endif

  ALT_LOG_PRINT_BOOT("[alt_main.c] After main - we should not be here?.\r\n");
}
 ad4:	dfc00017 	ldw	ra,0(sp)
 ad8:	dec00104 	addi	sp,sp,4
   */

  ALT_LOG_PRINT_BOOT("[alt_main.c] Calling main.\r\n");

#ifdef ALT_NO_EXIT
  main (alt_argc, alt_argv, alt_envp);
 adc:	00000e01 	jmpi	e0 <main>

00000ae0 <alt_printf>:
/* 
 * ALT printf function 
 */
void 
alt_printf(const char* fmt, ... )
{
 ae0:	defff804 	addi	sp,sp,-32
 ae4:	dfc00415 	stw	ra,16(sp)
 ae8:	dc800315 	stw	r18,12(sp)
 aec:	dc400215 	stw	r17,8(sp)
 af0:	dc000115 	stw	r16,4(sp)
 af4:	d9400515 	stw	r5,20(sp)
 af8:	d9800615 	stw	r6,24(sp)
 afc:	d9c00715 	stw	r7,28(sp)
	va_list args;
	va_start(args, fmt);
 b00:	d8800504 	addi	r2,sp,20
 b04:	2025883a 	mov	r18,r4
 b08:	d8800015 	stw	r2,0(sp)
 b0c:	00003d06 	br	c04 <alt_printf+0x124>
    w = fmt;
    while ((c = *w++) != 0)
    {
        /* If not a format escape character, just print  */
        /* character.  Otherwise, process format string. */
        if (c != '%')
 b10:	00800944 	movi	r2,37
    const char *w;
    char c;

    /* Process format string. */
    w = fmt;
    while ((c = *w++) != 0)
 b14:	94800044 	addi	r18,r18,1
    {
        /* If not a format escape character, just print  */
        /* character.  Otherwise, process format string. */
        if (c != '%')
 b18:	18800226 	beq	r3,r2,b24 <alt_printf+0x44>
        {
            alt_putchar(c);
 b1c:	1809883a 	mov	r4,r3
 b20:	00000a06 	br	b4c <alt_printf+0x6c>
        }
        else
        {
            /* Get format character.  If none     */
            /* available, processing is complete. */
            if ((c = *w++) != 0)
 b24:	91000007 	ldb	r4,0(r18)
 b28:	94800044 	addi	r18,r18,1
 b2c:	20003726 	beq	r4,zero,c0c <alt_printf+0x12c>
            {
                if (c == '%')
 b30:	20c00626 	beq	r4,r3,b4c <alt_printf+0x6c>
                {
                    /* Process "%" escape sequence. */
                    alt_putchar(c);
                } 
                else if (c == 'c')
 b34:	008018c4 	movi	r2,99
 b38:	2080061e 	bne	r4,r2,b54 <alt_printf+0x74>
                {
                    int v = va_arg(args, int);
 b3c:	d8800017 	ldw	r2,0(sp)
                    alt_putchar(v);
 b40:	11000017 	ldw	r4,0(r2)
                    /* Process "%" escape sequence. */
                    alt_putchar(c);
                } 
                else if (c == 'c')
                {
                    int v = va_arg(args, int);
 b44:	10800104 	addi	r2,r2,4
 b48:	d8800015 	stw	r2,0(sp)
                    alt_putchar(v);
 b4c:	0000c240 	call	c24 <alt_putchar>
 b50:	00002c06 	br	c04 <alt_printf+0x124>
                }
                else if (c == 'x')
 b54:	00801e04 	movi	r2,120
 b58:	20801e1e 	bne	r4,r2,bd4 <alt_printf+0xf4>
                {
                    /* Process hexadecimal number format. */
                    unsigned long v = va_arg(args, unsigned long);
 b5c:	d8800017 	ldw	r2,0(sp)
 b60:	14400017 	ldw	r17,0(r2)
 b64:	10800104 	addi	r2,r2,4
 b68:	d8800015 	stw	r2,0(sp)
                    unsigned long digit;
                    int digit_shift;

                    /* If the number value is zero, just print and continue. */
                    if (v == 0)
 b6c:	88000226 	beq	r17,zero,b78 <alt_printf+0x98>
 b70:	04000704 	movi	r16,28
 b74:	00000306 	br	b84 <alt_printf+0xa4>
                    {
                        alt_putchar('0');
 b78:	01000c04 	movi	r4,48
 b7c:	003ff306 	br	b4c <alt_printf+0x6c>
                    }

                    /* Find first non-zero digit. */
                    digit_shift = 28;
                    while (!(v & (0xF << digit_shift)))
                        digit_shift -= 4;
 b80:	843fff04 	addi	r16,r16,-4
                        continue;
                    }

                    /* Find first non-zero digit. */
                    digit_shift = 28;
                    while (!(v & (0xF << digit_shift)))
 b84:	008003c4 	movi	r2,15
 b88:	1404983a 	sll	r2,r2,r16
 b8c:	8884703a 	and	r2,r17,r2
 b90:	103ffb26 	beq	r2,zero,b80 <alt_printf+0xa0>
 b94:	00000b06 	br	bc4 <alt_printf+0xe4>
                        digit_shift -= 4;

                    /* Print digits. */
                    for (; digit_shift >= 0; digit_shift -= 4)
                    {
                        digit = (v & (0xF << digit_shift)) >> digit_shift;
 b98:	8884703a 	and	r2,r17,r2
 b9c:	1406d83a 	srl	r3,r2,r16
                        if (digit <= 9)
 ba0:	00800244 	movi	r2,9
                            c = '0' + digit;
 ba4:	19000c04 	addi	r4,r3,48

                    /* Print digits. */
                    for (; digit_shift >= 0; digit_shift -= 4)
                    {
                        digit = (v & (0xF << digit_shift)) >> digit_shift;
                        if (digit <= 9)
 ba8:	10c0012e 	bgeu	r2,r3,bb0 <alt_printf+0xd0>
                            c = '0' + digit;
                        else
                            c = 'a' + digit - 10;
 bac:	190015c4 	addi	r4,r3,87
                        alt_putchar(c);
 bb0:	21003fcc 	andi	r4,r4,255
 bb4:	2100201c 	xori	r4,r4,128
 bb8:	213fe004 	addi	r4,r4,-128
                    digit_shift = 28;
                    while (!(v & (0xF << digit_shift)))
                        digit_shift -= 4;

                    /* Print digits. */
                    for (; digit_shift >= 0; digit_shift -= 4)
 bbc:	843fff04 	addi	r16,r16,-4
                        digit = (v & (0xF << digit_shift)) >> digit_shift;
                        if (digit <= 9)
                            c = '0' + digit;
                        else
                            c = 'a' + digit - 10;
                        alt_putchar(c);
 bc0:	0000c240 	call	c24 <alt_putchar>
                        digit_shift -= 4;

                    /* Print digits. */
                    for (; digit_shift >= 0; digit_shift -= 4)
                    {
                        digit = (v & (0xF << digit_shift)) >> digit_shift;
 bc4:	008003c4 	movi	r2,15
 bc8:	1404983a 	sll	r2,r2,r16
                    digit_shift = 28;
                    while (!(v & (0xF << digit_shift)))
                        digit_shift -= 4;

                    /* Print digits. */
                    for (; digit_shift >= 0; digit_shift -= 4)
 bcc:	803ff20e 	bge	r16,zero,b98 <alt_printf+0xb8>
 bd0:	00000c06 	br	c04 <alt_printf+0x124>
                        else
                            c = 'a' + digit - 10;
                        alt_putchar(c);
                    }
                }
                else if (c == 's')
 bd4:	00801cc4 	movi	r2,115
 bd8:	20800a1e 	bne	r4,r2,c04 <alt_printf+0x124>
                {
                    /* Process string format. */
                    char *s = va_arg(args, char *);
 bdc:	d8800017 	ldw	r2,0(sp)
 be0:	14000017 	ldw	r16,0(r2)
 be4:	10800104 	addi	r2,r2,4
 be8:	d8800015 	stw	r2,0(sp)
 bec:	00000106 	br	bf4 <alt_printf+0x114>

                    while(*s)
                      alt_putchar(*s++);
 bf0:	0000c240 	call	c24 <alt_putchar>
                else if (c == 's')
                {
                    /* Process string format. */
                    char *s = va_arg(args, char *);

                    while(*s)
 bf4:	80800007 	ldb	r2,0(r16)
                      alt_putchar(*s++);
 bf8:	84000044 	addi	r16,r16,1
 bfc:	1009883a 	mov	r4,r2
                else if (c == 's')
                {
                    /* Process string format. */
                    char *s = va_arg(args, char *);

                    while(*s)
 c00:	103ffb1e 	bne	r2,zero,bf0 <alt_printf+0x110>
    const char *w;
    char c;

    /* Process format string. */
    w = fmt;
    while ((c = *w++) != 0)
 c04:	90c00007 	ldb	r3,0(r18)
 c08:	183fc11e 	bne	r3,zero,b10 <alt_printf+0x30>
            {
                break;
            }
        }
    }
}
 c0c:	dfc00417 	ldw	ra,16(sp)
 c10:	dc800317 	ldw	r18,12(sp)
 c14:	dc400217 	ldw	r17,8(sp)
 c18:	dc000117 	ldw	r16,4(sp)
 c1c:	dec00804 	addi	sp,sp,32
 c20:	f800283a 	ret

00000c24 <alt_putchar>:
 * Uses the ALT_DRIVER_WRITE() macro to call directly to driver if available.
 * Otherwise, uses newlib provided putchar() routine.
 */
int 
alt_putchar(int c)
{
 c24:	defffd04 	addi	sp,sp,-12
 c28:	dc000115 	stw	r16,4(sp)
#ifdef ALT_USE_DIRECT_DRIVERS
    ALT_DRIVER_WRITE_EXTERNS(ALT_STDOUT_DEV);
    char        c1 = (char)(c & 0xff);

    if (ALT_DRIVER_WRITE(ALT_STDOUT_DEV, &c1, 1, 0) == -1) {
 c2c:	d80b883a 	mov	r5,sp
 * Uses the ALT_DRIVER_WRITE() macro to call directly to driver if available.
 * Otherwise, uses newlib provided putchar() routine.
 */
int 
alt_putchar(int c)
{
 c30:	2021883a 	mov	r16,r4
#ifdef ALT_USE_DIRECT_DRIVERS
    ALT_DRIVER_WRITE_EXTERNS(ALT_STDOUT_DEV);
    char        c1 = (char)(c & 0xff);

    if (ALT_DRIVER_WRITE(ALT_STDOUT_DEV, &c1, 1, 0) == -1) {
 c34:	01800044 	movi	r6,1
 c38:	01000034 	movhi	r4,0
 c3c:	2103e304 	addi	r4,r4,3980
 c40:	000f883a 	mov	r7,zero
 * Uses the ALT_DRIVER_WRITE() macro to call directly to driver if available.
 * Otherwise, uses newlib provided putchar() routine.
 */
int 
alt_putchar(int c)
{
 c44:	dfc00215 	stw	ra,8(sp)
#ifdef ALT_USE_DIRECT_DRIVERS
    ALT_DRIVER_WRITE_EXTERNS(ALT_STDOUT_DEV);
    char        c1 = (char)(c & 0xff);
 c48:	dc000005 	stb	r16,0(sp)

    if (ALT_DRIVER_WRITE(ALT_STDOUT_DEV, &c1, 1, 0) == -1) {
 c4c:	0000c980 	call	c98 <altera_avalon_jtag_uart_write>
 c50:	1009883a 	mov	r4,r2
 c54:	00bfffc4 	movi	r2,-1
 c58:	2080011e 	bne	r4,r2,c60 <alt_putchar+0x3c>
 c5c:	2021883a 	mov	r16,r4
    }
    return c;
#else
    return putchar(c);
#endif
}
 c60:	8005883a 	mov	r2,r16
 c64:	dfc00217 	ldw	ra,8(sp)
 c68:	dc000117 	ldw	r16,4(sp)
 c6c:	dec00304 	addi	sp,sp,12
 c70:	f800283a 	ret

00000c74 <alt_sys_init>:
 */

void alt_sys_init( void )
{
    ALTERA_AVALON_JTAG_UART_INIT ( JTAG_UART, jtag_uart);
}
 c74:	f800283a 	ret

00000c78 <alt_irq_init>:
 * The "base" parameter is ignored and only
 * present for backwards-compatibility.
 */

void alt_irq_init ( const void* base )
{
 c78:	deffff04 	addi	sp,sp,-4
 c7c:	dfc00015 	stw	ra,0(sp)
    ALTERA_NIOS2_QSYS_IRQ_INIT ( NIOS2_PROCESSOR, nios2_processor);
 c80:	0000cd40 	call	cd4 <altera_nios2_qsys_irq_init>
 * alt_irq_cpu_enable_interrupts() enables the CPU to start taking interrupts.
 */
static ALT_INLINE void ALT_ALWAYS_INLINE 
       alt_irq_cpu_enable_interrupts ()
{
    NIOS2_WRITE_STATUS(NIOS2_STATUS_PIE_MSK
 c84:	00800044 	movi	r2,1
 c88:	1001703a 	wrctl	status,r2
    alt_irq_cpu_enable_interrupts();
}
 c8c:	dfc00017 	ldw	ra,0(sp)
 c90:	dec00104 	addi	sp,sp,4
 c94:	f800283a 	ret

00000c98 <altera_avalon_jtag_uart_write>:
 */

int altera_avalon_jtag_uart_write(altera_avalon_jtag_uart_state* sp, 
  const char * ptr, int count, int flags)
{
  unsigned int base = sp->base;
 c98:	21000017 	ldw	r4,0(r4)

  const char * end = ptr + count;
 c9c:	298f883a 	add	r7,r5,r6
 ca0:	20c00104 	addi	r3,r4,4
 ca4:	00000606 	br	cc0 <altera_avalon_jtag_uart_write+0x28>

  while (ptr < end)
    if ((IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) != 0)
 ca8:	18800037 	ldwio	r2,0(r3)
 cac:	10bfffec 	andhi	r2,r2,65535
 cb0:	10000326 	beq	r2,zero,cc0 <altera_avalon_jtag_uart_write+0x28>
      IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, *ptr++);
 cb4:	28800007 	ldb	r2,0(r5)
 cb8:	29400044 	addi	r5,r5,1
 cbc:	20800035 	stwio	r2,0(r4)
{
  unsigned int base = sp->base;

  const char * end = ptr + count;

  while (ptr < end)
 cc0:	29fff936 	bltu	r5,r7,ca8 <altera_avalon_jtag_uart_write+0x10>
    if ((IORD_ALTERA_AVALON_JTAG_UART_CONTROL(base) & ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK) != 0)
      IOWR_ALTERA_AVALON_JTAG_UART_DATA(base, *ptr++);

  return count;
}
 cc4:	3005883a 	mov	r2,r6
 cc8:	f800283a 	ret

00000ccc <alt_dcache_flush_all>:
  for (i = (char*) 0; i < (char*) NIOS2_DCACHE_SIZE; i+= NIOS2_DCACHE_LINE_SIZE)
  { 
    __asm__ volatile ("flushd (%0)" :: "r" (i));
  }
#endif /* NIOS2_DCACHE_SIZE > 0 */
}
 ccc:	f800283a 	ret

00000cd0 <alt_icache_flush_all>:
void alt_icache_flush_all (void)
{
#if NIOS2_ICACHE_SIZE > 0
  alt_icache_flush (0, NIOS2_ICACHE_SIZE);
#endif
}
 cd0:	f800283a 	ret

00000cd4 <altera_nios2_qsys_irq_init>:
 * To initialize the internal interrupt controller, just clear the IENABLE
 * register so that all possible IRQs are disabled.
 */
void altera_nios2_qsys_irq_init(void) 
{
    NIOS2_WRITE_IENABLE(0);
 cd4:	000170fa 	wrctl	ienable,zero
}
 cd8:	f800283a 	ret
