Assembly ile Basit Toplama,Çıkartma,Çarpma ve Bölme Yapan Basit Bir Hesap Makinesi
Gönderilme zamanı: 08 Oca 2023 11:58
İşte iki sayı üzerinde toplama, çıkarma, çarpma ve bölme işlemlerini yapabilen x86 derleme dilinde basit bir hesap makinesi programı :
Kod: Tümünü seç
section .data
section .text
global _start
_start:
; Print a message to ask the user to enter two numbers
mov eax, 4
mov ebx, 1
mov ecx, message
mov edx, len
int 0x80
; Read in the first number
mov eax, 3
mov ebx, 0
mov ecx, number1
mov edx, len
int 0x80
; Read in the second number
mov eax, 3
mov ebx, 0
mov ecx, number2
mov edx, len
int 0x80
; Convert the numbers from ASCII to integers
mov eax, [number1]
sub eax, '0'
mov ebx, [number2]
sub ebx, '0'
; Print a message to ask the user to choose an operation
mov eax, 4
mov ebx, 1
mov ecx, op_message
mov edx, op_len
int 0x80
; Read in the operation
mov eax, 3
mov ebx, 0
mov ecx, operation
mov edx, 1
int 0x80
; Perform the chosen operation
cmp byte [operation], '+'
je add
cmp byte [operation], '-'
je sub
cmp byte