How to Use assembly language in WebOS

Source: Internet
Author: User

To use the Assembly Language in WebOS, you need to use the PDK given by HP. For more information, see this address: https://developer.palm.com/content/api/dev-guide/pdk/overview.html.

If you are developing a PDK, you can find the PDK path on the user interface. If it is under Mac, it will be loaded into/OPT. Because this path cannot be displayed in the finder, you can use the Unix CP command to copy the/opt/palmpdk directory to the display location in the finder, this facilitates editing, compilation, and debugging.

Suppose I put this directory under/users/zenny_chen. You can open palmpdk and see some sample code provided by HP in the share/samplecode/directory. Let's start with simple.

1. Open terminal under your Mac OS X. Note that you should first set your location to the Mac directory in the simple example. CD/users/zenny_chen/palmpdk/share/samplecode/simple/MAC/

2. Set the project directory and compiler directory like android. In Mac OS X, there is a compilation template bash file -- buildit_for_device.sh. Therefore, we can easily compile and connect to this project by modifying this bash file. In terminal, enter Path = "/users/zenny_chen/palmpdk/ARM-gcc/bin"

Export path

Palmpdk = "/users/zenny_chen/palmpdk"

Export palmpdk

3. After completion, we can add the new Assembly source file -- hey. s under the src directory and edit it:

.text
.align 4
.arm

.globl my_real_arm


my_real_arm:

add r0, r0, #256
vmov q0, q1
vdup.32 q0, r0

bx lr

4. Add extern "C" int my_real_arm (INT dummy) to simple. cpp, and then call it in a function.

5. Modify the buildit_for_device.sh file.

First, we need to add hey. S. Let's add a symbol -- src2, enter: Export src2 = "Hey. s" under export src = "Simple. cpp"

Note that there cannot be spaces before and after the equal sign (=.

Then, we find $ CC $ deviceopts $ cppflags $ ldflags $ libs-o $ builddir/$ OUTFILE $ srcdir/$ SRC at the end.

Change it to $ CC $ deviceopts $ cppflags $ ldflags $ libs-o $ builddir/$ OUTFILE $ srcdir/$ SRC $ srcdir/$ src2

After saving the information, run./buildit_for_device.sh pre in terminal.

We will add pre later to tell the script that we use the armv7a architecture to enable the neon feature. If there is no pre, the script will be compiled using the arm11 option.

If you see an error in mkdir, manually add the build_device directory in the Mac directory before executing the script.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.