Feeds:
Posts
Comments

Archive for December 4th, 2018

In this article, I will show you assembly command for arithmetic function.

INC
It’s increase ‘operand’ by 1 (one).
Syntax

INC destination

Type the codes below and save it to ‘inc.asm’. It’s a very simple program. It will increase the value in variable num by 1 from 2 to 3.

1 section .text
2 global _start
3 _start:
4
5 ;put number in num
6 mov eax,2
7 mov [num],eax
8 inc byte [num]
9
10 ;exit
11 mov eax,1
12 mov ebx,[num]
13 int 0x80
14
15 section .data
16 num db 0
17

Compile and run the program.

$ nasm -f elf32 inc.asm -o inc.o
$ ld inc.o -o inc
$ echo $?
0
$ ./inc
$ echo $?
3
$


(more…)

Read Full Post »