diff options
| author | Camille Mougey <camille.mougey@cea.fr> | 2015-01-21 17:46:26 +0100 |
|---|---|---|
| committer | Camille Mougey <camille.mougey@cea.fr> | 2015-01-23 17:24:43 +0100 |
| commit | 7ce340c2e62d985e92c42add8ffc385d54360a91 (patch) | |
| tree | 920c6d567ba941b92a4aba3cfeec72c0e80bf92c | |
| parent | 9206458e0f4b815e4af68f8978d96d14632a087f (diff) | |
| download | miasm-7ce340c2e62d985e92c42add8ffc385d54360a91.tar.gz miasm-7ce340c2e62d985e92c42add8ffc385d54360a91.zip | |
Example/ASM: Extract asm sources to sample dir
| -rw-r--r-- | example/samples/arm_sc.S | 17 | ||||
| -rw-r--r-- | example/samples/arm_simple.S | 24 | ||||
| -rw-r--r-- | example/samples/armt.S | 27 | ||||
| -rw-r--r-- | example/samples/mips32.S | 12 | ||||
| -rw-r--r-- | example/samples/msp430.S | 8 | ||||
| -rw-r--r-- | example/samples/x86_32_enc.S | 38 | ||||
| -rw-r--r-- | example/samples/x86_32_manip_ptr.S | 50 | ||||
| -rw-r--r-- | example/samples/x86_64.S | 13 |
8 files changed, 189 insertions, 0 deletions
diff --git a/example/samples/arm_sc.S b/example/samples/arm_sc.S new file mode 100644 index 00000000..e9a0787f --- /dev/null +++ b/example/samples/arm_sc.S @@ -0,0 +1,17 @@ +main: + MOV R1, R0 + MOV R2, 0x100 + LDR R3, [PC, mykey1-$] +loop: + ADD R2, R1, R2 + ADD R1, R1, 1 + LDR R3, [PC, mykey2-$] + CMP R1, R3 + BEQ loop + + ADD R0, R1, R2 + BX LR +mykey1: +.long 0x1 +mykey2: +.long 0x2 diff --git a/example/samples/arm_simple.S b/example/samples/arm_simple.S new file mode 100644 index 00000000..f6dcf81e --- /dev/null +++ b/example/samples/arm_simple.S @@ -0,0 +1,24 @@ +main: + STMFD SP!, {R4, R5, LR} + MOV R0, mystr & 0xffff + ORR R0, R0, mystr & 0xffff0000 + MOV R4, R0 + MOV R1, mystrend & 0xffff + ORR R1, R1, mystrend & 0xffff0000 +xxx: + LDRB R2, [PC, key-$] +loop: + LDRB R3, [R0] + EOR R3, R3, R2 + STRB R3, [R0], 1 + CMP R0, R1 + BNE loop +end: + MOV R0, R4 + LDMFD SP!, {R4, R5, PC} +key: +.byte 0x11 +mystr: +.string "test string" +mystrend: +.long 0 diff --git a/example/samples/armt.S b/example/samples/armt.S new file mode 100644 index 00000000..c50075a6 --- /dev/null +++ b/example/samples/armt.S @@ -0,0 +1,27 @@ +memcpy: + PUSH {R0-R3, LR} + B test_end +loop: + LDRB R3, [R1] + STRB R3, [R0] + ADDS R0, R0, 1 + ADDS R1, R1, 1 + SUBS R2, R2, 1 +test_end: + CMP R2, 0 + BNE loop + POP {R0-R3, PC} +main: + PUSH {LR} + SUB SP, 0x100 + MOV R0, SP + ADD R1, PC, mystr-$+6 + MOV R0, R0 + EORS R2, R2 + ADDS R2, R2, 0x4 + BL memcpy + ADD SP, 0x100 + POP {PC} + +mystr: +.string "toto" diff --git a/example/samples/mips32.S b/example/samples/mips32.S new file mode 100644 index 00000000..ae44d52f --- /dev/null +++ b/example/samples/mips32.S @@ -0,0 +1,12 @@ +main: + ADDIU A0, ZERO, 0x10 + ADDIU A1, ZERO, 0 +loop: + ADDIU A1, A1, 0x1 + BNE A0, ZERO, loop + ADDIU A0, A0, 0xFFFFFFFF + + ADDIU A2, A2, 0x1 + MOVN A1, ZERO, ZERO + JR RA + ADDIU A2, A2, 0x1 diff --git a/example/samples/msp430.S b/example/samples/msp430.S new file mode 100644 index 00000000..77f4b448 --- /dev/null +++ b/example/samples/msp430.S @@ -0,0 +1,8 @@ +main: + mov.w 0x10, R10 + mov.w 0x0, R11 +loop: + add.w 1, R11 + sub.w 1, R10 + jnz loop + mov.w @SP+, PC diff --git a/example/samples/x86_32_enc.S b/example/samples/x86_32_enc.S new file mode 100644 index 00000000..92379838 --- /dev/null +++ b/example/samples/x86_32_enc.S @@ -0,0 +1,38 @@ +main: + CALL cipher_code + CALL msgbox_encrypted_start + CALL cipher_code + RET + +cipher_code: + PUSH EBP + MOV EBP, ESP + + LEA ESI, DWORD PTR [msgbox_encrypted_start] + LEA EDI, DWORD PTR [msgbox_encrypted_stop] + +loop: + XOR BYTE PTR [ESI], 0x42 + INC ESI + CMP ESI, EDI + JBE loop + + MOV ESP, EBP + POP EBP + RET + +msgbox_encrypted_start: + PUSH 0 + PUSH title + PUSH msg + PUSH 0 + CALL DWORD PTR [ MessageBoxA ] + RET +.dontsplit +msgbox_encrypted_stop: +.long 0 + +title: +.string "Hello!" +msg: +.string "World!" diff --git a/example/samples/x86_32_manip_ptr.S b/example/samples/x86_32_manip_ptr.S new file mode 100644 index 00000000..43e4ed73 --- /dev/null +++ b/example/samples/x86_32_manip_ptr.S @@ -0,0 +1,50 @@ +main: + PUSH EBP + MOV EBP, ESP + SUB ESP, 0x100 + MOV EAX, 0x1337 + ; test ptr manip + LEA ESI, DWORD PTR [mystr^toto] + CALL toto +mystr: +.string "test string" + toto: + POP EDI + + PUSH EDI + ; test scasb + XOR EAX, EAX + XOR ECX, ECX + DEC ECX + REPNE SCASB + NOT ECX + DEC ECX + + ; test movsb + POP ESI + LEA EDI, DWORD PTR [EBP-0x100] + REPE MOVSB + + ; test float + PUSH 0 + FLD1 + FLD1 + FADD ST, ST(1) + FIST DWORD PTR [ESP] + POP EAX + + ; test cond mnemo + NOP + NOP + CMOVZ EAX, EBX + ; test shr + NOP + SHR EAX, 1 + NOP + NOP + SHR EAX, CL + NOP + + MOV ESP, EBP + POP EBP + RET diff --git a/example/samples/x86_64.S b/example/samples/x86_64.S new file mode 100644 index 00000000..d090a01b --- /dev/null +++ b/example/samples/x86_64.S @@ -0,0 +1,13 @@ +main: + MOV R9, 0x0 + MOV R8, title + MOV RDX, msg + MOV RCX, 0x0 + MOV RAX, QWORD PTR [ MessageBoxA ] + CALL RAX + RET + +title: +.string "Hello!" +msg: +.string "World!" |