Programming
Casual
558

Cara membuat program keputusan di asm?






  14-Jan-2022 00:46:29



Permisi bang bagaimana cara membuat program if else atau keputusan di asm? Gwe baca artikel

https://blog.seccodeid.com/2021/12/belajar-asm-untuk-basic-reverse.html Gwe dah bisa buat hello world lalu cara buat program keputusan di asm seperti apa?

*Beware click the link!


DISCUSSION

Wah terima kasih sudah membaca, jujur saya juga masih mempelajari ASM, hmm menurut saya bahasa ini susah saya juga masih bingung dengan bahasa ini, untuk membuat keputusan atau if else sebenarnya asm tidak menggunakan itu, tetapi menggunakan Jump if Condition Is Met (jcc)

https://www.felixcloutier.com/x86/jcc 

Jadi nanti kamu buat penamaan atau insial label nah nanti kami tinggal panggil dengan je. Contoh

Untuk compile bisa menggunakan gcc 

 gcc input.S -o input -nostartfiles -nostdlib 
 .section .rodata
/**
 * Readonly data
 */
str1: .asciz "Enter the input (A-B) : "
str2: .asciz "Option A"
str3: .asciz "Otpion B"
str4: .asciz "No command"

.section .text

.global _start

/**
 * %rdi is the first argument.
 * %rsi is the second argument.
 *
 * ssize_t write_str(void *rdi, size_t len);
 */
write_str:
    movl  $1, %eax
    movq  %rsi, %rdx
    movq  %rdi, %rsi
    movl  $1, %edi
    syscall
    retq

_start:
    pushq %rbp
    movq  %rsp, %rbp
    subq  $32, %rsp

    leaq  str1(%rip), %rdi
    movl  $24, %esi
    callq write_str

    movl  $0, %eax
    movl  $0, %edi
    movq  %rsp, %rsi
    movl  $31, %edx
    syscall

    movb  (%rsp), %al
    cmpb  $'A', %al
    je    a_case
    cmpb  $'B', %al
    je    b_case

    leaq  str4(%rip), %rdi
    movl  $10, %esi
    callq write_str

exit:
    movl  $60, %eax
    xorl  %edi, %edi
    syscall

a_case:
    leaq  str2(%rip), %rdi
    movl  $8, %esi
    callq write_str
    jmp   exit

b_case:
    leaq  str3(%rip), %rdi
    movl  $8, %esi
    callq write_str
    jmp   exit
/**
* Readonly data
*/
str1: .asciz "Enter the input (A-B) : "
str2: .asciz "Option A"
str3: .asciz "Otpion B"
str4: .asciz "No command" .section .text .global _start /**
* %rdi is the first argument.
* %rsi is the second argument.
*
* ssize_t write_str(void *rdi, size_t len);
*/
write_str:
movl $1, %eax
movq %rsi, %rdx
movq %rdi, %rsi
movl $1, %edi
syscall
retq _start:
pushq %rbp
movq %rsp, %rbp
subq $32, %rsp leaq str1(%rip), %rdi
movl $24, %esi
callq write_str movl $0, %eax
movl $0, %edi
movq %rsp, %rsi
movl $31, %edx
syscall movb (%rsp), %al
cmpb $'A', %al
je a_case
cmpb $'B', %al
je b_case leaq str4(%rip), %rdi
movl $10, %esi
callq write_str exit:
movl $60, %eax
xorl %edi, %edi
syscall a_case:
leaq str2(%rip), %rdi
movl $8, %esi
callq write_str
jmp exit b_case:
leaq str3(%rip), %rdi
movl $8, %esi
callq write_str
jmp exit 



Reply


14-Jan-2022 00:58:54



Oh ya bang misalnya gwe mau mendalami ini hal penting apa yang harus gwe pelajari?


Reply


14-Jan-2022 01:01:23



Itu kamu pakai architecture apa? Itu kode di atas saya pakai x86 jika punya kamu berbeda silahkan bisa disesuaikan 

https://github.com/torvalds/linux 

*Doc ata panduan 


Untuk bahan yang dipelajari menurut saya banyak, saya pribadi masih belum menguasai tapi silahkan bisa kunjungi link di bawah ini 

 

# x86-64 ISA documentaion

https://www.felixcloutier.com/x86/ 

# System V ABI x86-64

https://gitlab.com/x86-psABIs 

Saran saya coba bahasa C aja hehehe. Bahasa C aja kek b**i 

Reply


14-Jan-2022 01:03:22



asm bisa digabung dengan c?


Reply


14-Jan-2022 01:07:38



Setahu saya bisa

Contoh

int main(void)
{
    char str[] = "Check!\n";

    __asm__ volatile(
      "syscall"
      :
      : "a"(1), "S"(str), "D"(1), "d"(13)
      : "memory", "rcx", "r11"
    );
}
Compile pakai gcc 

https://www.codeproject.com/Articles/15971/Using-Inline-Assembly-in-C-C 



Reply


14-Jan-2022 01:09:23



Boleh gw tanya ke lu tentang asm? Les privat bang gwe bayarin deh lu

Reply


14-Jan-2022 01:10:26



Join discrod server gw bang sekarang lo bisa ajarin g?


Reply


14-Jan-2022 01:12:57



Saya gak punya discord :) 


Reply


14-Jan-2022 01:13:48



Lagian hari ini sudah malam, saya masih ada pekerjaan untuk mipil UAS jadi saya rasa hari ini tidak bisa. Kalau pun kamu belejar ASM saya tidak bisa saya menolak hehehe


Reply


14-Jan-2022 01:19:25



Bang gw gak bisa akses chat

Reply


14-Jan-2022 01:20:20



Buat lolikey dulu, harus import private key, pub key, passphrase baru bisa akses

Reply


14-Jan-2022 01:12:34



Waduh saya masih belejar belum bisa ajarin. Kalau mau belejar seputar Web, OSINT, Jaringan, C dan C++. Saya masih bisa ngajarin 


Reply


14-Jan-2022 01:04:25



Cara cek architecturenya gimna bang?


Reply


14-Jan-2022 01:06:31



Pakai command bisa juga GUI 

uname -m  

Reply


19-Jan-2022 21:17:49



Ajarin saya ngoding dong kak


Reply


20-Jan-2022 01:50:05



Boleh mau belajar apa? Tanya aja disini free kok, kalau malu contact saya lewat Tele

https://t.me/bayjie 

Jangan lupa subs. https://t.me/seccodeid


Reply

Login for report, comment and join discussion
Login Here
Sponsored

Popular Posts
Gps Tracker Seccodeid Free Too...
General
21354
204
Top


Djie sam soe Djie sam soe
Complete Basic Course in Kali...
Linux
14373
4
Top


Djie sam soe Djie sam soe
Komintod (Ministry of Communic...
Data Leak
6511
94
Top


Murtad methamphetamine Murtad methamphetamine
Free Proxy List
Networking
3625
3
Top


Sandidi Sandidi
Mass Reverse IP Unlimited
Tools Hacking
3393
15
Top


ImamWawe ImamWawe

Related Post

Youtube Video

Subscribe