LATEST POSTS - page 3


x86-64 TUTORIAL: MULTIPLICATION & DIVISION

In the Hello World sample program we had used the instructions REPNZ and SCASB to calculate the length of the string being printed at runtime. In this program we use NASM’s equ directive to calculate the length during assembly time as opposed to at runtime. The variable promptlen gives an example.

Read More
Posted on by Vikas N. Kumar.

x86-64 TUTORIAL: INPUT OUTPUT FUNCTIONS

Here are some print functions for strings, integers and newline characters. There is also a function for reading an integer. All the code is in NASM’s syntax. The macros prologue and epilogue, are used to save space and avoid repetitiveness.

NOTE: Remember that the registers RBP, RBX and R12-R15 need to be saved across function calls.

Read More
Posted on by Vikas N. Kumar.

x86-64 TUTORIAL: HELLO WORLD!

Below is a program that prints "Hello World!" on screen followed by a newline character. In the data section we first store the string "Hello World!", followed by the newline character which has an ASCII value of 10 and the NULL character or the value 0. The NULL character is used here because of the way we calculate the string length. There are other ways to calculate the string length as well, by using NASM’s directives like equ, but we shall use that in another sample program.

Read More
Posted on by Vikas N. Kumar.

x86-64 TUTORIAL: CPUID

The x86 and x86-64 instruction sets have an instruction called CPUID that tells the program who made the CPU and what features it may have. We try to get that info using x86-64 assembly in this tutorial.

Read More
Posted on by Vikas N. Kumar.

x86-64 TUTORIAL: CALLING CONVENTIONS

SYSTEM CALLS

System calls are made using the syscall instruction on an x86-64 version of GNU/Linux as opposed to using int 0x80 on an x86 version of GNU/Linux. All programs are in long mode. Depending on the type of GNU/Linux system you use, the list of system calls can be found in /usr/include/asm/unistd_64.h for Debian-based systems or in /usr/include/asm-x86_64/unistd.h for Slackware, etc.

Read More
Posted on by Vikas N. Kumar.

Pages: Newer  |  1  |  2  |  3  |  4  |  Older