Created
December 25, 2019 02:42
-
-
Save Heppokoyuki/410420a8b737ab619630510a733f306d to your computer and use it in GitHub Desktop.
risc-v assembly sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int | |
func(int a, int b) | |
{ | |
return a + b; | |
} | |
int | |
main(void) | |
{ | |
int c = func(2, 3); | |
int d = 56; | |
return c * d; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a.out: file format elf64-littleriscv | |
Disassembly of section .plt: | |
0000000000010360 <_PROCEDURE_LINKAGE_TABLE_>: | |
10360: 97 23 00 00 33 03 c3 41 03 be 03 ca 13 03 43 fd .#..3..A......C. | |
10370: 93 82 03 ca 13 53 13 00 83 b2 82 00 67 00 0e 00 .....S......g... | |
0000000000010380 <__libc_start_main@plt>: | |
10380: 00002e17 auipc t3,0x2 | |
10384: c90e3e03 ld t3,-880(t3) # 12010 <__libc_start_main@GLIBC_2.27> | |
10388: 000e0367 jalr t1,t3 | |
1038c: 00000013 nop | |
Disassembly of section .text: | |
0000000000010390 <_start>: | |
10390: 02e000ef jal ra,103be <_start+0x2e> | |
10394: 87aa mv a5,a0 | |
10396: 00000517 auipc a0,0x0 | |
1039a: 0d050513 addi a0,a0,208 # 10466 <main> | |
1039e: 6582 ld a1,0(sp) | |
103a0: 0030 addi a2,sp,8 | |
103a2: ff017113 andi sp,sp,-16 | |
103a6: 00000697 auipc a3,0x0 | |
103aa: 0f668693 addi a3,a3,246 # 1049c <__libc_csu_init> | |
103ae: 00000717 auipc a4,0x0 | |
103b2: 14670713 addi a4,a4,326 # 104f4 <__libc_csu_fini> | |
103b6: 880a mv a6,sp | |
103b8: fc9ff0ef jal ra,10380 <__libc_start_main@plt> | |
103bc: 9002 ebreak | |
103be: 00002197 auipc gp,0x2 | |
103c2: 44218193 addi gp,gp,1090 # 12800 <__global_pointer$> | |
103c6: 8082 ret | |
... | |
00000000000103ca <deregister_tm_clones>: | |
103ca: 6549 lui a0,0x12 | |
103cc: 6749 lui a4,0x12 | |
103ce: 00050793 mv a5,a0 | |
103d2: 00070713 mv a4,a4 | |
103d6: 00f70b63 beq a4,a5,103ec <deregister_tm_clones+0x22> | |
103da: 00000337 lui t1,0x0 | |
103de: 00030313 mv t1,t1 | |
103e2: 00030563 beqz t1,103ec <deregister_tm_clones+0x22> | |
103e6: 00050513 mv a0,a0 | |
103ea: 8302 jr t1 | |
103ec: 8082 ret | |
00000000000103ee <register_tm_clones>: | |
103ee: 6549 lui a0,0x12 | |
103f0: 00050593 mv a1,a0 | |
103f4: 67c9 lui a5,0x12 | |
103f6: 00078793 mv a5,a5 | |
103fa: 8f8d sub a5,a5,a1 | |
103fc: 4037d713 srai a4,a5,0x3 | |
10400: 03f7d593 srli a1,a5,0x3f | |
10404: 95ba add a1,a1,a4 | |
10406: 8585 srai a1,a1,0x1 | |
10408: c991 beqz a1,1041c <register_tm_clones+0x2e> | |
1040a: 00000337 lui t1,0x0 | |
1040e: 00030313 mv t1,t1 | |
10412: 00030563 beqz t1,1041c <register_tm_clones+0x2e> | |
10416: 00050513 mv a0,a0 | |
1041a: 8302 jr t1 | |
1041c: 8082 ret | |
000000000001041e <__do_global_dtors_aux>: | |
1041e: 1141 addi sp,sp,-16 | |
10420: e022 sd s0,0(sp) | |
10422: 8301c783 lbu a5,-2000(gp) # 12030 <_edata> | |
10426: e406 sd ra,8(sp) | |
10428: e791 bnez a5,10434 <__do_global_dtors_aux+0x16> | |
1042a: fa1ff0ef jal ra,103ca <deregister_tm_clones> | |
1042e: 4785 li a5,1 | |
10430: 82f18823 sb a5,-2000(gp) # 12030 <_edata> | |
10434: 60a2 ld ra,8(sp) | |
10436: 6402 ld s0,0(sp) | |
10438: 0141 addi sp,sp,16 | |
1043a: 8082 ret | |
000000000001043c <frame_dummy>: | |
1043c: bf4d j 103ee <register_tm_clones> | |
000000000001043e <func>: | |
1043e: 1101 addi sp,sp,-32 | |
10440: ec22 sd s0,24(sp) | |
10442: 1000 addi s0,sp,32 | |
10444: 87aa mv a5,a0 | |
10446: 872e mv a4,a1 | |
10448: fef42623 sw a5,-20(s0) | |
1044c: 87ba mv a5,a4 | |
1044e: fef42423 sw a5,-24(s0) | |
10452: fec42703 lw a4,-20(s0) | |
10456: fe842783 lw a5,-24(s0) | |
1045a: 9fb9 addw a5,a5,a4 | |
1045c: 2781 sext.w a5,a5 | |
1045e: 853e mv a0,a5 | |
10460: 6462 ld s0,24(sp) | |
10462: 6105 addi sp,sp,32 | |
10464: 8082 ret | |
0000000000010466 <main>: | |
10466: 1101 addi sp,sp,-32 | |
10468: ec06 sd ra,24(sp) | |
1046a: e822 sd s0,16(sp) | |
1046c: 1000 addi s0,sp,32 | |
1046e: 458d li a1,3 | |
10470: 4509 li a0,2 | |
10472: fcdff0ef jal ra,1043e <func> | |
10476: 87aa mv a5,a0 | |
10478: fef42623 sw a5,-20(s0) | |
1047c: 03800793 li a5,56 | |
10480: fef42423 sw a5,-24(s0) | |
10484: fec42703 lw a4,-20(s0) | |
10488: fe842783 lw a5,-24(s0) | |
1048c: 02f707bb mulw a5,a4,a5 | |
10490: 2781 sext.w a5,a5 | |
10492: 853e mv a0,a5 | |
10494: 60e2 ld ra,24(sp) | |
10496: 6442 ld s0,16(sp) | |
10498: 6105 addi sp,sp,32 | |
1049a: 8082 ret | |
000000000001049c <__libc_csu_init>: | |
1049c: 7139 addi sp,sp,-64 | |
1049e: f822 sd s0,48(sp) | |
104a0: f04a sd s2,32(sp) | |
104a2: 00002417 auipc s0,0x2 | |
104a6: 97e40413 addi s0,s0,-1666 # 11e20 <__frame_dummy_init_array_entry> | |
104aa: 00002917 auipc s2,0x2 | |
104ae: 97e90913 addi s2,s2,-1666 # 11e28 <__init_array_end> | |
104b2: 40890933 sub s2,s2,s0 | |
104b6: fc06 sd ra,56(sp) | |
104b8: f426 sd s1,40(sp) | |
104ba: ec4e sd s3,24(sp) | |
104bc: e852 sd s4,16(sp) | |
104be: e456 sd s5,8(sp) | |
104c0: 40395913 srai s2,s2,0x3 | |
104c4: 00090f63 beqz s2,104e2 <__libc_csu_init+0x46> | |
104c8: 89aa mv s3,a0 | |
104ca: 8a2e mv s4,a1 | |
104cc: 8ab2 mv s5,a2 | |
104ce: 4481 li s1,0 | |
104d0: 601c ld a5,0(s0) | |
104d2: 8656 mv a2,s5 | |
104d4: 85d2 mv a1,s4 | |
104d6: 854e mv a0,s3 | |
104d8: 0485 addi s1,s1,1 | |
104da: 9782 jalr a5 | |
104dc: 0421 addi s0,s0,8 | |
104de: fe9919e3 bne s2,s1,104d0 <__libc_csu_init+0x34> | |
104e2: 70e2 ld ra,56(sp) | |
104e4: 7442 ld s0,48(sp) | |
104e6: 74a2 ld s1,40(sp) | |
104e8: 7902 ld s2,32(sp) | |
104ea: 69e2 ld s3,24(sp) | |
104ec: 6a42 ld s4,16(sp) | |
104ee: 6aa2 ld s5,8(sp) | |
104f0: 6121 addi sp,sp,64 | |
104f2: 8082 ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment