x86 inline asm support
MODIFY
src/inline_asm.rs
src/inline_asm.rs
@@ -493,6 +493,10 @@ fn generate_asm_wrapper(&self, asm_name: &str) -> String {
fn prologue(generated_asm: &mut String, arch: InlineAsmArch) {
match arch {
+ InlineAsmArch::X86 => {
+ generated_asm.push_str(" push ebp\n");
+ generated_asm.push_str(" mov ebp,[esp+8]\n");
+ }
InlineAsmArch::X86_64 => {
generated_asm.push_str(" push rbp\n");
generated_asm.push_str(" mov rbp,rdi\n");
@@ -503,6 +507,10 @@ fn prologue(generated_asm: &mut String, arch: InlineAsmArch) {
fn epilogue(generated_asm: &mut String, arch: InlineAsmArch) {
match arch {
+ InlineAsmArch::X86 => {
+ generated_asm.push_str(" pop ebp\n");
+ generated_asm.push_str(" ret\n");
+ }
InlineAsmArch::X86_64 => {
generated_asm.push_str(" pop rbp\n");
generated_asm.push_str(" ret\n");
@@ -513,7 +521,7 @@ fn epilogue(generated_asm: &mut String, arch: InlineAsmArch) {
fn epilogue_noreturn(generated_asm: &mut String, arch: InlineAsmArch) {
match arch {
- InlineAsmArch::X86_64 => {
+ InlineAsmArch::X86 | InlineAsmArch::X86_64 => {
generated_asm.push_str(" ud2\n");
}
_ => unimplemented!("epilogue_noreturn for {:?}", arch),
@@ -527,6 +535,11 @@ fn save_register(
offset: Size,
) {
match arch {
+ InlineAsmArch::X86 => {
+ write!(generated_asm, " mov [ebp+0x{:x}], ", offset.bytes()).unwrap();
+ reg.emit(generated_asm, InlineAsmArch::X86, None).unwrap();
+ generated_asm.push('\n');
+ }
InlineAsmArch::X86_64 => {
write!(generated_asm, " mov [rbp+0x{:x}], ", offset.bytes()).unwrap();
reg.emit(generated_asm, InlineAsmArch::X86_64, None).unwrap();
@@ -543,6 +556,11 @@ fn restore_register(
offset: Size,
) {
match arch {
+ InlineAsmArch::X86 => {
+ generated_asm.push_str(" mov ");
+ reg.emit(generated_asm, InlineAsmArch::X86, None).unwrap();
+ writeln!(generated_asm, ", [ebp+0x{:x}]", offset.bytes()).unwrap();
+ }
InlineAsmArch::X86_64 => {
generated_asm.push_str(" mov ");
reg.emit(generated_asm, InlineAsmArch::X86_64, None).unwrap();

x86 inline asm support