Skip to content
Permalink
Browse files

aarch64: Test aarch64 instruction with cc-rs in rust

Addition of two numbers in aarch64 using cc-rs compiling in rust.
Compiled and Executed Sucessfully
Output:
$ Finished dev [unoptimized + debuginfo] target(s) in 0.06s
$ Running `target/debug/aarch64`
$ 5
  • Loading branch information
vibhoothiiaanand committed Jun 27, 2019
1 parent 69f12b8 commit 1d885629c3930119bda1e7a8b8982948cade5965
Showing with 39 additions and 0 deletions.
  1. +10 −0 aarch64/Cargo.toml
  2. +8 −0 aarch64/build.rs
  3. +13 −0 aarch64/src/add.s
  4. +8 −0 aarch64/src/main.rs
@@ -0,0 +1,10 @@
[package]
name = "aarch64"
version = "0.1.0"
authors = ["vibhoothi <vibhoothiiaanand@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cc = "1.0"
@@ -0,0 +1,8 @@
#![feature(rustc_private)]
extern crate cc;

fn main() {
cc::Build::new()
.file("src/add.s")
.compile("my-asm-lib");
}
@@ -0,0 +1,13 @@
// add,s

.text

.globl main_addr
/*
Addition of two numbers
*/
main_addr:
mov w0, #2
mov w1, #3
add w0, w0, w1
ret
@@ -0,0 +1,8 @@
extern "C" {
fn main_addr() -> u32;
}

fn main() {
let sum = unsafe { main_addr() };
println!("{}", sum);
}

0 comments on commit 1d88562

Please sign in to comment.
You can’t perform that action at this time.