-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
420 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Copyright (C) 2025, Yasumasa Suenaga | ||
This file is part of ffmasm. | ||
ffmasm is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
ffmasm is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public Licensealong with ffmasm. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.yasuenag</groupId> | ||
<artifactId>ffmasm-disas-example</artifactId> | ||
<version>0.1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>ffmasm-disas-example</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<mainClass>com.yasuenag.ffmasm.examples.disas.Main</mainClass> | ||
<imageName>${project.artifactId}-${project.version}</imageName> | ||
<maven.compiler.source>22</maven.compiler.source> | ||
<maven.compiler.target>22</maven.compiler.target> | ||
</properties> | ||
|
||
<repositories> | ||
<repository> | ||
<id>github</id> | ||
<url>https://maven.pkg.github.com/YaSuenag/ffmasm</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.yasuenag</groupId> | ||
<artifactId>ffmasm</artifactId> | ||
<version>0.5.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.yasuenag</groupId> | ||
<artifactId>ffmasm-disassembler</artifactId> | ||
<version>0.1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.13.0</version> | ||
<configuration> | ||
<compilerArgs> | ||
<arg>-Xlint:all</arg> | ||
</compilerArgs> | ||
<debug>true</debug> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.4.2</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>${mainClass}</mainClass> | ||
</manifest> | ||
<manifestEntries> | ||
<Enable-Native-Access>ALL-UNNAMED</Enable-Native-Access> | ||
</manifestEntries> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>3.5.0</version> | ||
<configuration> | ||
<mainClass>${mainClass}</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
50 changes: 50 additions & 0 deletions
50
examples/disas/src/main/java/com/yasuenag/ffmasm/examples/disas/Main.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2025 Yasumasa Suenaga | ||
* | ||
* This file is part of ffmasm. | ||
* | ||
* ffmasm is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* ffmasm is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with ffmasm. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.yasuenag.ffmasm.examples.disas; | ||
|
||
import java.lang.foreign.*; | ||
import java.util.*; | ||
|
||
import com.yasuenag.ffmasm.*; | ||
import com.yasuenag.ffmasm.amd64.*; | ||
|
||
import com.yasuenag.ffmasmtools.disas.Disassembler; | ||
|
||
|
||
public class Main{ | ||
|
||
public static MemorySegment createRDTSC() throws Exception{ | ||
var seg = new CodeSegment(); | ||
return AMD64AsmBuilder.create(AMD64AsmBuilder.class, seg) | ||
/* push %rbp */ .push(Register.RBP) | ||
/* mov %rsp, %rbp */ .movMR(Register.RSP, Register.RBP, OptionalInt.empty()) | ||
/* rdtsc */ .rdtsc() | ||
/* shl $32, %rdx */ .shl(Register.RDX, (byte)32, OptionalInt.empty()) | ||
/* or %rdx, %rax */ .orMR(Register.RDX, Register.RAX, OptionalInt.empty()) | ||
/* leave */ .leave() | ||
/* ret */ .ret() | ||
.getMemorySegment(); | ||
} | ||
|
||
public static void main(String[] args) throws Exception{ | ||
var rdtsc = createRDTSC(); | ||
Disassembler.dumpToStdout(rdtsc); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- | ||
Copyright (C) 2025, Yasumasa Suenaga | ||
This file is part of ffmasm. | ||
ffmasm is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
ffmasm is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with ffmasm. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.yasuenag</groupId> | ||
<artifactId>ffmasm-disassembler</artifactId> | ||
<version>0.1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>ffmasm-disassembler</name> | ||
|
||
<scm> | ||
<connection>scm:git:git://github.com/YaSuenag/ffmasm.git</connection> | ||
<developerConnection>scm:git:ssh://github.com:YaSuenag/ffmasm.git</developerConnection> | ||
<url>https://github.com/YaSuenag/ffmasm</url> | ||
</scm> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>22</maven.compiler.source> | ||
<maven.compiler.target>22</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.yasuenag</groupId> | ||
<artifactId>ffmasm</artifactId> | ||
<version>0.5.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.10.1</version> | ||
<configuration> | ||
<compilerArgs> | ||
<arg>-Xlint:all</arg> | ||
</compilerArgs> | ||
<debug>true</debug> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.4.1</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<distributionManagement> | ||
<repository> | ||
<id>github</id> | ||
<name>GitHub Packages</name> | ||
<url>https://maven.pkg.github.com/YaSuenag/ffmasm</url> | ||
</repository> | ||
</distributionManagement> | ||
</project> |
Oops, something went wrong.