Sample 3: Full Assembly Translation
This sample demonstrates how to use the source code porting function of the Kunpeng Porting Advisor to perform full assembly translation.
Scanning the Source Code
- Download the source package from GitHub or Gitee to obtain the code sample.
The downloaded source package is devkitdemo-main.zip. The ./devkitdemo-main/Porting_advisor/testdemo/asm_trans/all_asm file extracted from the package is the code to be scanned for porting.
- Before porting the source code, compile the original code on the x86 platform. Go to the source code directory, for example, demo_all_asm.Run make to compile and generate the binary file target. Execute target and the result is generated. See Figure 1.
If the following error information is displayed during the compilation process, ignore it.

- Log in to the Kunpeng DevKit. In the navigation pane on the left, choose Porting Advisor > Source Code Porting. The page for creating a source code porting task is displayed.
Select Architecture source code porting for Source Code Porting and click Upload to upload the downloaded all_asm folder. Select other options as required. See Figure 2.
- Click Start. Figure 3 shows an example report.
Modifying the Source Code
- Click View Suggested Code on the page of the source code porting report. See Figure 4.
- Under File list on the left, switch between files to view the source code modification suggestions, as shown in Figure 5:
- Modify the file based on the report. On the Source Code Porting Suggestions page, check the modification suggestions and modify the source code accordingly.
On the Source Code Porting Suggestions page, view the suggestions for modifying the test.s file. See Figure 6.
Click Quick Fix > Replace with Suggested Code to modify the code. See the following figure:
Figure 7 New code 1
Figure 8 New code 2
Figure 9 New code 3
- Modify the file based on the report. On the Source Code Porting Suggestions page, check the modification suggestions and modify the source code based on the suggestions.
On the Source Code Porting Suggestions page, view the suggestions for modifying the Makefile file, as shown in Figure 8:
Figure 10 Suggestions for modifying Makefile
According to the preceding suggestions, add the option FLAGS = -fsigned-char to the compile command in Makefile.
Figure 11 Code after modification:
Compiling the Code
- Use an SSH tool to remotely log in to the server. Run the following command to go to the directory where the source code is stored:
cd /opt/DevKit/workspace/devadmin/porting/sourcecode/all_asm
/opt: tool installation directory. Replace it with the actual directory.
- Run the make command to compile the source code. The binary file target is generated, producing the same compilation result as on the x86 platform. This indicates that the source code has been successfully ported, as shown in Figure 12:
test.s is an assembly file generated after quick fix is performed in the Kunpeng Porting Advisor. Compile the file on the Kunpeng platform. If the file execution results on the Kunpeng platform and x86 platform are the same, the source code is successfully ported.






