Current location - Trademark Inquiry Complete Network - Futures platform - How to profit from commodity futures trading; Global securities investment
How to profit from commodity futures trading; Global securities investment
At compile time, we use the "-f elf" option to tell NASM assembler the target file in elf format that we want to generate. This example should explain exactly why these registers are universal.

Next, let's look at the use of EAX as a logical accumulation. That is, in four operations, an operand can be stored in the EAX register. Let's not discuss addition and subtraction. Let's look at multiplication and division. In the division operation, the dividend is stored in EAX register by default; When multiplying, by default, a number is also placed in the EAX register, and the final product is still saved in EAX by default. Take multiplication as an example:

Click (here) to collapse or open.

; mul.asm

Extern printf, exit; We call the printf and exit functions of the C library in the assembly, so we should declare the printf and exit with the extern keyword.

Part. Data; data field

var 1: dd 40

var2: dd 20

fmt: db "result=%d ", 10,0; Printf format, "\n", "0"

Part. Text; Code snippet.

Global _ Start

_start:

mov eax,[var 1]; Multiplier 1

mov ebx,[var 2]; Multiplier 2

Mul ebx performs multiplication and the result is stored in EAX register.

Push eax, and the result is EAX.

Push the address of dword fmtctrl string

Call printf and call c function

Press dword 0.

Call exit