Tulisan Dasar Cracking
Selamat Datang................. Cracker..........
Bahasa Assembler :

Variable
Variable adalah lokasi suatu memori. Untuk seorang programmer lebih mudah menyimpan nilai sebuah varible dengan nama "var1" daripada menyimpannya dialamat 5A73:235B, terutama bila kamu mempunyai 10 variable atau lebih.

kompiler kita mendukung 2 tipe variable yaitu : BYTE dan WORD.

Kode penulisan variable:

nama DB nilai

nama DW nilai

DB - untuk Define Byte.
DW - untuk Define Word.

nama - dapat berupa huruf atau kombinasi angka yang berawalan dengan huruf. It's possible to declare unnamed variables by not specifying the name (this variable will have an address but no name).

value - can be any numeric value in any supported numbering system (hexadecimal, binary, or decimal), or "?" symbol for variables that are not initialized.


Seperti catatan sebelumnya bahwa, perintah MOV biasa digunakan untuk menyalin suatu nilai dari asalnya kesuatu tempat.
Sebagai contoh perintah MOV :


#MAKE_COM#
ORG 100h

MOV AL, var1
MOV BX, var2

RET    ; menghentikan program.

VAR1 DB 7
var2 DW 1234h


Salin semua kode diatas ke Emu8086 editor, terus tekan F5 untuk mengkompiledan menjalankan di emulator. Tampilannya akan seperti dibawah ini:



Seperti yang terlihat dicontoh, except that variables are replaced with actual memory locations. Ketika kompiler membuat kode mesin, it automatically replaces all variable names with their offsets. By default segment is loaded in DS register (when COM files is loaded the value of DS register is set to the same value as CS register - code segment).

In memory list first row is an offset, second row is a hexadecimal value, third row is decimal value, and last row is an ASCII character value.

Compiler is not case sensitive, so "VAR1" and "var1" refer to the same variable.

The offset of VAR1 is 0108h, and full address is 0B56:0108.

The offset of var2 is 0109h, and full address is 0B56:0109, this variable is a WORD so it occupies 2 BYTES. It is assumed that low byte is stored at lower address, so 34h is located before 12h.

You can see that there are some other instructions after the RET instruction, this happens because disassembler has no idea about where the data starts, it just processes the values in memory and it understands them as valid 8086 instructions (we will learn them later).
You can even write the same program using DB directive only:


#MAKE_COM#
ORG 100h

DB 0A0h
DB 08h
DB 01h

DB 8Bh
DB 1Eh
DB 09h
DB 01h

DB 0C3h

DB 7

DB 34h
DB 12h


Kopi kode diatas ke Emu8086 kode editor, terus tekan F5 untuk memproses dan dijalankan diemulator. Kamu akan mendapatkan kode disassembler yang sama, dan fungsinya!

As you may guess, the compiler just converts the program source to the set of bytes, this set is called machine code, processor understands the machine code and executes it.

ORG 100h is a compiler directive (it tells compiler how to handle the source code). This directive is very important when you work with variables. It tells compiler that the executable file will be loaded at the offset of 100h (256 bytes), so compiler should calculate the correct address for all variables when it replaces the variable names with their offsets. Directives are never converted to any real machine code.
Why executable file is loaded at offset of 100h? Operating system keeps some data about the program in the first 256 bytes of the CS (code segment), such as command line parameters and etc.
Though this is true for COM files only, EXE files are loaded at offset of 0000, and generally use special segment for variables. Maybe we'll talk more about EXE files later.

WebMaster
Terus      Kembali
Komentar dan Mailing List
Crack One Software Every Day Make You The Real Cracker