From e7aa93614bf118814217ee2e99048bce517bb8ca Mon Sep 17 00:00:00 2001 From: Blaise Tine Date: Thu, 5 Aug 2021 11:49:05 -0700 Subject: [PATCH] minor update --- hw/rtl/tex_unit/VX_tex_addr.v | 28 +- hw/rtl/tex_unit/VX_tex_memory.v | 28 +- hw/rtl/tex_unit/VX_tex_sampler.v | 16 +- hw/rtl/tex_unit/VX_tex_unit.v | 30 +- tests/regression/tex/Makefile | 2 +- tests/regression/tex/blitter.h | 24 +- tests/regression/tex/kernel.bin | Bin 10740 -> 0 bytes tests/regression/tex/kernel.dump | 1514 ---------------------------- tests/regression/tex/kernel.elf | Bin 12896 -> 0 bytes tests/regression/tex/lupng.c | 1313 ++++++++++++++++++++++++ tests/regression/tex/lupng.h | 186 ++++ tests/regression/tex/surfacedesc.h | 25 + tests/regression/tex/tga.cpp | 122 +++ tests/regression/tex/tga.h | 14 + 14 files changed, 1728 insertions(+), 1574 deletions(-) delete mode 100755 tests/regression/tex/kernel.bin delete mode 100644 tests/regression/tex/kernel.dump delete mode 100755 tests/regression/tex/kernel.elf create mode 100644 tests/regression/tex/lupng.c create mode 100644 tests/regression/tex/lupng.h create mode 100644 tests/regression/tex/surfacedesc.h create mode 100644 tests/regression/tex/tga.cpp create mode 100644 tests/regression/tex/tga.h diff --git a/hw/rtl/tex_unit/VX_tex_addr.v b/hw/rtl/tex_unit/VX_tex_addr.v index d8e372cf..a35b6945 100644 --- a/hw/rtl/tex_unit/VX_tex_addr.v +++ b/hw/rtl/tex_unit/VX_tex_addr.v @@ -1,9 +1,9 @@ `include "VX_tex_define.vh" module VX_tex_addr #( - parameter CORE_ID = 0, - parameter REQ_INFO_WIDTH = 1, - parameter NUM_REQS = 1 + parameter CORE_ID = 0, + parameter REQ_INFOW = 1, + parameter NUM_REQS = 1 ) ( input wire clk, input wire reset, @@ -19,7 +19,7 @@ module VX_tex_addr #( input wire [`TEX_ADDR_BITS-1:0] req_baseaddr, input wire [NUM_REQS-1:0][`TEX_MIPOFF_BITS-1:0] req_mipoff, input wire [NUM_REQS-1:0][1:0][`TEX_DIM_BITS-1:0] req_logdims, - input wire [REQ_INFO_WIDTH-1:0] req_info, + input wire [REQ_INFOW-1:0] req_info, output wire req_ready, // outputs @@ -30,7 +30,7 @@ module VX_tex_addr #( output wire [`TEX_STRIDE_BITS-1:0] rsp_stride, output wire [NUM_REQS-1:0][3:0][31:0] rsp_addr, output wire [NUM_REQS-1:0][1:0][`BLEND_FRAC-1:0] rsp_blends, - output wire [REQ_INFO_WIDTH-1:0] rsp_info, + output wire [REQ_INFOW-1:0] rsp_info, input wire rsp_ready ); @@ -38,10 +38,10 @@ module VX_tex_addr #( localparam PITCH_BITS = `ADDER_CARRY_WIDTH(`TEX_DIM_BITS, `TEX_STRIDE_BITS); - wire valid_s0; - wire [NUM_REQS-1:0] tmask_s0; + wire valid_s0; + wire [NUM_REQS-1:0] tmask_s0; wire [`TEX_FILTER_BITS-1:0] filter_s0; - wire [REQ_INFO_WIDTH-1:0] req_info_s0; + wire [REQ_INFOW-1:0] req_info_s0; wire [NUM_REQS-1:0][1:0][`FIXED_FRAC-1:0] clamped_lo, clamped_lo_s0; wire [NUM_REQS-1:0][1:0][`FIXED_FRAC-1:0] clamped_hi, clamped_hi_s0; wire [`TEX_STRIDE_BITS-1:0] log_stride, log_stride_s0; @@ -90,7 +90,7 @@ module VX_tex_addr #( end VX_pipe_register #( - .DATAW (1 + NUM_REQS + `TEX_FILTER_BITS + `TEX_STRIDE_BITS + REQ_INFO_WIDTH + NUM_REQS * (PITCH_BITS + `TEX_DIM_BITS + 32 + 2 * 2 * `FIXED_FRAC)), + .DATAW (1 + NUM_REQS + `TEX_FILTER_BITS + `TEX_STRIDE_BITS + REQ_INFOW + NUM_REQS * (PITCH_BITS + `TEX_DIM_BITS + 32 + 2 * 2 * `FIXED_FRAC)), .RESETW (1) ) pipe_reg0 ( .clk (clk), @@ -127,7 +127,7 @@ module VX_tex_addr #( assign stall_out = rsp_valid && ~rsp_ready; VX_pipe_register #( - .DATAW (1 + NUM_REQS + `TEX_FILTER_BITS + `TEX_STRIDE_BITS + (NUM_REQS * 4 * 32) + (2 * NUM_REQS * `BLEND_FRAC) + REQ_INFO_WIDTH), + .DATAW (1 + NUM_REQS + `TEX_FILTER_BITS + `TEX_STRIDE_BITS + (NUM_REQS * 4 * 32) + (2 * NUM_REQS * `BLEND_FRAC) + REQ_INFOW), .RESETW (1) ) pipe_reg1 ( .clk (clk), @@ -157,18 +157,18 @@ module VX_tex_addr #( function logic [(`FIXED_INT+`TEX_STRIDE_BITS)-1:0] scale_to_pitch (input logic [`FIXED_FRAC-1:0] src, input logic [PITCH_BITS-1:0] dim); -`IGNORE_UNUSED_BEGIN +`IGNORE_WARNINGS_BEGIN logic [(`FIXED_BITS+`TEX_STRIDE_BITS)-1:0] out; -`IGNORE_UNUSED_END +`IGNORE_WARNINGS_END out = (`FIXED_BITS+`TEX_STRIDE_BITS)'(src) << dim; return out[`FIXED_FRAC +: (`FIXED_INT+`TEX_STRIDE_BITS)]; endfunction function logic [`FIXED_INT-1:0] scale_to_height (input logic [`FIXED_FRAC-1:0] src, input logic [`TEX_DIM_BITS-1:0] dim); -`IGNORE_UNUSED_BEGIN +`IGNORE_WARNINGS_BEGIN logic [`FIXED_BITS-1:0] out; -`IGNORE_UNUSED_END +`IGNORE_WARNINGS_END out = `FIXED_BITS'(src) << dim; return out[`FIXED_FRAC +: `FIXED_INT]; endfunction diff --git a/hw/rtl/tex_unit/VX_tex_memory.v b/hw/rtl/tex_unit/VX_tex_memory.v index 3a864c34..a1e52beb 100644 --- a/hw/rtl/tex_unit/VX_tex_memory.v +++ b/hw/rtl/tex_unit/VX_tex_memory.v @@ -1,8 +1,8 @@ `include "VX_tex_define.vh" module VX_tex_memory #( - parameter CORE_ID = 0, - parameter REQ_INFO_WIDTH = 1, - parameter NUM_REQS = 1 + parameter CORE_ID = 0, + parameter REQ_INFOW = 1, + parameter NUM_REQS = 1 ) ( input wire clk, input wire reset, @@ -17,14 +17,14 @@ module VX_tex_memory #( input wire [`TEX_FILTER_BITS-1:0] req_filter, input wire [`TEX_STRIDE_BITS-1:0] req_stride, input wire [NUM_REQS-1:0][3:0][31:0] req_addr, - input wire [REQ_INFO_WIDTH-1:0] req_info, + input wire [REQ_INFOW-1:0] req_info, output wire req_ready, // outputs output wire rsp_valid, output wire [NUM_REQS-1:0] rsp_tmask, output wire [NUM_REQS-1:0][3:0][31:0] rsp_data, - output wire [REQ_INFO_WIDTH-1:0] rsp_info, + output wire [REQ_INFOW-1:0] rsp_info, input wire rsp_ready ); @@ -59,18 +59,18 @@ module VX_tex_memory #( wire reqq_push, reqq_pop, reqq_empty, reqq_full; - wire [3:0][NUM_REQS-1:0][29:0] q_req_addr; - wire [NUM_REQS-1:0] q_req_tmask; - wire [`TEX_FILTER_BITS-1:0] q_req_filter; - wire [REQ_INFO_WIDTH-1:0] q_req_info; - wire [`TEX_STRIDE_BITS-1:0] q_req_stride; - wire [3:0][NUM_REQS-1:0][1:0] q_align_offs; - wire [3:0] q_dup_reqs; + wire [3:0][NUM_REQS-1:0][29:0] q_req_addr; + wire [NUM_REQS-1:0] q_req_tmask; + wire [`TEX_FILTER_BITS-1:0] q_req_filter; + wire [REQ_INFOW-1:0] q_req_info; + wire [`TEX_STRIDE_BITS-1:0] q_req_stride; + wire [3:0][NUM_REQS-1:0][1:0] q_align_offs; + wire [3:0] q_dup_reqs; assign reqq_push = req_valid && req_ready; VX_fifo_queue #( - .DATAW ((NUM_REQS * 4 * 30) + NUM_REQS + REQ_INFO_WIDTH + `TEX_FILTER_BITS + `TEX_STRIDE_BITS + (4 * NUM_REQS * 2) + 4), + .DATAW ((NUM_REQS * 4 * 30) + NUM_REQS + REQ_INFOW + `TEX_FILTER_BITS + `TEX_STRIDE_BITS + (4 * NUM_REQS * 2) + 4), .SIZE (`LSUQ_SIZE), .OUTPUT_REG (1) ) req_queue ( @@ -244,7 +244,7 @@ module VX_tex_memory #( assign reqq_pop = rsp_texels_done && ~stall_out; VX_pipe_register #( - .DATAW (1 + NUM_REQS + REQ_INFO_WIDTH + (4 * NUM_REQS * 32)), + .DATAW (1 + NUM_REQS + REQ_INFOW + (4 * NUM_REQS * 32)), .RESETW (1) ) rsp_pipe_reg ( .clk (clk), diff --git a/hw/rtl/tex_unit/VX_tex_sampler.v b/hw/rtl/tex_unit/VX_tex_sampler.v index e7779df5..a8bf7fc0 100644 --- a/hw/rtl/tex_unit/VX_tex_sampler.v +++ b/hw/rtl/tex_unit/VX_tex_sampler.v @@ -1,9 +1,9 @@ `include "VX_tex_define.vh" module VX_tex_sampler #( - parameter CORE_ID = 0, - parameter REQ_INFO_WIDTH = 1, - parameter NUM_REQS = 1 + parameter CORE_ID = 0, + parameter REQ_INFOW = 1, + parameter NUM_REQS = 1 ) ( input wire clk, input wire reset, @@ -14,14 +14,14 @@ module VX_tex_sampler #( input wire [`TEX_FORMAT_BITS-1:0] req_format, input wire [NUM_REQS-1:0][1:0][`BLEND_FRAC-1:0] req_blends, input wire [NUM_REQS-1:0][3:0][31:0] req_data, - input wire [REQ_INFO_WIDTH-1:0] req_info, + input wire [REQ_INFOW-1:0] req_info, output wire req_ready, // ouputs output wire rsp_valid, output wire [NUM_REQS-1:0] rsp_tmask, output wire [NUM_REQS-1:0][31:0] rsp_data, - output wire [REQ_INFO_WIDTH-1:0] rsp_info, + output wire [REQ_INFOW-1:0] rsp_info, input wire rsp_ready ); @@ -29,7 +29,7 @@ module VX_tex_sampler #( wire valid_s0; wire [NUM_REQS-1:0] tmask_s0; - wire [REQ_INFO_WIDTH-1:0] req_info_s0; + wire [REQ_INFOW-1:0] req_info_s0; wire [NUM_REQS-1:0][31:0] texel_ul, texel_uh; wire [NUM_REQS-1:0][31:0] texel_ul_s0, texel_uh_s0; wire [NUM_REQS-1:0][`BLEND_FRAC-1:0] blend_v, blend_v_s0; @@ -76,7 +76,7 @@ module VX_tex_sampler #( end VX_pipe_register #( - .DATAW (1 + NUM_REQS + REQ_INFO_WIDTH + (NUM_REQS * `BLEND_FRAC) + (2 * NUM_REQS * 32)), + .DATAW (1 + NUM_REQS + REQ_INFOW + (NUM_REQS * `BLEND_FRAC) + (2 * NUM_REQS * 32)), .RESETW (1) ) pipe_reg0 ( .clk (clk), @@ -103,7 +103,7 @@ module VX_tex_sampler #( assign stall_out = rsp_valid && ~rsp_ready; VX_pipe_register #( - .DATAW (1 + NUM_REQS + REQ_INFO_WIDTH + (NUM_REQS * 32)), + .DATAW (1 + NUM_REQS + REQ_INFOW + (NUM_REQS * 32)), .RESETW (1) ) pipe_reg1 ( .clk (clk), diff --git a/hw/rtl/tex_unit/VX_tex_unit.v b/hw/rtl/tex_unit/VX_tex_unit.v index 8c8d32f9..5db12f16 100644 --- a/hw/rtl/tex_unit/VX_tex_unit.v +++ b/hw/rtl/tex_unit/VX_tex_unit.v @@ -18,9 +18,9 @@ module VX_tex_unit #( VX_tex_rsp_if tex_rsp_if ); - localparam REQ_INFO_WIDTH_S = `NR_BITS + 1 + `NW_BITS + 32; - localparam REQ_INFO_WIDTH_A = `TEX_FORMAT_BITS + REQ_INFO_WIDTH_S; - localparam REQ_INFO_WIDTH_M = (2 * `NUM_THREADS * `BLEND_FRAC) + REQ_INFO_WIDTH_A; + localparam REQ_INFOW_S = `NR_BITS + 1 + `NW_BITS + 32; + localparam REQ_INFOW_A = `TEX_FORMAT_BITS + REQ_INFOW_S; + localparam REQ_INFOW_M = (2 * `NUM_THREADS * `BLEND_FRAC) + REQ_INFOW_A; reg [`TEX_MIPOFF_BITS-1:0] tex_mipoff [`NUM_TEX_UNITS-1:0][(1 << `TEX_LOD_BITS)-1:0]; reg [1:0][`TEX_DIM_BITS-1:0] tex_dims [`NUM_TEX_UNITS-1:0][(1 << `TEX_LOD_BITS)-1:0]; @@ -96,13 +96,13 @@ module VX_tex_unit #( wire [`TEX_STRIDE_BITS-1:0] mem_req_stride; wire [`NUM_THREADS-1:0][1:0][`BLEND_FRAC-1:0] mem_req_blends; wire [`NUM_THREADS-1:0][3:0][31:0] mem_req_addr; - wire [REQ_INFO_WIDTH_A-1:0] mem_req_info; + wire [REQ_INFOW_A-1:0] mem_req_info; wire mem_req_ready; VX_tex_addr #( - .CORE_ID (CORE_ID), - .REQ_INFO_WIDTH (REQ_INFO_WIDTH_A), - .NUM_REQS (`NUM_THREADS) + .CORE_ID (CORE_ID), + .REQ_INFOW (REQ_INFOW_A), + .NUM_REQS (`NUM_THREADS) ) tex_addr ( .clk (clk), .reset (reset), @@ -134,13 +134,13 @@ module VX_tex_unit #( wire mem_rsp_valid; wire [`NUM_THREADS-1:0] mem_rsp_tmask; wire [`NUM_THREADS-1:0][3:0][31:0] mem_rsp_data; - wire [REQ_INFO_WIDTH_M-1:0] mem_rsp_info; + wire [REQ_INFOW_M-1:0] mem_rsp_info; wire mem_rsp_ready; VX_tex_memory #( - .CORE_ID (CORE_ID), - .REQ_INFO_WIDTH (REQ_INFO_WIDTH_M), - .NUM_REQS (`NUM_THREADS) + .CORE_ID (CORE_ID), + .REQ_INFOW (REQ_INFOW_M), + .NUM_REQS (`NUM_THREADS) ) tex_memory ( .clk (clk), .reset (reset), @@ -170,14 +170,14 @@ module VX_tex_unit #( wire [`NUM_THREADS-1:0][1:0][`BLEND_FRAC-1:0] rsp_blends; wire [`TEX_FORMAT_BITS-1:0] rsp_format; - wire [REQ_INFO_WIDTH_S-1:0] rsp_info; + wire [REQ_INFOW_S-1:0] rsp_info; assign {rsp_blends, rsp_format, rsp_info} = mem_rsp_info; VX_tex_sampler #( - .CORE_ID (CORE_ID), - .REQ_INFO_WIDTH (REQ_INFO_WIDTH_S), - .NUM_REQS (`NUM_THREADS) + .CORE_ID (CORE_ID), + .REQ_INFOW (REQ_INFOW_S), + .NUM_REQS (`NUM_THREADS) ) tex_sampler ( .clk (clk), .reset (reset), diff --git a/tests/regression/tex/Makefile b/tests/regression/tex/Makefile index a4d2b32c..0c47a8bc 100644 --- a/tests/regression/tex/Makefile +++ b/tests/regression/tex/Makefile @@ -2,7 +2,7 @@ RISCV_TOOLCHAIN_PATH ?= /opt/riscv-gnu-toolchain VORTEX_DRV_PATH ?= $(realpath ../../../driver) VORTEX_RT_PATH ?= $(wildcard ../../../runtime) -OPTS ?= -f1 +OPTS ?= -g1 VX_CC = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-gcc VX_CXX = $(RISCV_TOOLCHAIN_PATH)/bin/riscv32-unknown-elf-g++ diff --git a/tests/regression/tex/blitter.h b/tests/regression/tex/blitter.h index 1e50dfd6..e05f64b8 100644 --- a/tests/regression/tex/blitter.h +++ b/tests/regression/tex/blitter.h @@ -1,12 +1,20 @@ -#include "format.h" +// +// Copyright (c) Blaise Tine. All rights reserved. +// +// +// Use of this sample source code is subject to the terms of the Microsoft +// license agreement under which you licensed this sample source code. If +// you did not accept the terms of the license agreement, you are not +// authorized to use this sample source code. For the terms of the license, +// please see the license agreement between you and Microsoft or, if applicable, +// see the LICENSE.RTF on your install media or the root of your tools +// installation. +// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR +// INDEMNITIES. +// +#pragma once -struct SurfaceDesc { - ePixelFormat Format; - uint8_t *pBits; - uint32_t Width; - uint32_t Height; - uint32_t Pitch; -}; +#include "surfacedesc.h" class BlitTable { public: diff --git a/tests/regression/tex/kernel.bin b/tests/regression/tex/kernel.bin deleted file mode 100755 index cb5d62ec622d53695168b90894aaa944fdb58cf0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10740 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 diff --git a/tests/regression/tex/kernel.dump b/tests/regression/tex/kernel.dump deleted file mode 100644 index ca725c4d..00000000 --- a/tests/regression/tex/kernel.dump +++ /dev/null @@ -1,1514 +0,0 @@ - -kernel.elf: file format elf32-littleriscv - - -Disassembly of section .init: - -80000000 <_start>: -80000000: 00001597 auipc a1,0x1 -80000004: d8458593 addi a1,a1,-636 # 80000d84 -80000008: fc102573 csrr a0,0xfc1 -8000000c: 00b5106b 0xb5106b -80000010: 575000ef jal ra,80000d84 -80000014: 00100513 li a0,1 -80000018: 0005006b 0x5006b -8000001c: 00003517 auipc a0,0x3 -80000020: 9d850513 addi a0,a0,-1576 # 800029f4 -80000024: 00003617 auipc a2,0x3 -80000028: a5060613 addi a2,a2,-1456 # 80002a74 <__BSS_END__> -8000002c: 40a60633 sub a2,a2,a0 -80000030: 00000593 li a1,0 -80000034: 2e8010ef jal ra,8000131c -80000038: 00001517 auipc a0,0x1 -8000003c: e2450513 addi a0,a0,-476 # 80000e5c <__libc_fini_array> -80000040: 294010ef jal ra,800012d4 -80000044: 57d000ef jal ra,80000dc0 <__libc_init_array> -80000048: 008000ef jal ra,80000050
-8000004c: 29c0106f j 800012e8 - -Disassembly of section .text: - -80000050
: -80000050: fd010113 addi sp,sp,-48 -80000054: 7ffff7b7 lui a5,0x7ffff -80000058: 02112623 sw ra,44(sp) -8000005c: 0107a703 lw a4,16(a5) # 7ffff010 <__stack_size+0x7fffec10> -80000060: fd071073 csrw 0xfd0,a4 -80000064: fd405073 csrwi 0xfd4,0 -80000068: 00c7c703 lbu a4,12(a5) -8000006c: fd571073 csrw 0xfd5,a4 -80000070: 00d7c703 lbu a4,13(a5) -80000074: fd671073 csrw 0xfd6,a4 -80000078: 0047c703 lbu a4,4(a5) -8000007c: fd171073 csrw 0xfd1,a4 -80000080: 0067c683 lbu a3,6(a5) -80000084: 00269713 slli a4,a3,0x2 -80000088: 00d76733 or a4,a4,a3 -8000008c: fd271073 csrw 0xfd2,a4 -80000090: 0057c703 lbu a4,5(a5) -80000094: 00e03733 snez a4,a4 -80000098: fd371073 csrw 0xfd3,a4 -8000009c: 0147a703 lw a4,20(a5) -800000a0: 800036b7 lui a3,0x80003 -800000a4: 9ec6a787 flw fa5,-1556(a3) # 800029ec <__stack_top+0x810029ec> -800000a8: 00e12823 sw a4,16(sp) -800000ac: 0007a503 lw a0,0(a5) -800000b0: 0187a683 lw a3,24(a5) -800000b4: d0177753 fcvt.s.wu fa4,a4 -800000b8: 800005b7 lui a1,0x80000 -800000bc: 00a68733 add a4,a3,a0 -800000c0: fff70713 addi a4,a4,-1 -800000c4: 02a75733 divu a4,a4,a0 -800000c8: d016f6d3 fcvt.s.wu fa3,a3 -800000cc: 18e7f753 fdiv.s fa4,fa5,fa4 -800000d0: 00c10613 addi a2,sp,12 -800000d4: 6c458593 addi a1,a1,1732 # 800006c4 <__stack_top+0x810006c4> -800000d8: 00f12623 sw a5,12(sp) -800000dc: 18d7f7d3 fdiv.s fa5,fa5,fa3 -800000e0: 00e12c27 fsw fa4,24(sp) -800000e4: 00e12a23 sw a4,20(sp) -800000e8: 00f12e27 fsw fa5,28(sp) -800000ec: 68d000ef jal ra,80000f78 -800000f0: 02c12083 lw ra,44(sp) -800000f4: 03010113 addi sp,sp,48 -800000f8: 00008067 ret - -800000fc : -800000fc: 00000793 li a5,0 -80000100: 00078863 beqz a5,80000110 -80000104: 80001537 lui a0,0x80001 -80000108: e5c50513 addi a0,a0,-420 # 80000e5c <__stack_top+0x81000e5c> -8000010c: 1c80106f j 800012d4 -80000110: 00008067 ret - -80000114 : -80000114: 00554783 lbu a5,5(a0) -80000118: 00c54303 lbu t1,12(a0) -8000011c: 00d54803 lbu a6,13(a0) -80000120: 00454683 lbu a3,4(a0) -80000124: 00654e83 lbu t4,6(a0) -80000128: 01052883 lw a7,16(a0) -8000012c: 2e078063 beqz a5,8000040c -80000130: 00080e37 lui t3,0x80 -80000134: 406e5733 sra a4,t3,t1 -80000138: 00100f13 li t5,1 -8000013c: 410e5e33 sra t3,t3,a6 -80000140: 40e587b3 sub a5,a1,a4 -80000144: 41c60533 sub a0,a2,t3 -80000148: 00b70733 add a4,a4,a1 -8000014c: 01c60633 add a2,a2,t3 -80000150: 3bee8e63 beq t4,t5,8000050c -80000154: fff7c593 not a1,a5 -80000158: 41f5d593 srai a1,a1,0x1f -8000015c: 00b7f7b3 and a5,a5,a1 -80000160: 001005b7 lui a1,0x100 -80000164: 42b7d463 bge a5,a1,8000058c -80000168: fff54593 not a1,a0 -8000016c: 41f5d593 srai a1,a1,0x1f -80000170: 00b57533 and a0,a0,a1 -80000174: 001005b7 lui a1,0x100 -80000178: 3cb55a63 bge a0,a1,8000054c -8000017c: fff74593 not a1,a4 -80000180: 41f5d593 srai a1,a1,0x1f -80000184: 00b77733 and a4,a4,a1 -80000188: 001005b7 lui a1,0x100 -8000018c: 3ab75263 bge a4,a1,80000530 -80000190: fff64593 not a1,a2 -80000194: 41f5d593 srai a1,a1,0x1f -80000198: 00b67633 and a2,a2,a1 -8000019c: 001005b7 lui a1,0x100 -800001a0: 38b65463 bge a2,a1,80000528 -800001a4: 01400593 li a1,20 -800001a8: 41058833 sub a6,a1,a6 -800001ac: 41055533 sra a0,a0,a6 -800001b0: 406585b3 sub a1,a1,t1 -800001b4: 41065633 sra a2,a2,a6 -800001b8: 00661633 sll a2,a2,t1 -800001bc: 40b7d833 sra a6,a5,a1 -800001c0: 40b75733 sra a4,a4,a1 -800001c4: 006515b3 sll a1,a0,t1 -800001c8: 00b80333 add t1,a6,a1 -800001cc: 00c807b3 add a5,a6,a2 -800001d0: 00b705b3 add a1,a4,a1 -800001d4: 00c70733 add a4,a4,a2 -800001d8: 00259593 slli a1,a1,0x2 -800001dc: 00231613 slli a2,t1,0x2 -800001e0: 00279793 slli a5,a5,0x2 -800001e4: 00271713 slli a4,a4,0x2 -800001e8: 00c88633 add a2,a7,a2 -800001ec: 00b885b3 add a1,a7,a1 -800001f0: 00f887b3 add a5,a7,a5 -800001f4: 00e88733 add a4,a7,a4 -800001f8: 00400893 li a7,4 -800001fc: 00062f03 lw t5,0(a2) -80000200: 0007ae83 lw t4,0(a5) -80000204: 0005a603 lw a2,0(a1) # 100000 <__stack_size+0xffc00> -80000208: 00072783 lw a5,0(a4) -8000020c: 0ff87813 andi a6,a6,255 -80000210: 0ff57593 andi a1,a0,255 -80000214: 3f168c63 beq a3,a7,8000060c -80000218: 14d8ee63 bltu a7,a3,80000374 -8000021c: 00300713 li a4,3 -80000220: 0ae69063 bne a3,a4,800002c0 -80000224: 008f1713 slli a4,t5,0x8 -80000228: 008e9513 slli a0,t4,0x8 -8000022c: 00861313 slli t1,a2,0x8 -80000230: 00879893 slli a7,a5,0x8 -80000234: 00ff0e37 lui t3,0xff0 -80000238: 0ffe0e13 addi t3,t3,255 # ff00ff <__stack_size+0xfefcff> -8000023c: 01e76f33 or t5,a4,t5 -80000240: 01d56533 or a0,a0,t4 -80000244: 00f8e7b3 or a5,a7,a5 -80000248: 00c36633 or a2,t1,a2 -8000024c: 01c57eb3 and t4,a0,t3 -80000250: 01cf7f33 and t5,t5,t3 -80000254: 01c7f533 and a0,a5,t3 -80000258: 01c67633 and a2,a2,t3 -8000025c: 41d50533 sub a0,a0,t4 -80000260: 41e607b3 sub a5,a2,t5 -80000264: 030787b3 mul a5,a5,a6 -80000268: 00000713 li a4,0 -8000026c: 03050833 mul a6,a0,a6 -80000270: 4087d793 srai a5,a5,0x8 -80000274: 01e787b3 add a5,a5,t5 -80000278: 01c7f7b3 and a5,a5,t3 -8000027c: 40885513 srai a0,a6,0x8 -80000280: 01d50533 add a0,a0,t4 -80000284: 01c57533 and a0,a0,t3 -80000288: 40f50533 sub a0,a0,a5 -8000028c: 02b50533 mul a0,a0,a1 -80000290: 40855513 srai a0,a0,0x8 -80000294: 00f50533 add a0,a0,a5 -80000298: 01c57533 and a0,a0,t3 -8000029c: 00400793 li a5,4 -800002a0: 24d7e663 bltu a5,a3,800004ec -800002a4: 00300793 li a5,3 -800002a8: 22f69463 bne a3,a5,800004d0 -800002ac: 40855793 srai a5,a0,0x8 -800002b0: 00a7e533 or a0,a5,a0 -800002b4: 01051513 slli a0,a0,0x10 -800002b8: 01055513 srli a0,a0,0x10 -800002bc: 00008067 ret -800002c0: 30069263 bnez a3,800005c4 -800002c4: 00ff0537 lui a0,0xff0 -800002c8: 0ff50313 addi t1,a0,255 # ff00ff <__stack_size+0xfefcff> -800002cc: 006f72b3 and t0,t5,t1 -800002d0: 00667e33 and t3,a2,t1 -800002d4: 4087d893 srai a7,a5,0x8 -800002d8: 405e0e33 sub t3,t3,t0 -800002dc: 006effb3 and t6,t4,t1 -800002e0: 0067f733 and a4,a5,t1 -800002e4: 408f5f13 srai t5,t5,0x8 -800002e8: 0068f7b3 and a5,a7,t1 -800002ec: 40865613 srai a2,a2,0x8 -800002f0: 030e08b3 mul a7,t3,a6 -800002f4: 408ede93 srai t4,t4,0x8 -800002f8: 006f7f33 and t5,t5,t1 -800002fc: 006efeb3 and t4,t4,t1 -80000300: 00667633 and a2,a2,t1 -80000304: 41f70733 sub a4,a4,t6 -80000308: 41d787b3 sub a5,a5,t4 -8000030c: 41e60633 sub a2,a2,t5 -80000310: 03070733 mul a4,a4,a6 -80000314: 4088d893 srai a7,a7,0x8 -80000318: 00588533 add a0,a7,t0 -8000031c: 006578b3 and a7,a0,t1 -80000320: 03060633 mul a2,a2,a6 -80000324: 40875513 srai a0,a4,0x8 -80000328: 01f50533 add a0,a0,t6 -8000032c: 00657533 and a0,a0,t1 -80000330: 41150533 sub a0,a0,a7 -80000334: 03078833 mul a6,a5,a6 -80000338: 40865793 srai a5,a2,0x8 -8000033c: 01e787b3 add a5,a5,t5 -80000340: 0067f7b3 and a5,a5,t1 -80000344: 40885713 srai a4,a6,0x8 -80000348: 01d70733 add a4,a4,t4 -8000034c: 00677733 and a4,a4,t1 -80000350: 02b50533 mul a0,a0,a1 -80000354: 40f70733 sub a4,a4,a5 -80000358: 02b70733 mul a4,a4,a1 -8000035c: 40855513 srai a0,a0,0x8 -80000360: 01150533 add a0,a0,a7 -80000364: 00657533 and a0,a0,t1 -80000368: 40875713 srai a4,a4,0x8 -8000036c: 00f70733 add a4,a4,a5 -80000370: f2dff06f j 8000029c -80000374: 00500713 li a4,5 -80000378: f4e696e3 bne a3,a4,800002c4 -8000037c: 00cf1693 slli a3,t5,0xc -80000380: 00c61313 slli t1,a2,0xc -80000384: 00ce9513 slli a0,t4,0xc -80000388: 00c79893 slli a7,a5,0xc -8000038c: 0f0f1737 lui a4,0xf0f1 -80000390: f0f70713 addi a4,a4,-241 # f0f0f0f <__stack_size+0xf0f0b0f> -80000394: 00f8e7b3 or a5,a7,a5 -80000398: 01e6ef33 or t5,a3,t5 -8000039c: 00c36633 or a2,t1,a2 -800003a0: 01d56eb3 or t4,a0,t4 -800003a4: 00ef7f33 and t5,t5,a4 -800003a8: 00eefeb3 and t4,t4,a4 -800003ac: 00e67633 and a2,a2,a4 -800003b0: 00e7f733 and a4,a5,a4 -800003b4: 41d70733 sub a4,a4,t4 -800003b8: 41e607b3 sub a5,a2,t5 -800003bc: 030787b3 mul a5,a5,a6 -800003c0: 00ff0537 lui a0,0xff0 -800003c4: 0ff50513 addi a0,a0,255 # ff00ff <__stack_size+0xfefcff> -800003c8: 03070833 mul a6,a4,a6 -800003cc: 4087d793 srai a5,a5,0x8 -800003d0: 01e787b3 add a5,a5,t5 -800003d4: 00a7f7b3 and a5,a5,a0 -800003d8: 40885713 srai a4,a6,0x8 -800003dc: 01d70733 add a4,a4,t4 -800003e0: 00a77733 and a4,a4,a0 -800003e4: 40f70733 sub a4,a4,a5 -800003e8: 02b70733 mul a4,a4,a1 -800003ec: 40875713 srai a4,a4,0x8 -800003f0: 00f70733 add a4,a4,a5 -800003f4: 00a77533 and a0,a4,a0 -800003f8: 40c55793 srai a5,a0,0xc -800003fc: 00a7e533 or a0,a5,a0 -80000400: 01051513 slli a0,a0,0x10 -80000404: 01055513 srli a0,a0,0x10 -80000408: 00008067 ret -8000040c: 00100793 li a5,1 -80000410: 18fe8c63 beq t4,a5,800005a8 -80000414: fff5c713 not a4,a1 -80000418: 41f75713 srai a4,a4,0x1f -8000041c: 00e5f733 and a4,a1,a4 -80000420: 001007b7 lui a5,0x100 -80000424: 14f75663 bge a4,a5,80000570 -80000428: fff64793 not a5,a2 -8000042c: 41f7d793 srai a5,a5,0x1f -80000430: 00f67633 and a2,a2,a5 -80000434: 001007b7 lui a5,0x100 -80000438: 12f65863 bge a2,a5,80000568 -8000043c: 01400593 li a1,20 -80000440: 41058833 sub a6,a1,a6 -80000444: 41065633 sra a2,a2,a6 -80000448: 406585b3 sub a1,a1,t1 -8000044c: 40b75733 sra a4,a4,a1 -80000450: 00661633 sll a2,a2,t1 -80000454: 00e60633 add a2,a2,a4 -80000458: 00261613 slli a2,a2,0x2 -8000045c: 00c88733 add a4,a7,a2 -80000460: 00400793 li a5,4 -80000464: 00072503 lw a0,0(a4) -80000468: 22f68a63 beq a3,a5,8000069c -8000046c: 02d7ea63 bltu a5,a3,800004a0 -80000470: 00300793 li a5,3 -80000474: 08f69a63 bne a3,a5,80000508 -80000478: 00851793 slli a5,a0,0x8 -8000047c: 00a7e533 or a0,a5,a0 -80000480: 00ff07b7 lui a5,0xff0 -80000484: 0ff78793 addi a5,a5,255 # ff00ff <__stack_size+0xfefcff> -80000488: 00f577b3 and a5,a0,a5 -8000048c: 4087d513 srai a0,a5,0x8 -80000490: 00f56533 or a0,a0,a5 -80000494: 01051513 slli a0,a0,0x10 -80000498: 01055513 srli a0,a0,0x10 -8000049c: 00008067 ret -800004a0: 00500793 li a5,5 -800004a4: 10f69c63 bne a3,a5,800005bc -800004a8: 00c51793 slli a5,a0,0xc -800004ac: 00a7e533 or a0,a5,a0 -800004b0: 0f0f17b7 lui a5,0xf0f1 -800004b4: f0f78793 addi a5,a5,-241 # f0f0f0f <__stack_size+0xf0f0b0f> -800004b8: 00f577b3 and a5,a0,a5 -800004bc: 40c7d513 srai a0,a5,0xc -800004c0: 00f56533 or a0,a0,a5 -800004c4: 01051513 slli a0,a0,0x10 -800004c8: 01055513 srli a0,a0,0x10 -800004cc: 00008067 ret -800004d0: 0e069863 bnez a3,800005c0 -800004d4: ff0107b7 lui a5,0xff010 -800004d8: f0078793 addi a5,a5,-256 # ff00ff00 <__stack_top+0xff00> -800004dc: 00871713 slli a4,a4,0x8 -800004e0: 00f77733 and a4,a4,a5 -800004e4: 00e56533 or a0,a0,a4 -800004e8: 00008067 ret -800004ec: 00500793 li a5,5 -800004f0: fef692e3 bne a3,a5,800004d4 -800004f4: 40c55793 srai a5,a0,0xc -800004f8: 00a7e533 or a0,a5,a0 -800004fc: 01051513 slli a0,a0,0x10 -80000500: 01055513 srli a0,a0,0x10 -80000504: 00008067 ret -80000508: 00008067 ret -8000050c: 001005b7 lui a1,0x100 -80000510: fff58593 addi a1,a1,-1 # fffff <__stack_size+0xffbff> -80000514: 00b7f7b3 and a5,a5,a1 -80000518: 00b57533 and a0,a0,a1 -8000051c: 00b77733 and a4,a4,a1 -80000520: 00b67633 and a2,a2,a1 -80000524: c81ff06f j 800001a4 -80000528: fff58613 addi a2,a1,-1 -8000052c: c79ff06f j 800001a4 -80000530: fff58713 addi a4,a1,-1 -80000534: fff64593 not a1,a2 -80000538: 41f5d593 srai a1,a1,0x1f -8000053c: 00b67633 and a2,a2,a1 -80000540: 001005b7 lui a1,0x100 -80000544: c6b640e3 blt a2,a1,800001a4 -80000548: fe1ff06f j 80000528 -8000054c: fff58513 addi a0,a1,-1 # fffff <__stack_size+0xffbff> -80000550: fff74593 not a1,a4 -80000554: 41f5d593 srai a1,a1,0x1f -80000558: 00b77733 and a4,a4,a1 -8000055c: 001005b7 lui a1,0x100 -80000560: c2b748e3 blt a4,a1,80000190 -80000564: fcdff06f j 80000530 -80000568: fff78613 addi a2,a5,-1 -8000056c: ed1ff06f j 8000043c -80000570: fff78713 addi a4,a5,-1 -80000574: fff64793 not a5,a2 -80000578: 41f7d793 srai a5,a5,0x1f -8000057c: 00f67633 and a2,a2,a5 -80000580: 001007b7 lui a5,0x100 -80000584: eaf64ce3 blt a2,a5,8000043c -80000588: fe1ff06f j 80000568 -8000058c: fff58793 addi a5,a1,-1 # fffff <__stack_size+0xffbff> -80000590: fff54593 not a1,a0 -80000594: 41f5d593 srai a1,a1,0x1f -80000598: 00b57533 and a0,a0,a1 -8000059c: 001005b7 lui a1,0x100 -800005a0: bcb54ee3 blt a0,a1,8000017c -800005a4: fa9ff06f j 8000054c -800005a8: 001007b7 lui a5,0x100 -800005ac: fff78793 addi a5,a5,-1 # fffff <__stack_size+0xffbff> -800005b0: 00f5f733 and a4,a1,a5 -800005b4: 00f67633 and a2,a2,a5 -800005b8: e85ff06f j 8000043c -800005bc: 00008067 ret -800005c0: 00008067 ret -800005c4: 41e606b3 sub a3,a2,t5 -800005c8: 41d787b3 sub a5,a5,t4 -800005cc: 030686b3 mul a3,a3,a6 -800005d0: 00ff0537 lui a0,0xff0 -800005d4: 0ff50713 addi a4,a0,255 # ff00ff <__stack_size+0xfefcff> -800005d8: 030787b3 mul a5,a5,a6 -800005dc: 4086d693 srai a3,a3,0x8 -800005e0: 01e686b3 add a3,a3,t5 -800005e4: 00e6f6b3 and a3,a3,a4 -800005e8: 4087d513 srai a0,a5,0x8 -800005ec: 01d50533 add a0,a0,t4 -800005f0: 00e57533 and a0,a0,a4 -800005f4: 40d50533 sub a0,a0,a3 -800005f8: 02b50533 mul a0,a0,a1 -800005fc: 40855513 srai a0,a0,0x8 -80000600: 00d50533 add a0,a0,a3 -80000604: 00e57533 and a0,a0,a4 -80000608: 00008067 ret -8000060c: 010f1713 slli a4,t5,0x10 -80000610: 01061893 slli a7,a2,0x10 -80000614: 010e9513 slli a0,t4,0x10 -80000618: 01079693 slli a3,a5,0x10 -8000061c: 07e10337 lui t1,0x7e10 -80000620: 81f30313 addi t1,t1,-2017 # 7e0f81f <__stack_size+0x7e0f41f> -80000624: 00f6e7b3 or a5,a3,a5 -80000628: 01e76f33 or t5,a4,t5 -8000062c: 00c8e633 or a2,a7,a2 -80000630: 01d56533 or a0,a0,t4 -80000634: 00657eb3 and t4,a0,t1 -80000638: 006f7f33 and t5,t5,t1 -8000063c: 0067f533 and a0,a5,t1 -80000640: 00667633 and a2,a2,t1 -80000644: 41d50533 sub a0,a0,t4 -80000648: 41e607b3 sub a5,a2,t5 -8000064c: 030787b3 mul a5,a5,a6 -80000650: 00ff0737 lui a4,0xff0 -80000654: 0ff70713 addi a4,a4,255 # ff00ff <__stack_size+0xfefcff> -80000658: 03050833 mul a6,a0,a6 -8000065c: 4087d793 srai a5,a5,0x8 -80000660: 01e787b3 add a5,a5,t5 -80000664: 00e7f7b3 and a5,a5,a4 -80000668: 40885513 srai a0,a6,0x8 -8000066c: 01d50533 add a0,a0,t4 -80000670: 00e57533 and a0,a0,a4 -80000674: 40f50533 sub a0,a0,a5 -80000678: 02b50533 mul a0,a0,a1 -8000067c: 40855513 srai a0,a0,0x8 -80000680: 00f50533 add a0,a0,a5 -80000684: 00e577b3 and a5,a0,a4 -80000688: 4107d513 srai a0,a5,0x10 -8000068c: 00f56533 or a0,a0,a5 -80000690: 01051513 slli a0,a0,0x10 -80000694: 01055513 srli a0,a0,0x10 -80000698: 00008067 ret -8000069c: 01051793 slli a5,a0,0x10 -800006a0: 00a7e533 or a0,a5,a0 -800006a4: 07e107b7 lui a5,0x7e10 -800006a8: 81f78793 addi a5,a5,-2017 # 7e0f81f <__stack_size+0x7e0f41f> -800006ac: 00f577b3 and a5,a0,a5 -800006b0: 4107d513 srai a0,a5,0x10 -800006b4: 00f56533 or a0,a0,a5 -800006b8: 01051513 slli a0,a0,0x10 -800006bc: 01055513 srli a0,a0,0x10 -800006c0: 00008067 ret - -800006c4 : -800006c4: 0085a703 lw a4,8(a1) # 100008 <__stack_size+0xffc08> -800006c8: f7010113 addi sp,sp,-144 -800006cc: 08812423 sw s0,136(sp) -800006d0: 02e507b3 mul a5,a0,a4 -800006d4: 0005a403 lw s0,0(a1) -800006d8: 05312027 fsw fs3,64(sp) -800006dc: 03512c27 fsw fs5,56(sp) -800006e0: 02042e03 lw t3,32(s0) -800006e4: 02442683 lw a3,36(s0) -800006e8: 0105aa87 flw fs5,16(a1) -800006ec: 08112623 sw ra,140(sp) -800006f0: 08912223 sw s1,132(sp) -800006f4: 09212023 sw s2,128(sp) -800006f8: 03c78e33 mul t3,a5,t3 -800006fc: d017f9d3 fcvt.s.wu fs3,a5 -80000700: 07312e23 sw s3,124(sp) -80000704: 07412c23 sw s4,120(sp) -80000708: 07512a23 sw s5,116(sp) -8000070c: 07612823 sw s6,112(sp) -80000710: 07712623 sw s7,108(sp) -80000714: 07812423 sw s8,104(sp) -80000718: 07912223 sw s9,100(sp) -8000071c: 07a12023 sw s10,96(sp) -80000720: 00de07b3 add a5,t3,a3 -80000724: 05b12e23 sw s11,92(sp) -80000728: 04812627 fsw fs0,76(sp) -8000072c: 04912427 fsw fs1,72(sp) -80000730: 05212227 fsw fs2,68(sp) -80000734: 03412e27 fsw fs4,60(sp) -80000738: 00f12623 sw a5,12(sp) -8000073c: 1159f9d3 fmul.s fs3,fs3,fs5 -80000740: 28070e63 beqz a4,800009dc -80000744: 80003737 lui a4,0x80003 -80000748: 9e872487 flw fs1,-1560(a4) # 800029e8 <__stack_top+0x810029e8> -8000074c: fff00737 lui a4,0xfff00 -80000750: 00b70713 addi a4,a4,11 # fff0000b <__stack_top+0xf0000b> -80000754: 00c5a907 flw fs2,12(a1) -80000758: f0000a53 fmv.w.x fs4,zero -8000075c: 00e12c23 sw a4,24(sp) -80000760: 07e10737 lui a4,0x7e10 -80000764: 81f70713 addi a4,a4,-2017 # 7e0f81f <__stack_size+0x7e0f41f> -80000768: 02e12223 sw a4,36(sp) -8000076c: 11497a53 fmul.s fs4,fs2,fs4 -80000770: 00010737 lui a4,0x10 -80000774: fff70713 addi a4,a4,-1 # ffff <__stack_size+0xfbff> -80000778: 00e12a23 sw a4,20(sp) -8000077c: 0045a783 lw a5,4(a1) -80000780: 0f0f1737 lui a4,0xf0f1 -80000784: f0f70713 addi a4,a4,-241 # f0f0f0f <__stack_size+0xf0f0b0f> -80000788: 00ff0bb7 lui s7,0xff0 -8000078c: 00058a13 mv s4,a1 -80000790: 00100ab7 lui s5,0x100 -80000794: 00012823 sw zero,16(sp) -80000798: 00200c13 li s8,2 -8000079c: 02e12423 sw a4,40(sp) -800007a0: 0ffb8b93 addi s7,s7,255 # ff00ff <__stack_size+0xfefcff> -800007a4: 22078c63 beqz a5,800009dc -800007a8: 1099f7d3 fmul.s fa5,fs3,fs1 -800007ac: 001007b7 lui a5,0x100 -800007b0: fff78793 addi a5,a5,-1 # fffff <__stack_size+0xffbff> -800007b4: 00744b03 lbu s6,7(s0) -800007b8: c00799d3 fcvt.w.s s3,fa5,rtz -800007bc: fff9cd13 not s10,s3 -800007c0: 41fd5d13 srai s10,s10,0x1f -800007c4: 00f9f7b3 and a5,s3,a5 -800007c8: 01a9fd33 and s10,s3,s10 -800007cc: 00f12e23 sw a5,28(sp) -800007d0: 015d4463 blt s10,s5,800007d8 -800007d4: fffa8d13 addi s10,s5,-1 # fffff <__stack_size+0xffbff> -800007d8: ff0107b7 lui a5,0xff010 -800007dc: 214a0453 fmv.s fs0,fs4 -800007e0: 00c12903 lw s2,12(sp) -800007e4: f0078793 addi a5,a5,-256 # ff00ff00 <__stack_top+0xff00> -800007e8: 00000493 li s1,0 -800007ec: 00100313 li t1,1 -800007f0: 01400d93 li s11,20 -800007f4: 00400c93 li s9,4 -800007f8: 00500893 li a7,5 -800007fc: 00300813 li a6,3 -80000800: 02f12023 sw a5,32(sp) -80000804: 109477d3 fmul.s fa5,fs0,fs1 -80000808: c00795d3 fcvt.w.s a1,fa5,rtz -8000080c: 220b0263 beqz s6,80000a30 -80000810: 00544683 lbu a3,5(s0) -80000814: 25868a63 beq a3,s8,80000a68 -80000818: 00c44603 lbu a2,12(s0) -8000081c: 00d44783 lbu a5,13(s0) -80000820: 00444703 lbu a4,4(s0) -80000824: 00644f83 lbu t6,6(s0) -80000828: 01042503 lw a0,16(s0) -8000082c: 24068c63 beqz a3,80000a84 -80000830: 000806b7 lui a3,0x80 -80000834: 40c6d3b3 sra t2,a3,a2 -80000838: 40f6d6b3 sra a3,a3,a5 -8000083c: 407582b3 sub t0,a1,t2 -80000840: 007585b3 add a1,a1,t2 -80000844: 40d983b3 sub t2,s3,a3 -80000848: 00d986b3 add a3,s3,a3 -8000084c: 406f8463 beq t6,t1,80000c54 -80000850: fff2cf93 not t6,t0 -80000854: 41ffdf93 srai t6,t6,0x1f -80000858: 01f2f2b3 and t0,t0,t6 -8000085c: 0152c463 blt t0,s5,80000864 -80000860: fffa8293 addi t0,s5,-1 -80000864: fff3cf93 not t6,t2 -80000868: 41ffdf93 srai t6,t6,0x1f -8000086c: 01f3f3b3 and t2,t2,t6 -80000870: 0153c463 blt t2,s5,80000878 -80000874: fffa8393 addi t2,s5,-1 -80000878: fff5cf93 not t6,a1 -8000087c: 41ffdf93 srai t6,t6,0x1f -80000880: 01f5f5b3 and a1,a1,t6 -80000884: 0155c463 blt a1,s5,8000088c -80000888: fffa8593 addi a1,s5,-1 -8000088c: fff6cf93 not t6,a3 -80000890: 41ffdf93 srai t6,t6,0x1f -80000894: 01f6f6b3 and a3,a3,t6 -80000898: 0156c463 blt a3,s5,800008a0 -8000089c: fffa8693 addi a3,s5,-1 -800008a0: 40fd87b3 sub a5,s11,a5 -800008a4: 40cd8fb3 sub t6,s11,a2 -800008a8: 40f6d6b3 sra a3,a3,a5 -800008ac: 40f3d3b3 sra t2,t2,a5 -800008b0: 00c397b3 sll a5,t2,a2 -800008b4: 41f2d2b3 sra t0,t0,t6 -800008b8: 41f5d5b3 sra a1,a1,t6 -800008bc: 00c69633 sll a2,a3,a2 -800008c0: 00f28fb3 add t6,t0,a5 -800008c4: 00c286b3 add a3,t0,a2 -800008c8: 00f587b3 add a5,a1,a5 -800008cc: 00c585b3 add a1,a1,a2 -800008d0: 002f9f93 slli t6,t6,0x2 -800008d4: 00279793 slli a5,a5,0x2 -800008d8: 00269693 slli a3,a3,0x2 -800008dc: 00259593 slli a1,a1,0x2 -800008e0: 01f50fb3 add t6,a0,t6 -800008e4: 00f507b3 add a5,a0,a5 -800008e8: 00d506b3 add a3,a0,a3 -800008ec: 00b505b3 add a1,a0,a1 -800008f0: 000faf83 lw t6,0(t6) -800008f4: 0007a783 lw a5,0(a5) -800008f8: 0006a683 lw a3,0(a3) # 80000 <__stack_size+0x7fc00> -800008fc: 0005a603 lw a2,0(a1) -80000900: 0ff2f293 andi t0,t0,255 -80000904: 0ff3f393 andi t2,t2,255 -80000908: 3f970063 beq a4,s9,80000ce8 -8000090c: 28ece863 bltu s9,a4,80000b9c -80000910: 1d071863 bne a4,a6,80000ae0 -80000914: 008f9593 slli a1,t6,0x8 -80000918: 00879513 slli a0,a5,0x8 -8000091c: 00869e93 slli t4,a3,0x8 -80000920: 00861e13 slli t3,a2,0x8 -80000924: 01f5e5b3 or a1,a1,t6 -80000928: 00f567b3 or a5,a0,a5 -8000092c: 00dee6b3 or a3,t4,a3 -80000930: 00ce6633 or a2,t3,a2 -80000934: 0175f5b3 and a1,a1,s7 -80000938: 0176f6b3 and a3,a3,s7 -8000093c: 0177f7b3 and a5,a5,s7 -80000940: 01767633 and a2,a2,s7 -80000944: 40b787b3 sub a5,a5,a1 -80000948: 40d60633 sub a2,a2,a3 -8000094c: 025787b3 mul a5,a5,t0 -80000950: 00000f93 li t6,0 -80000954: 025602b3 mul t0,a2,t0 -80000958: 4087d793 srai a5,a5,0x8 -8000095c: 00b785b3 add a1,a5,a1 -80000960: 0175f5b3 and a1,a1,s7 -80000964: 4082d293 srai t0,t0,0x8 -80000968: 00d287b3 add a5,t0,a3 -8000096c: 0177f7b3 and a5,a5,s7 -80000970: 40b787b3 sub a5,a5,a1 -80000974: 027783b3 mul t2,a5,t2 -80000978: 4083d393 srai t2,t2,0x8 -8000097c: 00b385b3 add a1,t2,a1 -80000980: 0175f533 and a0,a1,s7 -80000984: 20ece863 bltu s9,a4,80000b94 -80000988: 2b071a63 bne a4,a6,80000c3c -8000098c: 40855793 srai a5,a0,0x8 -80000990: 00a7e533 or a0,a5,a0 -80000994: 01412783 lw a5,20(sp) -80000998: 00f57533 and a0,a0,a5 -8000099c: 00a92023 sw a0,0(s2) -800009a0: 004a2783 lw a5,4(s4) -800009a4: 00148493 addi s1,s1,1 -800009a8: 01247453 fadd.s fs0,fs0,fs2 -800009ac: 00490913 addi s2,s2,4 -800009b0: e4f4eae3 bltu s1,a5,80000804 -800009b4: 01012603 lw a2,16(sp) -800009b8: 00c12583 lw a1,12(sp) -800009bc: 02042683 lw a3,32(s0) -800009c0: 008a2703 lw a4,8(s4) -800009c4: 00160613 addi a2,a2,1 -800009c8: 00d586b3 add a3,a1,a3 -800009cc: 00c12823 sw a2,16(sp) -800009d0: 00d12623 sw a3,12(sp) -800009d4: 0159f9d3 fadd.s fs3,fs3,fs5 -800009d8: dce666e3 bltu a2,a4,800007a4 -800009dc: 08c12083 lw ra,140(sp) -800009e0: 08812403 lw s0,136(sp) -800009e4: 08412483 lw s1,132(sp) -800009e8: 08012903 lw s2,128(sp) -800009ec: 07c12983 lw s3,124(sp) -800009f0: 07812a03 lw s4,120(sp) -800009f4: 07412a83 lw s5,116(sp) -800009f8: 07012b03 lw s6,112(sp) -800009fc: 06c12b83 lw s7,108(sp) -80000a00: 06812c03 lw s8,104(sp) -80000a04: 06412c83 lw s9,100(sp) -80000a08: 06012d03 lw s10,96(sp) -80000a0c: 05c12d83 lw s11,92(sp) -80000a10: 04c12407 flw fs0,76(sp) -80000a14: 04812487 flw fs1,72(sp) -80000a18: 04412907 flw fs2,68(sp) -80000a1c: 04012987 flw fs3,64(sp) -80000a20: 03c12a07 flw fs4,60(sp) -80000a24: 03812a87 flw fs5,56(sp) -80000a28: 09010113 addi sp,sp,144 -80000a2c: 00008067 ret -80000a30: 00544703 lbu a4,5(s0) -80000a34: 00842783 lw a5,8(s0) -80000a38: 01870863 beq a4,s8,80000a48 -80000a3c: 7935d76b 0x7935d76b -80000a40: 00e92023 sw a4,0(s2) -80000a44: f5dff06f j 800009a0 -80000a48: 7935d76b 0x7935d76b -80000a4c: 01812683 lw a3,24(sp) -80000a50: 00f6d463 bge a3,a5,80000a58 -80000a54: 00068793 mv a5,a3 -80000a58: 015787b3 add a5,a5,s5 -80000a5c: 7935d7eb 0x7935d7eb -80000a60: 00e92023 sw a4,0(s2) -80000a64: f3dff06f j 800009a0 -80000a68: 00098613 mv a2,s3 -80000a6c: 00040513 mv a0,s0 -80000a70: ea4ff0ef jal ra,80000114 -80000a74: 00100313 li t1,1 -80000a78: 00500893 li a7,5 -80000a7c: 00300813 li a6,3 -80000a80: f1dff06f j 8000099c -80000a84: 1e6f8663 beq t6,t1,80000c70 -80000a88: fff5c693 not a3,a1 -80000a8c: 41f6d693 srai a3,a3,0x1f -80000a90: 00d5f5b3 and a1,a1,a3 -80000a94: 0155c463 blt a1,s5,80000a9c -80000a98: fffa8593 addi a1,s5,-1 -80000a9c: 000d0693 mv a3,s10 -80000aa0: 40fd87b3 sub a5,s11,a5 -80000aa4: 40f6d7b3 sra a5,a3,a5 -80000aa8: 40cd86b3 sub a3,s11,a2 -80000aac: 00c797b3 sll a5,a5,a2 -80000ab0: 40d5d5b3 sra a1,a1,a3 -80000ab4: 00b787b3 add a5,a5,a1 -80000ab8: 00279793 slli a5,a5,0x2 -80000abc: 00f507b3 add a5,a0,a5 -80000ac0: 0007a503 lw a0,0(a5) -80000ac4: 21970063 beq a4,s9,80000cc4 -80000ac8: 14ecee63 bltu s9,a4,80000c24 -80000acc: ed0718e3 bne a4,a6,8000099c -80000ad0: 00851793 slli a5,a0,0x8 -80000ad4: 00a7e533 or a0,a5,a0 -80000ad8: 01757533 and a0,a0,s7 -80000adc: eb1ff06f j 8000098c -80000ae0: 1a071263 bnez a4,80000c84 -80000ae4: 017ff5b3 and a1,t6,s7 -80000ae8: 0177fe33 and t3,a5,s7 -80000aec: 40be0e33 sub t3,t3,a1 -80000af0: 025e0e33 mul t3,t3,t0 -80000af4: 408fdf93 srai t6,t6,0x8 -80000af8: 4087d793 srai a5,a5,0x8 -80000afc: 0176f533 and a0,a3,s7 -80000b00: 40865f13 srai t5,a2,0x8 -80000b04: 017fffb3 and t6,t6,s7 -80000b08: 0177f7b3 and a5,a5,s7 -80000b0c: 01767633 and a2,a2,s7 -80000b10: 40a60633 sub a2,a2,a0 -80000b14: 41f78eb3 sub t4,a5,t6 -80000b18: 03c12623 sw t3,44(sp) -80000b1c: 02c12783 lw a5,44(sp) -80000b20: 02560e33 mul t3,a2,t0 -80000b24: 4086d693 srai a3,a3,0x8 -80000b28: 0176f6b3 and a3,a3,s7 -80000b2c: 017f7f33 and t5,t5,s7 -80000b30: 40df0f33 sub t5,t5,a3 -80000b34: 4087d793 srai a5,a5,0x8 -80000b38: 00b787b3 add a5,a5,a1 -80000b3c: 0177f633 and a2,a5,s7 -80000b40: 025e85b3 mul a1,t4,t0 -80000b44: 408e5793 srai a5,t3,0x8 -80000b48: 00a787b3 add a5,a5,a0 -80000b4c: 0177f7b3 and a5,a5,s7 -80000b50: 40c78533 sub a0,a5,a2 -80000b54: 025f02b3 mul t0,t5,t0 -80000b58: 4085d793 srai a5,a1,0x8 -80000b5c: 01f78fb3 add t6,a5,t6 -80000b60: 017fffb3 and t6,t6,s7 -80000b64: 4082d293 srai t0,t0,0x8 -80000b68: 00d286b3 add a3,t0,a3 -80000b6c: 0176f6b3 and a3,a3,s7 -80000b70: 02750533 mul a0,a0,t2 -80000b74: 41f687b3 sub a5,a3,t6 -80000b78: 027783b3 mul t2,a5,t2 -80000b7c: 40855513 srai a0,a0,0x8 -80000b80: 00c50533 add a0,a0,a2 -80000b84: 01757533 and a0,a0,s7 -80000b88: 4083d393 srai t2,t2,0x8 -80000b8c: 01f38fb3 add t6,t2,t6 -80000b90: deecfce3 bgeu s9,a4,80000988 -80000b94: 07170e63 beq a4,a7,80000c10 -80000b98: 0a80006f j 80000c40 -80000b9c: f51714e3 bne a4,a7,80000ae4 -80000ba0: 00c79593 slli a1,a5,0xc -80000ba4: 00f5e7b3 or a5,a1,a5 -80000ba8: 02812583 lw a1,40(sp) -80000bac: 00c69513 slli a0,a3,0xc -80000bb0: 00cf9713 slli a4,t6,0xc -80000bb4: 00c61e13 slli t3,a2,0xc -80000bb8: 00d566b3 or a3,a0,a3 -80000bbc: 01f76733 or a4,a4,t6 -80000bc0: 00ce6633 or a2,t3,a2 -80000bc4: 00b77733 and a4,a4,a1 -80000bc8: 00b6f6b3 and a3,a3,a1 -80000bcc: 00b7f7b3 and a5,a5,a1 -80000bd0: 00b67633 and a2,a2,a1 -80000bd4: 40e787b3 sub a5,a5,a4 -80000bd8: 40d60633 sub a2,a2,a3 -80000bdc: 025787b3 mul a5,a5,t0 -80000be0: 025602b3 mul t0,a2,t0 -80000be4: 4087d793 srai a5,a5,0x8 -80000be8: 00e787b3 add a5,a5,a4 -80000bec: 0177f7b3 and a5,a5,s7 -80000bf0: 4082d293 srai t0,t0,0x8 -80000bf4: 00d28733 add a4,t0,a3 -80000bf8: 01777733 and a4,a4,s7 -80000bfc: 40f70733 sub a4,a4,a5 -80000c00: 027703b3 mul t2,a4,t2 -80000c04: 4083d393 srai t2,t2,0x8 -80000c08: 00f387b3 add a5,t2,a5 -80000c0c: 0177f533 and a0,a5,s7 -80000c10: 40c55793 srai a5,a0,0xc -80000c14: 00a7e533 or a0,a5,a0 -80000c18: 01412783 lw a5,20(sp) -80000c1c: 00f57533 and a0,a0,a5 -80000c20: d7dff06f j 8000099c -80000c24: d7171ce3 bne a4,a7,8000099c -80000c28: 00c51793 slli a5,a0,0xc -80000c2c: 00a7e533 or a0,a5,a0 -80000c30: 02812783 lw a5,40(sp) -80000c34: 00f57533 and a0,a0,a5 -80000c38: fd9ff06f j 80000c10 -80000c3c: d60710e3 bnez a4,8000099c -80000c40: 02012783 lw a5,32(sp) -80000c44: 008f9f93 slli t6,t6,0x8 -80000c48: 00ffffb3 and t6,t6,a5 -80000c4c: 01f56533 or a0,a0,t6 -80000c50: d4dff06f j 8000099c -80000c54: 00100e37 lui t3,0x100 -80000c58: fffe0e93 addi t4,t3,-1 # fffff <__stack_size+0xffbff> -80000c5c: 01d2f2b3 and t0,t0,t4 -80000c60: 01d3f3b3 and t2,t2,t4 -80000c64: 01d5f5b3 and a1,a1,t4 -80000c68: 01d6f6b3 and a3,a3,t4 -80000c6c: c35ff06f j 800008a0 -80000c70: 001006b7 lui a3,0x100 -80000c74: fff68693 addi a3,a3,-1 # fffff <__stack_size+0xffbff> -80000c78: 00d5f5b3 and a1,a1,a3 -80000c7c: 01c12683 lw a3,28(sp) -80000c80: e21ff06f j 80000aa0 -80000c84: 41f787b3 sub a5,a5,t6 -80000c88: 40d60633 sub a2,a2,a3 -80000c8c: 025787b3 mul a5,a5,t0 -80000c90: 025602b3 mul t0,a2,t0 -80000c94: 4087d793 srai a5,a5,0x8 -80000c98: 01f787b3 add a5,a5,t6 -80000c9c: 0177f7b3 and a5,a5,s7 -80000ca0: 4082d293 srai t0,t0,0x8 -80000ca4: 00d28733 add a4,t0,a3 -80000ca8: 01777733 and a4,a4,s7 -80000cac: 40f70733 sub a4,a4,a5 -80000cb0: 027703b3 mul t2,a4,t2 -80000cb4: 4083d393 srai t2,t2,0x8 -80000cb8: 00f387b3 add a5,t2,a5 -80000cbc: 0177f533 and a0,a5,s7 -80000cc0: cddff06f j 8000099c -80000cc4: 01051793 slli a5,a0,0x10 -80000cc8: 00a7e533 or a0,a5,a0 -80000ccc: 02412783 lw a5,36(sp) -80000cd0: 00f57533 and a0,a0,a5 -80000cd4: 41055793 srai a5,a0,0x10 -80000cd8: 00a7e533 or a0,a5,a0 -80000cdc: 01412783 lw a5,20(sp) -80000ce0: 00f57533 and a0,a0,a5 -80000ce4: cb9ff06f j 8000099c -80000ce8: 01079593 slli a1,a5,0x10 -80000cec: 00f5e7b3 or a5,a1,a5 -80000cf0: 02412583 lw a1,36(sp) -80000cf4: 01069513 slli a0,a3,0x10 -80000cf8: 010f9713 slli a4,t6,0x10 -80000cfc: 01061e13 slli t3,a2,0x10 -80000d00: 00d566b3 or a3,a0,a3 -80000d04: 01f76733 or a4,a4,t6 -80000d08: 00ce6633 or a2,t3,a2 -80000d0c: 00b77733 and a4,a4,a1 -80000d10: 00b6f6b3 and a3,a3,a1 -80000d14: 00b7f7b3 and a5,a5,a1 -80000d18: 00b67633 and a2,a2,a1 -80000d1c: 40e787b3 sub a5,a5,a4 -80000d20: 40d60633 sub a2,a2,a3 -80000d24: 025787b3 mul a5,a5,t0 -80000d28: 025602b3 mul t0,a2,t0 -80000d2c: 4087d793 srai a5,a5,0x8 -80000d30: 00e787b3 add a5,a5,a4 -80000d34: 0177f7b3 and a5,a5,s7 -80000d38: 4082d293 srai t0,t0,0x8 -80000d3c: 00d28733 add a4,t0,a3 -80000d40: 01777733 and a4,a4,s7 -80000d44: 40f70733 sub a4,a4,a5 -80000d48: 027703b3 mul t2,a4,t2 -80000d4c: 4083d393 srai t2,t2,0x8 -80000d50: 00f387b3 add a5,t2,a5 -80000d54: 0177f7b3 and a5,a5,s7 -80000d58: 4107d513 srai a0,a5,0x10 -80000d5c: 00f56533 or a0,a0,a5 -80000d60: 01412783 lw a5,20(sp) -80000d64: 00f57533 and a0,a0,a5 -80000d68: c35ff06f j 8000099c - -80000d6c <_exit>: -80000d6c: 00050663 beqz a0,80000d78 -80000d70: 00050193 mv gp,a0 -80000d74: 00000073 ecall - -80000d78 : -80000d78: 348000ef jal ra,800010c0 -80000d7c: 00000513 li a0,0 -80000d80: 0005006b 0x5006b - -80000d84 : -80000d84: fc002573 csrr a0,0xfc0 -80000d88: 0005006b 0x5006b -80000d8c: 00002197 auipc gp,0x2 -80000d90: 03418193 addi gp,gp,52 # 80002dc0 <__global_pointer> -80000d94: 7efff117 auipc sp,0x7efff -80000d98: 26c10113 addi sp,sp,620 # ff000000 <__stack_top> -80000d9c: 40000593 li a1,1024 -80000da0: cc102673 csrr a2,0xcc1 -80000da4: 02c585b3 mul a1,a1,a2 -80000da8: 40b10133 sub sp,sp,a1 -80000dac: cc3026f3 csrr a3,0xcc3 -80000db0: 00068663 beqz a3,80000dbc -80000db4: 00000513 li a0,0 -80000db8: 0005006b 0x5006b - -80000dbc : -80000dbc: 00008067 ret - -80000dc0 <__libc_init_array>: -80000dc0: ff010113 addi sp,sp,-16 -80000dc4: 00812423 sw s0,8(sp) -80000dc8: 01212023 sw s2,0(sp) -80000dcc: 80002437 lui s0,0x80002 -80000dd0: 80002937 lui s2,0x80002 -80000dd4: 5b840793 addi a5,s0,1464 # 800025b8 <__stack_top+0x810025b8> -80000dd8: 5b890913 addi s2,s2,1464 # 800025b8 <__stack_top+0x810025b8> -80000ddc: 40f90933 sub s2,s2,a5 -80000de0: 00112623 sw ra,12(sp) -80000de4: 00912223 sw s1,4(sp) -80000de8: 40295913 srai s2,s2,0x2 -80000dec: 02090063 beqz s2,80000e0c <__libc_init_array+0x4c> -80000df0: 5b840413 addi s0,s0,1464 -80000df4: 00000493 li s1,0 -80000df8: 00042783 lw a5,0(s0) -80000dfc: 00148493 addi s1,s1,1 -80000e00: 00440413 addi s0,s0,4 -80000e04: 000780e7 jalr a5 -80000e08: fe9918e3 bne s2,s1,80000df8 <__libc_init_array+0x38> -80000e0c: 80002437 lui s0,0x80002 -80000e10: 80002937 lui s2,0x80002 -80000e14: 5b840793 addi a5,s0,1464 # 800025b8 <__stack_top+0x810025b8> -80000e18: 5bc90913 addi s2,s2,1468 # 800025bc <__stack_top+0x810025bc> -80000e1c: 40f90933 sub s2,s2,a5 -80000e20: 40295913 srai s2,s2,0x2 -80000e24: 02090063 beqz s2,80000e44 <__libc_init_array+0x84> -80000e28: 5b840413 addi s0,s0,1464 -80000e2c: 00000493 li s1,0 -80000e30: 00042783 lw a5,0(s0) -80000e34: 00148493 addi s1,s1,1 -80000e38: 00440413 addi s0,s0,4 -80000e3c: 000780e7 jalr a5 -80000e40: fe9918e3 bne s2,s1,80000e30 <__libc_init_array+0x70> -80000e44: 00c12083 lw ra,12(sp) -80000e48: 00812403 lw s0,8(sp) -80000e4c: 00412483 lw s1,4(sp) -80000e50: 00012903 lw s2,0(sp) -80000e54: 01010113 addi sp,sp,16 -80000e58: 00008067 ret - -80000e5c <__libc_fini_array>: -80000e5c: ff010113 addi sp,sp,-16 -80000e60: 00812423 sw s0,8(sp) -80000e64: 800027b7 lui a5,0x80002 -80000e68: 80002437 lui s0,0x80002 -80000e6c: 5bc40413 addi s0,s0,1468 # 800025bc <__stack_top+0x810025bc> -80000e70: 5bc78793 addi a5,a5,1468 # 800025bc <__stack_top+0x810025bc> -80000e74: 408787b3 sub a5,a5,s0 -80000e78: 00912223 sw s1,4(sp) -80000e7c: 00112623 sw ra,12(sp) -80000e80: 4027d493 srai s1,a5,0x2 -80000e84: 02048063 beqz s1,80000ea4 <__libc_fini_array+0x48> -80000e88: ffc78793 addi a5,a5,-4 -80000e8c: 00878433 add s0,a5,s0 -80000e90: 00042783 lw a5,0(s0) -80000e94: fff48493 addi s1,s1,-1 -80000e98: ffc40413 addi s0,s0,-4 -80000e9c: 000780e7 jalr a5 -80000ea0: fe0498e3 bnez s1,80000e90 <__libc_fini_array+0x34> -80000ea4: 00c12083 lw ra,12(sp) -80000ea8: 00812403 lw s0,8(sp) -80000eac: 00412483 lw s1,4(sp) -80000eb0: 01010113 addi sp,sp,16 -80000eb4: 00008067 ret - -80000eb8 : -80000eb8: fe010113 addi sp,sp,-32 -80000ebc: 00112e23 sw ra,28(sp) -80000ec0: 00812c23 sw s0,24(sp) -80000ec4: 00912a23 sw s1,20(sp) -80000ec8: 01212823 sw s2,16(sp) -80000ecc: 01312623 sw s3,12(sp) -80000ed0: fc0027f3 csrr a5,0xfc0 -80000ed4: 0007806b 0x7806b -80000ed8: cc5027f3 csrr a5,0xcc5 -80000edc: cc3029f3 csrr s3,0xcc3 -80000ee0: cc002773 csrr a4,0xcc0 -80000ee4: fc002673 csrr a2,0xfc0 -80000ee8: 00279693 slli a3,a5,0x2 -80000eec: 800037b7 lui a5,0x80003 -80000ef0: 9f478793 addi a5,a5,-1548 # 800029f4 <__stack_top+0x810029f4> -80000ef4: 00d787b3 add a5,a5,a3 -80000ef8: 0007a483 lw s1,0(a5) -80000efc: 0104a403 lw s0,16(s1) -80000f00: 00c4a683 lw a3,12(s1) -80000f04: 0089a933 slt s2,s3,s0 -80000f08: 00040793 mv a5,s0 -80000f0c: 00d90933 add s2,s2,a3 -80000f10: 03368433 mul s0,a3,s3 -80000f14: 00f9d463 bge s3,a5,80000f1c -80000f18: 00098793 mv a5,s3 -80000f1c: 00f40433 add s0,s0,a5 -80000f20: 0084a683 lw a3,8(s1) -80000f24: 02c40433 mul s0,s0,a2 -80000f28: 02e907b3 mul a5,s2,a4 -80000f2c: 00d40433 add s0,s0,a3 -80000f30: 00f40433 add s0,s0,a5 -80000f34: 00890933 add s2,s2,s0 -80000f38: 01245e63 bge s0,s2,80000f54 -80000f3c: 0004a783 lw a5,0(s1) -80000f40: 0044a583 lw a1,4(s1) -80000f44: 00040513 mv a0,s0 -80000f48: 00140413 addi s0,s0,1 -80000f4c: 000780e7 jalr a5 -80000f50: fe8916e3 bne s2,s0,80000f3c -80000f54: 0019b993 seqz s3,s3 -80000f58: 0009806b 0x9806b -80000f5c: 01c12083 lw ra,28(sp) -80000f60: 01812403 lw s0,24(sp) -80000f64: 01412483 lw s1,20(sp) -80000f68: 01012903 lw s2,16(sp) -80000f6c: 00c12983 lw s3,12(sp) -80000f70: 02010113 addi sp,sp,32 -80000f74: 00008067 ret - -80000f78 : -80000f78: fc010113 addi sp,sp,-64 -80000f7c: 02112e23 sw ra,60(sp) -80000f80: 02812c23 sw s0,56(sp) -80000f84: 02912a23 sw s1,52(sp) -80000f88: 03212823 sw s2,48(sp) -80000f8c: 03312623 sw s3,44(sp) -80000f90: fc2026f3 csrr a3,0xfc2 -80000f94: fc102873 csrr a6,0xfc1 -80000f98: fc002473 csrr s0,0xfc0 -80000f9c: cc5027f3 csrr a5,0xcc5 -80000fa0: 01f00713 li a4,31 -80000fa4: 0cf74463 blt a4,a5,8000106c -80000fa8: 030408b3 mul a7,s0,a6 -80000fac: 00100713 li a4,1 -80000fb0: 00a8d463 bge a7,a0,80000fb8 -80000fb4: 03154733 div a4,a0,a7 -80000fb8: 0ce6c863 blt a3,a4,80001088 -80000fbc: 0ae7d863 bge a5,a4,8000106c -80000fc0: fff68693 addi a3,a3,-1 -80000fc4: 02e54333 div t1,a0,a4 -80000fc8: 00030893 mv a7,t1 -80000fcc: 00f69663 bne a3,a5,80000fd8 -80000fd0: 02e56533 rem a0,a0,a4 -80000fd4: 006508b3 add a7,a0,t1 -80000fd8: 0288c4b3 div s1,a7,s0 -80000fdc: 0288e933 rem s2,a7,s0 -80000fe0: 0b04ca63 blt s1,a6,80001094 -80000fe4: 00100693 li a3,1 -80000fe8: 0304c733 div a4,s1,a6 -80000fec: 00070663 beqz a4,80000ff8 -80000ff0: 00070693 mv a3,a4 -80000ff4: 0304e733 rem a4,s1,a6 -80000ff8: 800039b7 lui s3,0x80003 -80000ffc: 9f498993 addi s3,s3,-1548 # 800029f4 <__stack_top+0x810029f4> -80001000: 00e12e23 sw a4,28(sp) -80001004: 00c10713 addi a4,sp,12 -80001008: 00b12623 sw a1,12(sp) -8000100c: 00c12823 sw a2,16(sp) -80001010: 00d12c23 sw a3,24(sp) -80001014: 02f30333 mul t1,t1,a5 -80001018: 00279793 slli a5,a5,0x2 -8000101c: 00f987b3 add a5,s3,a5 -80001020: 00e7a023 sw a4,0(a5) -80001024: 00612a23 sw t1,20(sp) -80001028: 06904c63 bgtz s1,800010a0 -8000102c: 04090063 beqz s2,8000106c -80001030: 02848433 mul s0,s1,s0 -80001034: 00812a23 sw s0,20(sp) -80001038: 0009006b 0x9006b -8000103c: cc5027f3 csrr a5,0xcc5 -80001040: cc202573 csrr a0,0xcc2 -80001044: 00279793 slli a5,a5,0x2 -80001048: 00f989b3 add s3,s3,a5 -8000104c: 0009a783 lw a5,0(s3) -80001050: 0087a683 lw a3,8(a5) -80001054: 0007a703 lw a4,0(a5) -80001058: 0047a583 lw a1,4(a5) -8000105c: 00d50533 add a0,a0,a3 -80001060: 000700e7 jalr a4 -80001064: 00100793 li a5,1 -80001068: 0007806b 0x7806b -8000106c: 03c12083 lw ra,60(sp) -80001070: 03812403 lw s0,56(sp) -80001074: 03412483 lw s1,52(sp) -80001078: 03012903 lw s2,48(sp) -8000107c: 02c12983 lw s3,44(sp) -80001080: 04010113 addi sp,sp,64 -80001084: 00008067 ret -80001088: 00068713 mv a4,a3 -8000108c: f2e7cae3 blt a5,a4,80000fc0 -80001090: fddff06f j 8000106c -80001094: 00000713 li a4,0 -80001098: 00100693 li a3,1 -8000109c: f5dff06f j 80000ff8 -800010a0: 00048713 mv a4,s1 -800010a4: 00985463 bge a6,s1,800010ac -800010a8: 00080713 mv a4,a6 -800010ac: 800017b7 lui a5,0x80001 -800010b0: eb878793 addi a5,a5,-328 # 80000eb8 <__stack_top+0x81000eb8> -800010b4: 00f7106b 0xf7106b -800010b8: e01ff0ef jal ra,80000eb8 -800010bc: f71ff06f j 8000102c - -800010c0 : -800010c0: cc5027f3 csrr a5,0xcc5 -800010c4: 00ff0737 lui a4,0xff0 -800010c8: 00e787b3 add a5,a5,a4 -800010cc: 00879793 slli a5,a5,0x8 -800010d0: b0002773 csrr a4,mcycle -800010d4: 00e7a023 sw a4,0(a5) -800010d8: b0102773 csrr a4,0xb01 -800010dc: 00e7a223 sw a4,4(a5) -800010e0: b0202773 csrr a4,minstret -800010e4: 00e7a423 sw a4,8(a5) -800010e8: b0302773 csrr a4,mhpmcounter3 -800010ec: 00e7a623 sw a4,12(a5) -800010f0: b0402773 csrr a4,mhpmcounter4 -800010f4: 00e7a823 sw a4,16(a5) -800010f8: b0502773 csrr a4,mhpmcounter5 -800010fc: 00e7aa23 sw a4,20(a5) -80001100: b0602773 csrr a4,mhpmcounter6 -80001104: 00e7ac23 sw a4,24(a5) -80001108: b0702773 csrr a4,mhpmcounter7 -8000110c: 00e7ae23 sw a4,28(a5) -80001110: b0802773 csrr a4,mhpmcounter8 -80001114: 02e7a023 sw a4,32(a5) -80001118: b0902773 csrr a4,mhpmcounter9 -8000111c: 02e7a223 sw a4,36(a5) -80001120: b0a02773 csrr a4,mhpmcounter10 -80001124: 02e7a423 sw a4,40(a5) -80001128: b0b02773 csrr a4,mhpmcounter11 -8000112c: 02e7a623 sw a4,44(a5) -80001130: b0c02773 csrr a4,mhpmcounter12 -80001134: 02e7a823 sw a4,48(a5) -80001138: b0d02773 csrr a4,mhpmcounter13 -8000113c: 02e7aa23 sw a4,52(a5) -80001140: b0e02773 csrr a4,mhpmcounter14 -80001144: 02e7ac23 sw a4,56(a5) -80001148: b0f02773 csrr a4,mhpmcounter15 -8000114c: 02e7ae23 sw a4,60(a5) -80001150: b1002773 csrr a4,mhpmcounter16 -80001154: 04e7a023 sw a4,64(a5) -80001158: b1102773 csrr a4,mhpmcounter17 -8000115c: 04e7a223 sw a4,68(a5) -80001160: b1202773 csrr a4,mhpmcounter18 -80001164: 04e7a423 sw a4,72(a5) -80001168: b1302773 csrr a4,mhpmcounter19 -8000116c: 04e7a623 sw a4,76(a5) -80001170: b1402773 csrr a4,mhpmcounter20 -80001174: 04e7a823 sw a4,80(a5) -80001178: b1502773 csrr a4,mhpmcounter21 -8000117c: 04e7aa23 sw a4,84(a5) -80001180: b1602773 csrr a4,mhpmcounter22 -80001184: 04e7ac23 sw a4,88(a5) -80001188: b1702773 csrr a4,mhpmcounter23 -8000118c: 04e7ae23 sw a4,92(a5) -80001190: b1802773 csrr a4,mhpmcounter24 -80001194: 06e7a023 sw a4,96(a5) -80001198: b1902773 csrr a4,mhpmcounter25 -8000119c: 06e7a223 sw a4,100(a5) -800011a0: b1a02773 csrr a4,mhpmcounter26 -800011a4: 06e7a423 sw a4,104(a5) -800011a8: b1b02773 csrr a4,mhpmcounter27 -800011ac: 06e7a623 sw a4,108(a5) -800011b0: b1c02773 csrr a4,mhpmcounter28 -800011b4: 06e7a823 sw a4,112(a5) -800011b8: b1d02773 csrr a4,mhpmcounter29 -800011bc: 06e7aa23 sw a4,116(a5) -800011c0: b1e02773 csrr a4,mhpmcounter30 -800011c4: 06e7ac23 sw a4,120(a5) -800011c8: b1f02773 csrr a4,mhpmcounter31 -800011cc: 06e7ae23 sw a4,124(a5) -800011d0: b8002773 csrr a4,mcycleh -800011d4: 08e7a023 sw a4,128(a5) -800011d8: b8102773 csrr a4,0xb81 -800011dc: 08e7a223 sw a4,132(a5) -800011e0: b8202773 csrr a4,minstreth -800011e4: 08e7a423 sw a4,136(a5) -800011e8: b8302773 csrr a4,mhpmcounter3h -800011ec: 08e7a623 sw a4,140(a5) -800011f0: b8402773 csrr a4,mhpmcounter4h -800011f4: 08e7a823 sw a4,144(a5) -800011f8: b8502773 csrr a4,mhpmcounter5h -800011fc: 08e7aa23 sw a4,148(a5) -80001200: b8602773 csrr a4,mhpmcounter6h -80001204: 08e7ac23 sw a4,152(a5) -80001208: b8702773 csrr a4,mhpmcounter7h -8000120c: 08e7ae23 sw a4,156(a5) -80001210: b8802773 csrr a4,mhpmcounter8h -80001214: 0ae7a023 sw a4,160(a5) -80001218: b8902773 csrr a4,mhpmcounter9h -8000121c: 0ae7a223 sw a4,164(a5) -80001220: b8a02773 csrr a4,mhpmcounter10h -80001224: 0ae7a423 sw a4,168(a5) -80001228: b8b02773 csrr a4,mhpmcounter11h -8000122c: 0ae7a623 sw a4,172(a5) -80001230: b8c02773 csrr a4,mhpmcounter12h -80001234: 0ae7a823 sw a4,176(a5) -80001238: b8d02773 csrr a4,mhpmcounter13h -8000123c: 0ae7aa23 sw a4,180(a5) -80001240: b8e02773 csrr a4,mhpmcounter14h -80001244: 0ae7ac23 sw a4,184(a5) -80001248: b8f02773 csrr a4,mhpmcounter15h -8000124c: 0ae7ae23 sw a4,188(a5) -80001250: b9002773 csrr a4,mhpmcounter16h -80001254: 0ce7a023 sw a4,192(a5) -80001258: b9102773 csrr a4,mhpmcounter17h -8000125c: 0ce7a223 sw a4,196(a5) -80001260: b9202773 csrr a4,mhpmcounter18h -80001264: 0ce7a423 sw a4,200(a5) -80001268: b9302773 csrr a4,mhpmcounter19h -8000126c: 0ce7a623 sw a4,204(a5) -80001270: b9402773 csrr a4,mhpmcounter20h -80001274: 0ce7a823 sw a4,208(a5) -80001278: b9502773 csrr a4,mhpmcounter21h -8000127c: 0ce7aa23 sw a4,212(a5) -80001280: b9602773 csrr a4,mhpmcounter22h -80001284: 0ce7ac23 sw a4,216(a5) -80001288: b9702773 csrr a4,mhpmcounter23h -8000128c: 0ce7ae23 sw a4,220(a5) -80001290: b9802773 csrr a4,mhpmcounter24h -80001294: 0ee7a023 sw a4,224(a5) -80001298: b9902773 csrr a4,mhpmcounter25h -8000129c: 0ee7a223 sw a4,228(a5) -800012a0: b9a02773 csrr a4,mhpmcounter26h -800012a4: 0ee7a423 sw a4,232(a5) -800012a8: b9b02773 csrr a4,mhpmcounter27h -800012ac: 0ee7a623 sw a4,236(a5) -800012b0: b9c02773 csrr a4,mhpmcounter28h -800012b4: 0ee7a823 sw a4,240(a5) -800012b8: b9d02773 csrr a4,mhpmcounter29h -800012bc: 0ee7aa23 sw a4,244(a5) -800012c0: b9e02773 csrr a4,mhpmcounter30h -800012c4: 0ee7ac23 sw a4,248(a5) -800012c8: b9f02773 csrr a4,mhpmcounter31h -800012cc: 0ee7ae23 sw a4,252(a5) -800012d0: 00008067 ret - -800012d4 : -800012d4: 00050593 mv a1,a0 -800012d8: 00000693 li a3,0 -800012dc: 00000613 li a2,0 -800012e0: 00000513 li a0,0 -800012e4: 1140006f j 800013f8 <__register_exitproc> - -800012e8 : -800012e8: ff010113 addi sp,sp,-16 -800012ec: 00000593 li a1,0 -800012f0: 00812423 sw s0,8(sp) -800012f4: 00112623 sw ra,12(sp) -800012f8: 00050413 mv s0,a0 -800012fc: 198000ef jal ra,80001494 <__call_exitprocs> -80001300: 800037b7 lui a5,0x80003 -80001304: 9f07a503 lw a0,-1552(a5) # 800029f0 <__stack_top+0x810029f0> -80001308: 03c52783 lw a5,60(a0) -8000130c: 00078463 beqz a5,80001314 -80001310: 000780e7 jalr a5 -80001314: 00040513 mv a0,s0 -80001318: a55ff0ef jal ra,80000d6c <_exit> - -8000131c : -8000131c: 00f00313 li t1,15 -80001320: 00050713 mv a4,a0 -80001324: 02c37e63 bgeu t1,a2,80001360 -80001328: 00f77793 andi a5,a4,15 -8000132c: 0a079063 bnez a5,800013cc -80001330: 08059263 bnez a1,800013b4 -80001334: ff067693 andi a3,a2,-16 -80001338: 00f67613 andi a2,a2,15 -8000133c: 00e686b3 add a3,a3,a4 -80001340: 00b72023 sw a1,0(a4) # ff0000 <__stack_size+0xfefc00> -80001344: 00b72223 sw a1,4(a4) -80001348: 00b72423 sw a1,8(a4) -8000134c: 00b72623 sw a1,12(a4) -80001350: 01070713 addi a4,a4,16 -80001354: fed766e3 bltu a4,a3,80001340 -80001358: 00061463 bnez a2,80001360 -8000135c: 00008067 ret -80001360: 40c306b3 sub a3,t1,a2 -80001364: 00269693 slli a3,a3,0x2 -80001368: 00000297 auipc t0,0x0 -8000136c: 005686b3 add a3,a3,t0 -80001370: 00c68067 jr 12(a3) -80001374: 00b70723 sb a1,14(a4) -80001378: 00b706a3 sb a1,13(a4) -8000137c: 00b70623 sb a1,12(a4) -80001380: 00b705a3 sb a1,11(a4) -80001384: 00b70523 sb a1,10(a4) -80001388: 00b704a3 sb a1,9(a4) -8000138c: 00b70423 sb a1,8(a4) -80001390: 00b703a3 sb a1,7(a4) -80001394: 00b70323 sb a1,6(a4) -80001398: 00b702a3 sb a1,5(a4) -8000139c: 00b70223 sb a1,4(a4) -800013a0: 00b701a3 sb a1,3(a4) -800013a4: 00b70123 sb a1,2(a4) -800013a8: 00b700a3 sb a1,1(a4) -800013ac: 00b70023 sb a1,0(a4) -800013b0: 00008067 ret -800013b4: 0ff5f593 andi a1,a1,255 -800013b8: 00859693 slli a3,a1,0x8 -800013bc: 00d5e5b3 or a1,a1,a3 -800013c0: 01059693 slli a3,a1,0x10 -800013c4: 00d5e5b3 or a1,a1,a3 -800013c8: f6dff06f j 80001334 -800013cc: 00279693 slli a3,a5,0x2 -800013d0: 00000297 auipc t0,0x0 -800013d4: 005686b3 add a3,a3,t0 -800013d8: 00008293 mv t0,ra -800013dc: fa0680e7 jalr -96(a3) -800013e0: 00028093 mv ra,t0 -800013e4: ff078793 addi a5,a5,-16 -800013e8: 40f70733 sub a4,a4,a5 -800013ec: 00f60633 add a2,a2,a5 -800013f0: f6c378e3 bgeu t1,a2,80001360 -800013f4: f3dff06f j 80001330 - -800013f8 <__register_exitproc>: -800013f8: 800037b7 lui a5,0x80003 -800013fc: 9f07a703 lw a4,-1552(a5) # 800029f0 <__stack_top+0x810029f0> -80001400: 14872783 lw a5,328(a4) -80001404: 04078c63 beqz a5,8000145c <__register_exitproc+0x64> -80001408: 0047a703 lw a4,4(a5) -8000140c: 01f00813 li a6,31 -80001410: 06e84e63 blt a6,a4,8000148c <__register_exitproc+0x94> -80001414: 00271813 slli a6,a4,0x2 -80001418: 02050663 beqz a0,80001444 <__register_exitproc+0x4c> -8000141c: 01078333 add t1,a5,a6 -80001420: 08c32423 sw a2,136(t1) -80001424: 1887a883 lw a7,392(a5) -80001428: 00100613 li a2,1 -8000142c: 00e61633 sll a2,a2,a4 -80001430: 00c8e8b3 or a7,a7,a2 -80001434: 1917a423 sw a7,392(a5) -80001438: 10d32423 sw a3,264(t1) -8000143c: 00200693 li a3,2 -80001440: 02d50463 beq a0,a3,80001468 <__register_exitproc+0x70> -80001444: 00170713 addi a4,a4,1 -80001448: 00e7a223 sw a4,4(a5) -8000144c: 010787b3 add a5,a5,a6 -80001450: 00b7a423 sw a1,8(a5) -80001454: 00000513 li a0,0 -80001458: 00008067 ret -8000145c: 14c70793 addi a5,a4,332 -80001460: 14f72423 sw a5,328(a4) -80001464: fa5ff06f j 80001408 <__register_exitproc+0x10> -80001468: 18c7a683 lw a3,396(a5) -8000146c: 00170713 addi a4,a4,1 -80001470: 00e7a223 sw a4,4(a5) -80001474: 00c6e633 or a2,a3,a2 -80001478: 18c7a623 sw a2,396(a5) -8000147c: 010787b3 add a5,a5,a6 -80001480: 00b7a423 sw a1,8(a5) -80001484: 00000513 li a0,0 -80001488: 00008067 ret -8000148c: fff00513 li a0,-1 -80001490: 00008067 ret - -80001494 <__call_exitprocs>: -80001494: fd010113 addi sp,sp,-48 -80001498: 800037b7 lui a5,0x80003 -8000149c: 01412c23 sw s4,24(sp) -800014a0: 9f07aa03 lw s4,-1552(a5) # 800029f0 <__stack_top+0x810029f0> -800014a4: 03212023 sw s2,32(sp) -800014a8: 02112623 sw ra,44(sp) -800014ac: 148a2903 lw s2,328(s4) -800014b0: 02812423 sw s0,40(sp) -800014b4: 02912223 sw s1,36(sp) -800014b8: 01312e23 sw s3,28(sp) -800014bc: 01512a23 sw s5,20(sp) -800014c0: 01612823 sw s6,16(sp) -800014c4: 01712623 sw s7,12(sp) -800014c8: 01812423 sw s8,8(sp) -800014cc: 04090063 beqz s2,8000150c <__call_exitprocs+0x78> -800014d0: 00050b13 mv s6,a0 -800014d4: 00058b93 mv s7,a1 -800014d8: 00100a93 li s5,1 -800014dc: fff00993 li s3,-1 -800014e0: 00492483 lw s1,4(s2) -800014e4: fff48413 addi s0,s1,-1 -800014e8: 02044263 bltz s0,8000150c <__call_exitprocs+0x78> -800014ec: 00249493 slli s1,s1,0x2 -800014f0: 009904b3 add s1,s2,s1 -800014f4: 040b8463 beqz s7,8000153c <__call_exitprocs+0xa8> -800014f8: 1044a783 lw a5,260(s1) -800014fc: 05778063 beq a5,s7,8000153c <__call_exitprocs+0xa8> -80001500: fff40413 addi s0,s0,-1 -80001504: ffc48493 addi s1,s1,-4 -80001508: ff3416e3 bne s0,s3,800014f4 <__call_exitprocs+0x60> -8000150c: 02c12083 lw ra,44(sp) -80001510: 02812403 lw s0,40(sp) -80001514: 02412483 lw s1,36(sp) -80001518: 02012903 lw s2,32(sp) -8000151c: 01c12983 lw s3,28(sp) -80001520: 01812a03 lw s4,24(sp) -80001524: 01412a83 lw s5,20(sp) -80001528: 01012b03 lw s6,16(sp) -8000152c: 00c12b83 lw s7,12(sp) -80001530: 00812c03 lw s8,8(sp) -80001534: 03010113 addi sp,sp,48 -80001538: 00008067 ret -8000153c: 00492783 lw a5,4(s2) -80001540: 0044a683 lw a3,4(s1) -80001544: fff78793 addi a5,a5,-1 -80001548: 04878e63 beq a5,s0,800015a4 <__call_exitprocs+0x110> -8000154c: 0004a223 sw zero,4(s1) -80001550: fa0688e3 beqz a3,80001500 <__call_exitprocs+0x6c> -80001554: 18892783 lw a5,392(s2) -80001558: 008a9733 sll a4,s5,s0 -8000155c: 00492c03 lw s8,4(s2) -80001560: 00f777b3 and a5,a4,a5 -80001564: 02079263 bnez a5,80001588 <__call_exitprocs+0xf4> -80001568: 000680e7 jalr a3 -8000156c: 00492703 lw a4,4(s2) -80001570: 148a2783 lw a5,328(s4) -80001574: 01871463 bne a4,s8,8000157c <__call_exitprocs+0xe8> -80001578: f92784e3 beq a5,s2,80001500 <__call_exitprocs+0x6c> -8000157c: f80788e3 beqz a5,8000150c <__call_exitprocs+0x78> -80001580: 00078913 mv s2,a5 -80001584: f5dff06f j 800014e0 <__call_exitprocs+0x4c> -80001588: 18c92783 lw a5,396(s2) -8000158c: 0844a583 lw a1,132(s1) -80001590: 00f77733 and a4,a4,a5 -80001594: 00071c63 bnez a4,800015ac <__call_exitprocs+0x118> -80001598: 000b0513 mv a0,s6 -8000159c: 000680e7 jalr a3 -800015a0: fcdff06f j 8000156c <__call_exitprocs+0xd8> -800015a4: 00892223 sw s0,4(s2) -800015a8: fa9ff06f j 80001550 <__call_exitprocs+0xbc> -800015ac: 00058513 mv a0,a1 -800015b0: 000680e7 jalr a3 -800015b4: fb9ff06f j 8000156c <__call_exitprocs+0xd8> - -Disassembly of section .init_array: - -800025b8 <__init_array_start>: -800025b8: 00fc addi a5,sp,76 -800025ba: 8000 0x8000 - -Disassembly of section .data: - -800025c0 : -800025c0: 0000 unimp -800025c2: 0000 unimp -800025c4: 28ac fld fa1,80(s1) -800025c6: 8000 0x8000 -800025c8: 2914 fld fa3,16(a0) -800025ca: 8000 0x8000 -800025cc: 297c fld fa5,208(a0) -800025ce: 8000 0x8000 - ... -80002668: 0001 nop -8000266a: 0000 unimp -8000266c: 0000 unimp -8000266e: 0000 unimp -80002670: 330e fld ft6,224(sp) -80002672: abcd j 80002c64 <__BSS_END__+0x1f0> -80002674: 1234 addi a3,sp,296 -80002676: e66d bnez a2,80002760 -80002678: deec sw a1,124(a3) -8000267a: 0005 c.nop 1 -8000267c: 0000000b 0xb - ... - -Disassembly of section .sdata: - -800029e8 <__SDATA_BEGIN__>: -800029e8: 0000 unimp -800029ea: 4980 lw s0,16(a1) -800029ec: 0000 unimp -800029ee: 3f80 fld fs0,56(a5) - -800029f0 <_global_impure_ptr>: -800029f0: 25c0 fld fs0,136(a1) -800029f2: 8000 0x8000 - -Disassembly of section .bss: - -800029f4 : - ... - -Disassembly of section .comment: - -00000000 <.comment>: - 0: 3a434347 fmsub.d ft6,ft6,ft4,ft7,rmm - 4: 2820 fld fs0,80(s0) - 6: 29554e47 fmsub.s ft8,fa0,fs5,ft5,rmm - a: 3120 fld fs0,96(a0) - c: 2e30 fld fa2,88(a2) - e: 2e32 fld ft8,264(sp) - 10: 0030 addi a2,sp,8 - -Disassembly of section .riscv.attributes: - -00000000 <.riscv.attributes>: - 0: 2941 jal 490 <__stack_size+0x90> - 2: 0000 unimp - 4: 7200 flw fs0,32(a2) - 6: 7369 lui t1,0xffffa - 8: 01007663 bgeu zero,a6,14 <__stack_usage+0x14> - c: 001f 0000 1004 0x10040000001f - 12: 7205 lui tp,0xfffe1 - 14: 3376 fld ft6,376(sp) - 16: 6932 flw fs2,12(sp) - 18: 7032 flw ft0,44(sp) - 1a: 5f30 lw a2,120(a4) - 1c: 326d jal fffff9c6 <__stack_top+0xfff9c6> - 1e: 3070 fld fa2,224(s0) - 20: 665f 7032 0030 0x307032665f - 26: 0108 addi a0,sp,128 - 28: 0b0a slli s6,s6,0x2 diff --git a/tests/regression/tex/kernel.elf b/tests/regression/tex/kernel.elf deleted file mode 100755 index 15dff9f886617156597d95e99ac34f755fbf8be2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12896 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 MAm|fm1Tana- +#include +#include +#include + +#ifndef LUPNG_USE_ZLIB +#include +#else +#include +#endif + +#include "lupng.h" + +#define PNG_NONE 0 +#define PNG_IHDR 0x01 +#define PNG_PLTE 0x02 +#define PNG_IDAT 0x04 +#define PNG_IEND 0x08 + +#define PNG_GRAYSCALE 0 +#define PNG_TRUECOLOR 2 +/* 24bpp RGB palette */ +#define PNG_PALETTED 3 +#define PNG_GRAYSCALE_ALPHA 4 +#define PNG_TRUECOLOR_ALPHA 6 + +#define PNG_FILTER_NONE 0 +#define PNG_FILTER_SUB 1 +#define PNG_FILTER_UP 2 +#define PNG_FILTER_AVERAGE 3 +#define PNG_FILTER_PAETH 4 + +#define PNG_SIG_SIZE 8 + +#define PNG_DONE 1 +#define PNG_OK 0 +#define PNG_ERROR -1 + +#define BUF_SIZE 8192 +#define MAX(x, y) (x > y ? x : y) + +#if defined(_MSC_VER) +#define LU_INLINE __inline /* MS-specific inline */ +#else +#define LU_INLINE inline /* rest of the world... */ +#endif + +#define SIZE_T_MAX_POSITIVE ( ((size_t)-1) >> 1 ) + +/******************************************************** + * CRC computation as per PNG spec + ********************************************************/ + +/* Precomputed table of CRCs of all 8-bit messages + using the polynomial from the PNG spec, 0xEDB88320L. */ +static const uint32_t crcTable[] = +{ + 0x0, 0x77073096, 0xEE0E612C, 0x990951BA, 0x76DC419, 0x706AF48F, + 0xE963A535, 0x9E6495A3, 0xEDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x9B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, + 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, + 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, + 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, + 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x1DB7106, + 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x6B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0xF00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x86D3D2D, + 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, + 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, + 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, + 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, + 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x3B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x4DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, + 0xD6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0xA00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, + 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, + 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, + 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, + 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x26D930A, 0x9C0906A9, 0xEB0E363F, + 0x72076785, 0x5005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0xCB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0xBDBDF21, 0x86D3D2D4, 0xF1D4E242, + 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, + 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, + 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, + 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D +}; + +/* Update a running CRC with the bytes buf[0..len-1]--the CRC + should be initialized to all 1's, and the transmitted value + is the 1's complement of the final running CRC (see the + crc() routine below)). */ +static uint32_t updateCrc(uint32_t crc, unsigned char *buf, + size_t len) +{ + uint32_t c = crc; + size_t n; + + for (n = 0; n < len; n++) + c = crcTable[(c ^ buf[n]) & 0xFF] ^ (c >> 8); + + return c; +} + +/* Return the CRC of the bytes buf[0..len-1]. */ +static uint32_t crc(unsigned char *buf, size_t len) +{ + return updateCrc(0xFFFFFFFFL, buf, len) ^ 0xFFFFFFFFL; +} + + + +/******************************************************** + * Helper structs + ********************************************************/ + +typedef struct +{ + uint32_t length; + uint8_t *type; + uint8_t *data; + uint32_t crc; +} PngChunk; + +typedef struct { + const LuUserContext *userCtx; + int8_t chunksFound; + + /* IHDR info */ + int32_t width; + int32_t height; + uint8_t depth; + uint8_t colorType; + uint8_t channels; + uint8_t compression; + uint8_t filter; + uint8_t interlace; + + /* PLTE info */ + uint32_t paletteItems; + uint8_t *palette; + + /* fields used for (de)compression & (de-)filtering */ + z_stream stream; + size_t scanlineBytes; + int32_t currentCol; + int32_t currentRow; + uint32_t currentElem; + size_t currentByte; + int bytesPerPixel; + uint8_t *currentScanline; + uint8_t *previousScanline; + uint8_t currentFilter; + uint8_t interlacePass; + size_t compressedBytes; + + /* used for constructing 16 bit deep pixels */ + int tmpCount; + uint8_t tmpBytes[2]; + + /* the output image */ + LuImage *img; + const LuImage *cimg; /* constant pointer version */ +} PngInfoStruct; + +/* helper macro to output warning via user context of the info struct */ +#define LUPNG_WARN_UC(uc,...) do { if ((uc)->warnProc) { (uc)->warnProc((uc)->warnProcUserPtr, __VA_ARGS__); }} while(0) +#define LUPNG_WARN(info,...) LUPNG_WARN_UC((info)->userCtx, __VA_ARGS__) + +/* PNG header: */ +static const uint8_t PNG_SIG[] = +/* P N G \r \n SUB \n */ +{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; + +static const int startingRow[] = { 0, 0, 0, 4, 0, 2, 0, 1 }; +static const int startingCol[] = { 0, 0, 4, 0, 2, 0, 1, 0 }; +static const int rowIncrement[] = { 1, 8, 8, 8, 4, 4, 2, 2 }; +static const int colIncrement[] = { 1, 8, 8, 4, 4, 2, 2, 1 }; + + + +/******************************************************** + * Helper functions + ********************************************************/ + +static LU_INLINE void releaseChunk(PngChunk *chunk, const LuUserContext *userCtx) +{ + /* Only release chunk->type since chunk->data points to the same memory. */ + userCtx->freeProc(chunk->type, userCtx->freeProcUserPtr); + userCtx->freeProc(chunk, userCtx->freeProcUserPtr); +} + +static LU_INLINE uint32_t swap32(uint32_t n) +{ + union { + unsigned char np[4]; + uint32_t i; + } u; + u.i = n; + + return ((uint32_t)u.np[0] << 24) | + ((uint32_t)u.np[1] << 16) | + ((uint32_t)u.np[2] << 8) | + (uint32_t)u.np[3]; +} + +static LU_INLINE uint16_t swap16(uint16_t n) +{ + union { + unsigned char np[2]; + uint16_t i; + } u; + u.i = n; + + return ((uint16_t)u.np[0] << 8) | (uint16_t)u.np[1]; +} + +static int bytesEqual(const uint8_t *a, const uint8_t *b, size_t count) +{ + size_t i; + for (i = 0; i < count; ++i) + { + if (*(a+i) != *(b+i)) + return 0; + } + + return 1; +} + +static void* internalMalloc(size_t size, void *userPtr) +{ + (void)userPtr; /* not used */ + return malloc(size); +} + +static void internalFree(void *ptr, void *userPtr) +{ + (void)userPtr; /* not used */ + free(ptr); +} + +static void internalPrintf(void *userPtr, const char *fmt, ...) +{ + FILE *outStream = (FILE*)userPtr; + va_list args; + + va_start(args, fmt); + vfprintf(outStream, fmt, args); + va_end(args); + fputc('\n', outStream); +} + +static size_t internalFread(void *ptr, size_t size, size_t count, void *userPtr) +{ + return fread(ptr, size, count, (FILE *)userPtr); +} + +static size_t internalFwrite(const void *ptr, size_t size, size_t count, void *userPtr) +{ + return fwrite(ptr, size, count, (FILE *)userPtr); +} + +/******************************************************** + * Png filter functions + ********************************************************/ +static LU_INLINE int absi(int val) +{ + return val > 0 ? val : -val; +} + +static LU_INLINE uint8_t raw(PngInfoStruct *info, size_t col) +{ + if (col > SIZE_T_MAX_POSITIVE) + return 0; + return info->currentScanline[col]; +} + +static LU_INLINE uint8_t prior(PngInfoStruct *info, size_t col) +{ + if (info->currentRow <= startingRow[info->interlacePass] || col > SIZE_T_MAX_POSITIVE) + return 0; + return info->previousScanline[col]; +} + + +static LU_INLINE uint8_t paethPredictor(uint8_t a, uint8_t b, uint8_t c) +{ + unsigned int A = a, B = b, C = c; + int p = (int)A + (int)B - (int)C; + int pa = absi(p - (int)A); + int pb = absi(p - (int)B); + int pc = absi(p - (int)C); + + if (pa <= pb && pa <= pc) + return a; + if (pb <= pc) + return b; + return c; +} + +static LU_INLINE uint8_t deSub(PngInfoStruct *info, uint8_t filtered) +{ + return filtered + raw(info, info->currentByte-info->bytesPerPixel); +} + +static LU_INLINE uint8_t deUp(PngInfoStruct *info, uint8_t filtered) +{ + return filtered + prior(info, info->currentByte); +} + +static LU_INLINE uint8_t deAverage(PngInfoStruct *info, uint8_t filtered) +{ + uint16_t avg = (uint16_t)(raw(info, info->currentByte-info->bytesPerPixel) + + prior(info, info->currentByte)); + avg >>= 1; + return filtered + avg; +} + +static LU_INLINE uint8_t dePaeth(PngInfoStruct *info, uint8_t filtered) +{ + return filtered + paethPredictor( + raw(info, info->currentByte-info->bytesPerPixel), + prior(info, info->currentByte), + prior(info, info->currentByte-info->bytesPerPixel)); +} + +static LU_INLINE uint8_t none(PngInfoStruct *info) +{ + return raw(info, info->currentByte); +} + +static LU_INLINE uint8_t sub(PngInfoStruct *info) +{ + return raw(info, info->currentByte) - raw(info, info->currentByte-info->bytesPerPixel); +} + +static LU_INLINE uint8_t up(PngInfoStruct *info) +{ + return raw(info, info->currentByte) - prior(info, info->currentByte); +} + +static LU_INLINE uint8_t average(PngInfoStruct *info) +{ + uint16_t avg = (uint16_t)(raw(info, info->currentByte-info->bytesPerPixel) + + prior(info, info->currentByte)); + avg >>= 1; + return raw(info, info->currentByte) - avg; +} + +static LU_INLINE uint8_t paeth(PngInfoStruct *info) +{ + return raw(info, info->currentByte) - paethPredictor( + raw(info, info->currentByte-info->bytesPerPixel), + prior(info, info->currentByte), + prior(info, info->currentByte-info->bytesPerPixel)); +} + + + +/******************************************************** + * Actual implementation + ********************************************************/ +static LU_INLINE int parseIhdr(PngInfoStruct *info, PngChunk *chunk) +{ + if (info->chunksFound) + { + LUPNG_WARN(info,"PNG: malformed PNG file!"); + return PNG_ERROR; + } + + info->chunksFound |= PNG_IHDR; + info->width = swap32(*(uint32_t *)chunk->data); + info->height = swap32(*((uint32_t *)chunk->data + 1)); + info->depth = *(chunk->data + 8); + info->colorType = *(chunk->data + 9); + info->compression = *(chunk->data + 10); + info->filter = *(chunk->data + 11); + info->interlace = *(chunk->data + 12); + + switch (info->colorType) + { + case PNG_GRAYSCALE: + info->channels = 1; + break; + case PNG_TRUECOLOR: + info->channels = 3; + break; + case PNG_PALETTED: + info->channels = 3; + break; + case PNG_GRAYSCALE_ALPHA: + info->channels = 2; + break; + case PNG_TRUECOLOR_ALPHA: + info->channels = 4; + break; + default: + LUPNG_WARN(info,"PNG: illegal color type: %u", + (unsigned int)info->colorType); + return PNG_ERROR; + break; + } + + if (info->width <= 0 || info->height <= 0) + { + LUPNG_WARN(info, "PNG: illegal dimensions"); + return PNG_ERROR; + } + + if ((info->colorType != PNG_GRAYSCALE && info->colorType != PNG_PALETTED && + info->depth < 8) || + (info->colorType == PNG_PALETTED && info->depth == 16) || + info->depth > 16) + { + LUPNG_WARN(info, "PNG: illegal bit depth for color type"); + return PNG_ERROR; + } + + if (info->compression) + { + LUPNG_WARN(info,"PNG: unknown compression method: %u", + (unsigned int)info->compression); + return PNG_ERROR; + } + + if (info->filter) + { + LUPNG_WARN(info,"PNG: unknown filter scheme: %u", + (unsigned int)info->filter); + return PNG_ERROR; + } + + memset(&(info->stream), 0, sizeof(info->stream)); + if(inflateInit(&(info->stream)) != Z_OK) + { + LUPNG_WARN(info, "PNG: inflateInit failed!"); + return PNG_ERROR; + } + info->img = luImageCreate(info->width, info->height, + info->channels, info->depth < 16 ? 8 : 16, NULL, info->userCtx); + info->cimg = info->img; + info->scanlineBytes = MAX((info->width * info->channels * info->depth) >> 3, 1); + info->currentScanline = (uint8_t *)info->userCtx->allocProc(info->scanlineBytes, info->userCtx->allocProcUserPtr); + info->previousScanline = (uint8_t *)info->userCtx->allocProc(info->scanlineBytes, info->userCtx->allocProcUserPtr); + info->currentCol = -1; + info->interlacePass = info->interlace ? 1 : 0; + info->bytesPerPixel = MAX((info->channels * info->depth) >> 3, 1); + if (!info->img || !info->currentScanline || !info->previousScanline) + { + LUPNG_WARN(info, "PNG: memory allocation failed!"); + return PNG_ERROR; + } + + return PNG_OK; +} + +static LU_INLINE int parsePlte(PngInfoStruct *info, PngChunk *chunk) +{ + if (info->chunksFound & PNG_PLTE) + { + LUPNG_WARN(info, "PNG: too many palette chunks in file!"); + return PNG_ERROR; + } + info->chunksFound |= PNG_PLTE; + + if (info->chunksFound & PNG_IDAT || !(info->chunksFound & PNG_IHDR)) + { + LUPNG_WARN(info, "PNG: malformed PNG file!"); + return PNG_ERROR; + } + + if (info->colorType == PNG_GRAYSCALE || info->colorType == PNG_GRAYSCALE_ALPHA) + { + LUPNG_WARN(info, "PNG: palettes are not allowed in grayscale images!"); + return PNG_ERROR; + } + + if (chunk->length % 3 != 0) + { + LUPNG_WARN(info, "PNG: invalid palette size!"); + return PNG_ERROR; + } + + info->paletteItems = chunk->length/3; + info->palette = (uint8_t *)info->userCtx->allocProc(chunk->length,info->userCtx->allocProcUserPtr); + if (!info->palette) + { + LUPNG_WARN(info, "PNG: memory allocation failed!"); + return PNG_ERROR; + } + memcpy(info->palette, chunk->data, chunk->length); + + return PNG_OK; +} + +static LU_INLINE void stretchBits(uint8_t inByte, uint8_t outBytes[8], int depth) +{ + int i; + switch (depth) { + case 1: + for (i = 0; i < 8; ++i) + outBytes[i] = (inByte >> (7-i)) & 0x01; + break; + + case 2: + outBytes[0] = (inByte >> 6) & 0x03; + outBytes[1] = (inByte >> 4) & 0x03; + outBytes[2] = (inByte >> 2) & 0x03; + outBytes[3] = inByte & 0x03; + break; + + case 4: + outBytes[0] = (inByte >> 4) & 0x0F; + outBytes[1] = inByte & 0x0F; + break; + + default: + break; + } +} + +/* returns: 1 if at end of scanline, 0 otherwise */ +static LU_INLINE int insertByte(PngInfoStruct *info, uint8_t byte) +{ + int advance = 0; + const uint8_t scale[] = {0x00, 0xFF, 0x55, 0x00, 0x11, 0x00, 0x00, 0x00}; + + /* for paletted images currentElem will always be 0 */ + size_t idx = info->currentRow * info->width * info->channels + + info->currentCol * info->channels + + info->currentElem; + + if (info->colorType != PNG_PALETTED) + { + if (info->depth == 8) + info->cimg->data[idx] = byte; + + else if (info->depth < 8) + info->cimg->data[idx] = byte * scale[info->depth]; + + else /* depth == 16 */ + { + info->tmpBytes[info->tmpCount] = byte; + if (info->tmpCount) /* just inserted 2nd byte */ + { + uint16_t val = *(uint16_t *)info->tmpBytes; + val = swap16(val); + info->tmpCount = 0; + + ((uint16_t *)(info->cimg->data))[idx] = val; + } + else + { + ++info->tmpCount; + return 0; + } + } + + ++info->currentElem; + if (info->currentElem >= info->channels) + { + advance = 1; + info->currentElem = 0; + } + } + else + { + /* The spec limits palette size to 256 entries */ + if (byte < info->paletteItems) + { + info->cimg->data[idx ] = info->palette[3*byte ]; + info->cimg->data[idx+1] = info->palette[3*byte+1]; + info->cimg->data[idx+2] = info->palette[3*byte+2]; + } + else + { + LUPNG_WARN(info,"PNG: invalid palette index encountered!"); + } + advance = 1; + } + + if (advance) + { + /* advance to next pixel */ + info->currentCol += colIncrement[info->interlacePass]; + + if (info->currentCol >= info->width) + { + uint8_t *tmp = info->currentScanline; + info->currentScanline = info->previousScanline; + info->previousScanline = tmp; + + info->currentCol = -1; + info->currentByte = 0; + + info->currentRow += rowIncrement[info->interlacePass]; + if (info->currentRow >= info->height && info->interlace) + { + ++info->interlacePass; + while (startingCol[info->interlacePass] >= info->width || + startingRow[info->interlacePass] >= info->height) + ++info->interlacePass; + info->currentRow = startingRow[info->interlacePass]; + } + return 1; + } + } + + return 0; +} + +static LU_INLINE int parseIdat(PngInfoStruct *info, PngChunk *chunk) +{ + unsigned char filtered[BUF_SIZE]; + int status = Z_OK; + + if (!(info->chunksFound & PNG_IHDR)) + { + LUPNG_WARN(info,"PNG: malformed PNG file!"); + return PNG_ERROR; + } + + if (info->colorType == PNG_PALETTED && !(info->chunksFound & PNG_PLTE)) + { + LUPNG_WARN(info,"PNG: palette required but missing!"); + return PNG_ERROR; + } + + info->chunksFound |= PNG_IDAT; + info->stream.next_in = (unsigned char *)chunk->data; + info->stream.avail_in = chunk->length; + do + { + size_t decompressed; + size_t i; + + info->stream.next_out = filtered; + info->stream.avail_out = BUF_SIZE; + status = inflate(&(info->stream), Z_NO_FLUSH); + decompressed = BUF_SIZE - info->stream.avail_out; + + if (status != Z_OK && + status != Z_STREAM_END && + status != Z_BUF_ERROR && + status != Z_NEED_DICT) + { + LUPNG_WARN(info, "PNG: inflate error!"); + return PNG_ERROR; + } + + for (i = 0; + i < decompressed && info->currentCol < info->width && info->currentRow < info->height; + ++i) + { + if (info->currentCol < 0) + { + info->currentCol = startingCol[info->interlacePass]; + info->currentFilter = filtered[i]; + } + else + { + uint8_t rawByte = 0; + uint8_t fullBytes[8] = {0}; + switch (info->currentFilter) + { + case PNG_FILTER_NONE: + rawByte = filtered[i]; + break; + case PNG_FILTER_SUB: + rawByte = deSub(info, filtered[i]); + break; + case PNG_FILTER_UP: + rawByte = deUp(info, filtered[i]); + break; + case PNG_FILTER_AVERAGE: + rawByte = deAverage(info, filtered[i]); + break; + case PNG_FILTER_PAETH: + rawByte = dePaeth(info, filtered[i]); + break; + default: + break; + } + + info->currentScanline[info->currentByte] = rawByte; + ++info->currentByte; + + if (info->depth < 8) + { + int j; + stretchBits(rawByte, fullBytes, info->depth); + for (j = 0; j < 8/info->depth; ++j) + if(insertByte(info, fullBytes[j])) + break; + } + else + insertByte(info, rawByte); + } + } + } while ((info->stream.avail_in > 0 || info->stream.avail_out == 0) + && info->currentCol < info->width && info->currentRow < info->height); + + return PNG_OK; +} + +static LU_INLINE PngChunk *readChunk(PngInfoStruct *info) +{ + PngChunk *chunk = (PngChunk *)info->userCtx->allocProc(sizeof(PngChunk),info->userCtx->allocProcUserPtr); + size_t read = 0; + if (!chunk) + { + LUPNG_WARN(info,"PNG: memory allocation failed!"); + return NULL; + } + + info->userCtx->readProc((void *)&chunk->length, 4, 1, info->userCtx->readProcUserPtr); + chunk->length = swap32(chunk->length); + if (chunk->length+4 < chunk->length) + { + LUPNG_WARN(info, "PNG: chunk claims to be absurdly large"); + info->userCtx->freeProc(chunk, info->userCtx->freeProcUserPtr); + return NULL; + } + + // Store chunk type and contents in the same buffer for convenience + chunk->type = (uint8_t *)info->userCtx->allocProc(chunk->length + 4, info->userCtx->allocProcUserPtr); + if (!chunk->type) + { + LUPNG_WARN(info,"PNG: memory allocation failed!"); + info->userCtx->freeProc(chunk, info->userCtx->freeProcUserPtr); + return NULL; + } + chunk->data = chunk->type + 4; + info->userCtx->readProc((void *)chunk->type, 1, chunk->length + 4, info->userCtx->readProcUserPtr); + read = info->userCtx->readProc((void *)&chunk->crc, 4, 1, info->userCtx->readProcUserPtr); + chunk->crc = swap32(chunk->crc); + + for (int i = 0; i < 4; ++i) + { + char byte = chunk->type[i]; + if ((byte < 'a' || byte > 'z') && (byte < 'A' || byte > 'Z')) + { + LUPNG_WARN(info, "PNG: invalid chunk name, possibly unprintable"); + releaseChunk(chunk, info->userCtx); + return NULL; + } + } + if (read != 1) + { + LUPNG_WARN(info, "PNG: read error"); + releaseChunk(chunk, info->userCtx); + return NULL; + } + + if (crc(chunk->type, chunk->length+4) != chunk->crc) + { + LUPNG_WARN(info, "PNG: CRC mismatch in \'%.4s\' chunk", (char *)chunk->type); + releaseChunk(chunk, info->userCtx); + return NULL; + } + + return chunk; +} + +static LU_INLINE int handleChunk(PngInfoStruct *info, PngChunk *chunk) +{ + /* critical chunk */ + if (!(chunk->type[0] & 0x20)) + { + if (bytesEqual(chunk->type, (const uint8_t *)"IHDR", 4)) + return parseIhdr(info, chunk); + if (bytesEqual(chunk->type, (const uint8_t *)"PLTE", 4)) + return parsePlte(info, chunk); + if (bytesEqual(chunk->type, (const uint8_t *)"IDAT", 4)) + return parseIdat(info, chunk); + if (bytesEqual(chunk->type, (const uint8_t *)"IEND", 4)) + { + info->chunksFound |= PNG_IEND; + if (!(info->chunksFound & PNG_IDAT)) + { + LUPNG_WARN(info, "PNG: no IDAT chunk found"); + return PNG_ERROR; + } + return PNG_DONE; + } + } + /* ignore ancillary chunks for now */ + + return PNG_OK; +} + +LuImage *luPngReadUC(const LuUserContext *userCtx) +{ + + uint8_t signature[PNG_SIG_SIZE]; + int status = PNG_ERROR; + + PngInfoStruct info; + memset(&info, 0, sizeof(PngInfoStruct)); + info.userCtx = userCtx; + + if (!userCtx->skipSig) + { + info.userCtx->readProc((void *)signature, 1, PNG_SIG_SIZE, info.userCtx->readProcUserPtr); + status = bytesEqual(signature, PNG_SIG, PNG_SIG_SIZE) ? PNG_OK : PNG_ERROR; + } + + if (status == PNG_OK) + { + PngChunk *chunk; + while ((chunk = readChunk(&info))) + { + status = handleChunk(&info, chunk); + releaseChunk(chunk, info.userCtx); + + if (status != PNG_OK) + break; + } + } + else + LUPNG_WARN(&info, "PNG: invalid header"); + + userCtx->freeProc(info.currentScanline, userCtx->freeProcUserPtr); + userCtx->freeProc(info.previousScanline, userCtx->freeProcUserPtr); + userCtx->freeProc(info.palette, userCtx->freeProcUserPtr); + inflateEnd(&info.stream); + + if (status == PNG_DONE) + return info.img; + else + if (info.img) + luImageRelease(info.img, info.userCtx); + + return NULL; +} + +LuImage *luPngRead(PngReadProc readProc, void *userPtr, int skipSig) +{ + LuUserContext userCtx; + + luUserContextInitDefault(&userCtx); + userCtx.readProc = readProc; + userCtx.readProcUserPtr = userPtr; + userCtx.skipSig = skipSig; + return luPngReadUC(&userCtx); +} + +LuImage *luPngReadFile(const char *filename, LuUserContext *userCtx) +{ + LuUserContext tmp_userCtx; + if (userCtx == NULL) { + luUserContextInitDefault(&tmp_userCtx); + userCtx = &tmp_userCtx; + } + + LuImage *img; + FILE *f = fopen(filename,"rb"); + + if (f) { + userCtx->readProc = internalFread; + userCtx->readProcUserPtr = f; + img = luPngReadUC(userCtx); + fclose(f); + } else { + LUPNG_WARN_UC(userCtx, "PNG: failed to open '%s'", filename); + img = NULL; + } + + return img; +} + +static LU_INLINE int writeIhdr(PngInfoStruct *info) +{ + static uint8_t buf[17]; + static const uint8_t colorType[] = { + PNG_GRAYSCALE, + PNG_GRAYSCALE_ALPHA, + PNG_TRUECOLOR, + PNG_TRUECOLOR_ALPHA + }; + size_t written = 0; + PngChunk c; + + if (info->cimg->channels > 4) + { + LUPNG_WARN(info, "PNG: too many channels in image"); + return PNG_ERROR; + } + + c.length = swap32(13); + c.type = buf; /* 4 (type) + 4 + 4 + 5x1 */ + c.data = c.type + 4; + + memcpy((void *)c.type, (void *)"IHDR", 4); + *(uint32_t *)(c.data) = swap32((uint32_t)info->cimg->width); + *(uint32_t *)(c.data + 4) = swap32((uint32_t)info->cimg->height); + *(c.data + 8) = info->cimg->depth; + *(c.data + 9) = colorType[info->cimg->channels-1]; + *(c.data + 10) = 0; /* compression method */ + *(c.data + 11) = 0; /* filter method */ + *(c.data + 12) = 0; /* interlace method: none */ + + c.crc = swap32(crc(c.type, 17)); + + written += info->userCtx->writeProc((void *)&c.length, 4, 1, info->userCtx->writeProcUserPtr) * 4; + written += info->userCtx->writeProc((void *)c.type, 1, 4, info->userCtx->writeProcUserPtr); + written += info->userCtx->writeProc((void *)c.data, 1, 13, info->userCtx->writeProcUserPtr); + written += info->userCtx->writeProc((void *)&c.crc, 4, 1, info->userCtx->writeProcUserPtr) * 4; + + if (written != 25) + { + LUPNG_WARN(info, "PNG: write error"); + return PNG_ERROR; + } + + return PNG_OK; +} + +static LU_INLINE int writeIdat(PngInfoStruct *info, uint8_t *buf, size_t buflen) +{ + size_t written = 0; + PngChunk c; + + c.length = swap32((uint32_t)(buflen-4)); + c.crc = swap32(crc(buf, buflen)); + + written += info->userCtx->writeProc((void *)&c.length, 4, 1, info->userCtx->writeProcUserPtr) * 4; + written += info->userCtx->writeProc((void *)buf, 1, buflen, info->userCtx->writeProcUserPtr); + written += info->userCtx->writeProc((void *)&c.crc, 4, 1, info->userCtx->writeProcUserPtr) * 4; + + if (written != buflen+8) + { + LUPNG_WARN(info, "PNG: write error"); + return PNG_ERROR; + } + + return PNG_OK; +} + +static LU_INLINE void advanceBytep(PngInfoStruct *info, int is16bit) +{ + if (is16bit) + { + if (info->currentByte%2) + --info->currentByte; + else + info->currentByte+=3; + } + else + ++info->currentByte; +} + +static LU_INLINE size_t filterScanline(PngInfoStruct *info, + uint8_t(*f)(PngInfoStruct *info), + uint8_t filter, + uint8_t *filterCandidate, + int is16bit) +{ + size_t curSum = 0; + size_t fc; + + filterCandidate[0] = filter; + for (info->currentByte = is16bit ? 1 : 0, fc = 1; + info->currentByte < info->scanlineBytes; ++fc, advanceBytep(info, is16bit) ) + { + uint8_t val = f(info); + filterCandidate[fc] = val; + curSum += val; + } + + return curSum; +} + +/* + * Processes the input image and calls writeIdat for every BUF_SIZE compressed + * bytes. + */ +static LU_INLINE int processPixels(PngInfoStruct *info) +{ + uint8_t idatBuf[BUF_SIZE+4] = {'I', 'D', 'A', 'T'}; + uint8_t *compressed = idatBuf+4; + uint8_t *filterCandidate = (uint8_t *)info->userCtx->allocProc(info->scanlineBytes+1, info->userCtx->allocProcUserPtr); + uint8_t *bestCandidate = (uint8_t *)info->userCtx->allocProc(info->scanlineBytes+1, info->userCtx->allocProcUserPtr); + size_t minSum = (size_t)-1, curSum = 0; + int status = Z_OK; + int is16bit = info->cimg->depth == 16; + + if (!filterCandidate || !bestCandidate) + { + LUPNG_WARN(info, "PNG: memory allocation failed!"); + } + + memset(&(info->stream), 0, sizeof(info->stream)); + if(deflateInit(&(info->stream), info->userCtx->compressionLevel) != Z_OK) + { + LUPNG_WARN(info, "PNG: deflateInit failed!"); + info->userCtx->freeProc(filterCandidate, info->userCtx->freeProcUserPtr); + info->userCtx->freeProc(bestCandidate, info->userCtx->freeProcUserPtr); + return PNG_ERROR; + } + + info->stream.avail_out = BUF_SIZE; + info->stream.next_out = compressed; + + for (info->currentRow = 0; info->currentRow < info->cimg->height; + ++info->currentRow) + { + int flush = (info->currentRow < info->cimg->height-1) ? + Z_NO_FLUSH : Z_FINISH; + minSum = (size_t)-1; + + /* + * 1st time it doesn't matter, the filters never look at the previous + * scanline when processing row 0. And next time it'll be valid. + */ + info->previousScanline = info->currentScanline; + info->currentScanline = info->cimg->data + (info->currentRow*info->scanlineBytes); + + /* + * Try to choose the best filter for each scanline. + * Breaks in case of overflow, but hey it's just a heuristic. + */ + for (info->currentFilter = PNG_FILTER_NONE; info->currentFilter <= PNG_FILTER_PAETH; ++info->currentFilter) + { + + switch (info->currentFilter) + { + case PNG_FILTER_NONE: + curSum = filterScanline(info, none, PNG_FILTER_NONE, filterCandidate, is16bit); + break; + + case PNG_FILTER_SUB: + curSum = filterScanline(info, sub, PNG_FILTER_SUB, filterCandidate, is16bit); + break; + + case PNG_FILTER_UP: + curSum = filterScanline(info, up, PNG_FILTER_UP, filterCandidate, is16bit); + break; + + case PNG_FILTER_AVERAGE: + curSum = filterScanline(info, average, PNG_FILTER_AVERAGE, filterCandidate, is16bit); + break; + + case PNG_FILTER_PAETH: + curSum = filterScanline(info, paeth, PNG_FILTER_PAETH, filterCandidate, is16bit); + break; + + default: + break; + } + + if (curSum < minSum || !info->currentFilter) + { + uint8_t *tmp = bestCandidate; + bestCandidate = filterCandidate; + filterCandidate = tmp; + minSum = curSum; + } + } + + info->stream.avail_in = (unsigned int)info->scanlineBytes+1; + info->stream.next_in = bestCandidate; + + /* compress bestCandidate */ + do + { + status = deflate(&info->stream, flush); + + if (info->stream.avail_out < BUF_SIZE) + { + writeIdat(info, idatBuf, BUF_SIZE-info->stream.avail_out+4); + info->stream.next_out = compressed; + info->stream.avail_out = BUF_SIZE; + } + } while ((flush == Z_FINISH && status != Z_STREAM_END) + || (flush == Z_NO_FLUSH && info->stream.avail_in)); + } + + info->userCtx->freeProc(filterCandidate, info->userCtx->freeProcUserPtr); + info->userCtx->freeProc(bestCandidate, info->userCtx->freeProcUserPtr); + + return PNG_OK; +} + +static LU_INLINE int writeIend(PngInfoStruct *info) +{ + PngChunk c = { 0, (uint8_t *)"IEND", 0, 0 }; + size_t written = 0; + c.crc = swap32(crc(c.type, 4)); + + written += info->userCtx->writeProc((void *)&c.length, 4, 1, info->userCtx->writeProcUserPtr) * 4; + written += info->userCtx->writeProc((void *)c.type, 1, 4, info->userCtx->writeProcUserPtr); + written += info->userCtx->writeProc((void *)&c.crc, 4, 1, info->userCtx->writeProcUserPtr) * 4; + + if (written != 12) + { + LUPNG_WARN(info, "PNG: write error"); + return PNG_ERROR; + } + + return PNG_OK; +} + +int luPngWriteUC(const LuUserContext *userCtx, const LuImage *img) +{ + PngInfoStruct info; + memset(&info, 0, sizeof(PngInfoStruct)); + info.userCtx = userCtx; + info.cimg = img; + info.bytesPerPixel = (info.cimg->channels * info.cimg->depth) >> 3; + + if (info.userCtx->writeProc((void *)PNG_SIG, 1, PNG_SIG_SIZE, info.userCtx->writeProcUserPtr) != PNG_SIG_SIZE) + { + LUPNG_WARN(&info, "PNG: write error"); + return PNG_ERROR; + } + + if (writeIhdr(&info) != PNG_OK) + return PNG_ERROR; + + info.scanlineBytes = (info.cimg->depth >> 3) * info.cimg->channels * info.cimg->width; + if (processPixels(&info) != PNG_OK) + { + deflateEnd(&(info.stream)); + return PNG_ERROR; + } + + deflateEnd(&(info.stream)); + return writeIend(&info); +} + +int luPngWrite(PngWriteProc writeProc, void *userPtr, const LuImage *img) +{ + LuUserContext userCtx; + + luUserContextInitDefault(&userCtx); + userCtx.writeProc = writeProc; + userCtx.writeProcUserPtr = userPtr; + return luPngWriteUC(&userCtx, img); +} + +int luPngWriteFile(const char *filename, const LuImage *img) +{ + LuUserContext userCtx; + FILE *f; + + if (!img) + { + return PNG_ERROR; + } + + f = fopen(filename,"wb"); + luUserContextInitDefault(&userCtx); + if (f) + { + userCtx.writeProc = internalFwrite; + userCtx.writeProcUserPtr = f; + luPngWriteUC(&userCtx, img); + fclose(f); + } + else + { + LUPNG_WARN_UC(&userCtx, "PNG: failed to open '%s'", filename); + return PNG_ERROR; + } + + return PNG_OK; +} + +void luImageRelease(LuImage *img, const LuUserContext *userCtx) +{ + LuUserContext ucDefault; + + if (userCtx == NULL) + { + luUserContextInitDefault(&ucDefault); + userCtx = &ucDefault; + } + + userCtx->freeProc(img->data, userCtx->freeProcUserPtr); + if (userCtx->overrideImage != img) + userCtx->freeProc(img, userCtx->freeProcUserPtr); +} + +LuImage *luImageCreate(size_t width, size_t height, uint8_t channels, uint8_t depth, + uint8_t *buffer, const LuUserContext *userCtx) +{ + LuImage *img; + LuUserContext ucDefault; + + if (userCtx == NULL) { + luUserContextInitDefault(&ucDefault); + userCtx = &ucDefault; + } + + if (depth != 8 && depth != 16) + { + LUPNG_WARN_UC(userCtx,"Image: only bit depths 8 and 16 are supported!"); + return NULL; + } + if (width > 0x7FFFFFFF || height > 0x7FFFFFFF) { + LUPNG_WARN_UC(userCtx, "Image: only 32 bit signed image dimensions are supported!"); + return NULL; + } + + if (userCtx->overrideImage) + img = userCtx->overrideImage; + else + img = (LuImage *)userCtx->allocProc(sizeof(LuImage), userCtx->allocProcUserPtr); + if (!img) + return NULL; + + img->width = (int32_t)width; + img->height = (int32_t)height; + img->channels = channels; + img->depth = depth; + img->dataSize = (size_t)((depth >> 3) * width * height * channels); + if (buffer) + img->data = buffer; + else + img->data = (uint8_t *)userCtx->allocProc(img->dataSize, userCtx->allocProcUserPtr); + + if (img->data == NULL) + { + luImageRelease(img, userCtx); + return NULL; + } + + return img; +} + +uint8_t *luImageExtractBufAndRelease(LuImage *img, const LuUserContext *userCtx) +{ + uint8_t *data; + LuUserContext ucDefault; + + if (userCtx == NULL) { + luUserContextInitDefault(&ucDefault); + userCtx = &ucDefault; + } + + if (img) + { + data = img->data; + img->data = NULL; + luImageRelease(img, userCtx); + } + else + { + data = NULL; + } + + return data; +} + +void luUserContextInitDefault(LuUserContext *userCtx) +{ + userCtx->readProc=NULL; + userCtx->readProcUserPtr=NULL; + userCtx->skipSig = 0; + + userCtx->writeProc=NULL; + userCtx->writeProcUserPtr=NULL; + userCtx->compressionLevel=Z_DEFAULT_COMPRESSION; + + userCtx->allocProc=internalMalloc; + userCtx->allocProcUserPtr=NULL; + userCtx->freeProc=internalFree; + userCtx->freeProcUserPtr=NULL; + + userCtx->warnProc=internalPrintf; + userCtx->warnProcUserPtr=(void*)stderr; + + userCtx->overrideImage=NULL; +} \ No newline at end of file diff --git a/tests/regression/tex/lupng.h b/tests/regression/tex/lupng.h new file mode 100644 index 00000000..5c3f8465 --- /dev/null +++ b/tests/regression/tex/lupng.h @@ -0,0 +1,186 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2014 Jan Solanti + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma once + +#if defined(_MSC_VER) && (_MSC_VER < 1600) +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +#else +#include +#include +#endif + +typedef struct { + int32_t width; + int32_t height; + uint8_t channels; + uint8_t depth; /* must be 8 or 16 */ + size_t dataSize; + uint8_t *data; +} LuImage; + +typedef size_t (*PngReadProc)(void *outPtr, size_t size, size_t count, void *userPtr); +typedef size_t (*PngWriteProc)(const void *inPtr, size_t size, size_t count, void *userPtr); +typedef void* (*PngAllocProc)(size_t size, void *userPtr); +typedef void (*PngFreeProc)(void *ptr, void *userPtr); +typedef void (*PngWarnProc)(void *userPtr, const char *fmt, ...); + +typedef struct { + /* loader */ + PngReadProc readProc; + void *readProcUserPtr; + int skipSig; + + /* writer */ + PngWriteProc writeProc; + void *writeProcUserPtr; + int compressionLevel; + + /* memory allocation */ + PngAllocProc allocProc; + void *allocProcUserPtr; + PngFreeProc freeProc; + void *freeProcUserPtr; + + /* warnings/error output */ + PngWarnProc warnProc; /* set to NULL to disable output altogether */ + void *warnProcUserPtr; + + /* special case: avoid allocating a LuImage when loading or creating + * an image, just use this one */ + LuImage *overrideImage; +} LuUserContext; + +/** + * Initializes a LuUserContext to use the defaul malloc implementation. + * + * @param userCtx the LuUserContext to initialize + */ +void luUserContextInitDefault(LuUserContext *userCtx); + +/** + * Creates a new Image object with the specified attributes. + * The data store of the Image is allocated but its contents are undefined. + * Only 8 and 16 bits deep images with 1-4 channels are supported. + * + * @param buffer pointer to an existing buffer (which may already contain the + * image data), or NULL to internally allocate a new buffer + * @param userCtx the user context (with the memory allocator function + * pointers to use), or NULL to use the default allocator + * (malloc). + */ +LuImage *luImageCreate(size_t width, size_t height, uint8_t channels, uint8_t depth, + uint8_t *buffer, const LuUserContext *usrCtx); + +/** + * Releases the memory associated with the given Image object. + * + * @param userCtx the user context (with the memory deallocator function + * pointers to use), or NULL to use the default deallocator + * (free). The deallocator should match the ones used for + * allocation. + */ +void luImageRelease(LuImage *img, const LuUserContext *usrCtx); + +/** + * Extracts the raw image buffer form a LuImage and releases the + * then-orphaned LuImage object. This can be used if you want to use + * the image data in your own structures. + * + * @param userCtx the user context (with the memory deallocator function + * pointers to use), or NULL to use the default deallocator + * (free). The deallocator should match the ones used for + * allocation. + */ +uint8_t *luImageExtractBufAndRelease(LuImage *img, const LuUserContext *userCtx); + +/** + * Decodes a PNG image from a file + * + * @param filename the file name (optionally with full path) to read from. + * @param userCtx the user context (with the memory allocator function + * pointers to use), or NULL to use the default allocator + * (malloc). + */ +LuImage *luPngReadFile(const char *filename, LuUserContext *userCtx); + +/** + * Decodes a PNG image with the provided read function into a LuImage struct + * + * @param readProc a function pointer to a user-defined function to use for + * reading the PNG data. + * @param userPtr an opaque pointer provided as an argument to readProc + * @param skipSig don't verify PNG signature - the bytes have already been + * removed from the input stream + */ +LuImage *luPngRead(PngReadProc readProc, void *userPtr, int skipSig); + +/** + * Decodes a PNG image with the provided user context into a LuImage struct + * + * @param userCtx the LuUserContext to use + */ +LuImage *luPngReadUC(const LuUserContext *userCtx); + +/** + * Encodes a LuImage struct to PNG and writes it out to a file. + * + * @param filename the file name (optionally with full path) to write to. + * Existing files will be overwritten! + * @param img the LuImage to encode + */ +int luPngWriteFile(const char *filename, const LuImage *img); + +/** + * Encodes a LuImage struct to PNG and writes it out using a user-defined write + * function. + * + * @param writeProc a function pointer to a user-defined function that will be + * used for writing the final PNG data. + * @param userPtr an opaque pointer provided as an argument to writeProc + * @param img the LuImage to encode + */ +int luPngWrite(PngWriteProc writeProc, void *userPtr, const LuImage *img); + +/** + * Encodes a LuImage struct to PNG and writes it out with the provided user + * context. + * + * @param userCtx the LuUserContext to use + * @param img the LuImage to encode + */ +int luPngWriteUC(const LuUserContext *userCtx, const LuImage *img); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/tests/regression/tex/surfacedesc.h b/tests/regression/tex/surfacedesc.h new file mode 100644 index 00000000..cf303584 --- /dev/null +++ b/tests/regression/tex/surfacedesc.h @@ -0,0 +1,25 @@ +// +// Copyright (c) Blaise Tine. All rights reserved. +// +// +// Use of this sample source code is subject to the terms of the Microsoft +// license agreement under which you licensed this sample source code. If +// you did not accept the terms of the license agreement, you are not +// authorized to use this sample source code. For the terms of the license, +// please see the license agreement between you and Microsoft or, if applicable, +// see the LICENSE.RTF on your install media or the root of your tools +// installation. +// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR +// INDEMNITIES. +// +#pragma once + +#include "format.h" + +struct SurfaceDesc { + ePixelFormat Format; + uint8_t *pBits; + uint32_t Width; + uint32_t Height; + uint32_t Pitch; +}; \ No newline at end of file diff --git a/tests/regression/tex/tga.cpp b/tests/regression/tex/tga.cpp new file mode 100644 index 00000000..62641587 --- /dev/null +++ b/tests/regression/tex/tga.cpp @@ -0,0 +1,122 @@ +#include "tga.h" +#include +#include +#include "format.h" + +struct __attribute__((__packed__)) tga_header_t { + int8_t idlength; + int8_t colormaptype; + int8_t imagetype; + int16_t colormaporigin; + int16_t colormaplength; + int8_t colormapdepth; + int16_t xoffset; + int16_t yoffset; + int16_t width; + int16_t height; + int8_t bitsperpixel; + int8_t imagedescriptor; +}; + +int LoadTGA(const char *filename, + std::vector &pixels, + uint32_t *width, + uint32_t *height, + uint32_t *bpp) { + std::ifstream ifs(filename, std::ios::in | std::ios::binary); + if (!ifs.is_open()) { + std::cerr << "couldn't open file: " << filename << "!" << std::endl; + return -1; + } + + tga_header_t header; + ifs.read(reinterpret_cast(&header), sizeof(tga_header_t)); + if (ifs.fail()) { + std::cerr << "invalid TGA file header!" << std::endl; + return -1; + } + + if (header.imagetype != 2) { + std::cerr << "unsupported TGA encoding format!" << std::endl; + return -1; + } + + ifs.seekg(header.idlength, std::ios::cur); // skip string + if (ifs.fail()) { + std::cerr << "invalid TGA file!" << std::endl; + return -1; + } + + switch (header.bitsperpixel) { + case 16: + case 24: + case 32: { + // Read pixels data + auto stride = header.bitsperpixel / 8; + pixels.resize(stride * header.width * header.height); + ifs.read((char*)pixels.data(), pixels.size()); + if (ifs.fail()) { + std::cerr << "invalid TGA file!" << std::endl; + return -1; + } + *bpp = stride; + break; + } + default: + std::cerr << "unsupported TGA bitsperpixel!" << std::endl; + return -1; + } + + *width = header.width; + *height = header.height; + + return 0; +} + +int SaveTGA(const char *filename, + const std::vector &pixels, + uint32_t width, + uint32_t height, + uint32_t bpp) { + std::ofstream ofs(filename, std::ios::out | std::ios::binary); + if (!ofs.is_open()) { + std::cerr << "couldn't create file: " << filename << "!" << std::endl; + return -1; + } + + if (bpp < 2 || bpp > 4) { + std::cerr << "unsupported pixel stride: " << bpp << "!" << std::endl; + return -1; + } + + tga_header_t header; + header.idlength = 0; + header.colormaptype = 0; // no palette + header.imagetype = 2; // color mapped data + header.colormaporigin = 0; + header.colormaplength = 0; + header.colormapdepth = 0; + header.xoffset = 0; + header.yoffset = 0; + header.width = width; + header.height = height; + header.bitsperpixel = bpp * 8; + header.imagedescriptor = 0; + + // write header + ofs.write(reinterpret_cast(&header), sizeof(tga_header_t)); + + // write pixel data + uint32_t pitch = bpp * width; + const uint8_t* pixel_bytes = pixels.data() + (height - 1) * pitch; + for (uint32_t y = 0; y < height; ++y) { + const uint8_t* pixel_row = pixel_bytes; + for (uint32_t x = 0; x < width; ++x) { + ofs.write((const char*)pixel_row, bpp); + pixel_row += bpp; + } + pixel_bytes -= pitch; + } + + return 0; +} \ No newline at end of file diff --git a/tests/regression/tex/tga.h b/tests/regression/tex/tga.h new file mode 100644 index 00000000..24b92a75 --- /dev/null +++ b/tests/regression/tex/tga.h @@ -0,0 +1,14 @@ +#include +#include + +int LoadTGA(const char *filename, + std::vector &pixels, + uint32_t *width, + uint32_t *height, + uint32_t *bpp); + +int SaveTGA(const char *filename, + const std::vector &pixels, + uint32_t width, + uint32_t height, + uint32_t bpp); \ No newline at end of file