1.安装Gforth,在终端中输入Gforth
2.把编辑好的汇编文件拷贝到/esr/share/gforth/site-forth文件夹中
3.加载汇编,反汇编程序在终端中输入include asm.fs disasm.fs(注意:文件以fs,结尾上传时会变成txt结尾,要更改过来)
4.查看汇编字:在终端中输入code +
3.分析code字组成,如下(注意Code字中不变的程序不能变更,分许出字中功能)
code +
( $AAAC42CCF4 ) $270003D9 stptr.d, rd:25 rj:30 i14:0
( $AAAC42CCF8 ) $28C022CD ld.d, rd:13 rj:22 i12:8
( $AAAC42CCFC ) $260002CE ldptr.d, rd:14 rj:22 i14:0
( $AAAC42CD00 ) $2C022D6 addi.d, rd:22 rj:22 i12:8
( $AAAC42CD04 ) $2C02339 addi.d, rd:25 rj:25 i12:8
( $AAAC42CD08 ) $10B9AD add.d, rd:13 rj:13 rk:14
( $AAAC42CD0C ) $270002CD stptr.d, rd:13 rj:22 i14:0
( $AAAC42CD10 ) $28FFE32E ld.d, rd:14 rj:25 i12:-8
( $AAAC42CD14 ) $4C0001C0 jirl, rd:0 rj:14 i12:0
( $AAAC42CD18 ) $28FFE32E ld.d, rd:14 rj:25 i12:-8
( $AAAC42CD1C ) $4C0001C0 jirl, rd:0 rj:14 i12:0
( $AAAC42CD20 ) $4C0001C0 jirl, rd:0 rj:14 i12:0
( $AAAC42CD24 ) $270003D9 stptr.d, rd:25 rj:30 i14:0
( $AAAC42CD28 ) $2600032D ldptr.d, rd:13 rj:25 i14:0
( $AAAC42CD2C ) $260002CE ldptr.d, rd:14 rj:22 i14:0
( $AAAC42CD30 ) $2C04339 addi.d, rd:25 rj:25 i12:16
( $AAAC42CD34 ) $10B9AD add.d, rd:13 rj:13 rk:14
( $AAAC42CD38 ) $270002CD stptr.d, rd:13 rj:22 i14:0
( $AAAC42CD3C ) $28FFE32E ld.d, rd:14 rj:25 i12:-8
( $AAAC42CD40 ) $4C0001C0 jirl, rd:0 rj:14 i12:0
end-code
Code -
( $AAADF08DF0 ) $270003D9 stptr.d, rd:25 rj:30 i14:0
( $AAADF08DF4 ) $28C022CD ld.d, rd:13 rj:22 i12:8
( $AAADF08DF8 ) $260002CE ldptr.d, rd:14 rj:22 i14:0
( $AAADF08DFC ) $2C022D6 addi.d, rd:22 rj:22 i12:8
( $AAADF08E00 ) $2C02339 addi.d, rd:25 rj:25 i12:8
( $AAADF08E04 ) $11B9AD sub.d, rd:13 rj:13 rk:14
( $AAADF08E08 ) $270002CD stptr.d, rd:13 rj:22 i14:0
( $AAADF08E0C ) $28FFE32E ld.d, rd:14 rj:25 i12:-8
( $AAADF08E10 ) $4C0001C0 jirl, rd:0 rj:14 i12:0
( $AAADF08E14 ) $28FFE32E ld.d, rd:14 rj:25 i12:-8
( $AAADF08E18 ) $4C0001C0 jirl, rd:0 rj:14 i12:0
( $AAADF08E1C ) $4C0001C0 jirl, rd:0 rj:14 i12:0
( $AAADF08E20 ) $270003D9 stptr.d, rd:25 rj:30 i14:0
( $AAADF08E24 ) $260002CD ldptr.d, rd:13 rj:22 i14:0
( $AAADF08E28 ) $2C02339 addi.d, rd:25 rj:25 i12:8
( $AAADF08E2C ) $11B40D sub.d, rd:13 rj:0 rk:13
( $AAADF08E30 ) $270002CD stptr.d, rd:13 rj:22 i14:0
( $AAADF08E34 ) $28FFE32E ld.d, rd:14 rj:25 i12:-8
( $AAADF08E38 ) $4C0001C0 jirl, rd:0 rj:14 i12:0
end-code
4.Gforth中code字以Code开始如下,(功能获取龙芯指令cpucfg配置信息,返回CFG字段信息)
code cpucfg ( rd rj -- cfg )
指令序列,需自行编辑,编辑好了再上传
end-code