section .data
prompt1 db "Key in the first number : ", 0
prompt2 db "Key in the second number : ", 0
result1 db "The total is ", 0
result2 db "The division result is ", 0
result3 db "The remainder value is ", 0
newline db 10, 0
section .bss
num1 resb 2
num2 resb 2
section .text
global _start
_start:
; Display prompt for first number
mov eax, 4
mov ebx, 1
mov ecx, prompt1
mov edx, 23
int 0x80
; Read first number
mov eax, 3
mov ebx, 0
mov ecx, num1
mov edx, 2
int 0x80
; Display prompt for second number
mov eax, 4
mov ebx, 1
mov ecx, prompt2
mov edx, 24
int 0x80
; Read second number
mov eax, 3
mov ebx, 0
mov ecx, num2
mov edx, 2
int 0x80
; Convert first number to integer
mov al, [num1]
sub al, '0'
mov [num1], al
; Convert second number to integer
mov al, [num2]
sub al, '0'
mov [num2], al
; Calculate multiplication
mov al, [num1]
mul byte [num2]
mov [num1], al
; Display multiplication result
mov eax, 4
mov ebx, 1
mov ecx, result1
mov edx, 13
int 0x80
mov al, [num1]
add al, '0'
mov [num1], al
mov ecx, num1
mov edx, 1
int 0x80
; Display newline
mov eax, 4
mov ebx, 1
mov ecx, newline
mov edx, 1
int 0x80
; Calculate division
mov al, [num1]
div byte [num2]
mov [num1], al
; Display division result
mov eax, 4
mov ebx, 1
mov ecx, result2
mov edx, 16
int 0x80
mov al, [num1]
add al, '0'
mov [num1], al
mov ecx, num1
mov edx, 1
int 0x80
; Display newline
mov eax, 4
mov ebx, 1
mov ecx, newline
mov edx, 1
int 0x80
; Calculate remainder
mov al, [num1]
mov ah, 0
div byte [num2]
mov [num1], ah
; Display remainder
mov eax, 4
mov ebx, 1
mov ecx, result3
mov edx, 17
int 0x80
mov al, [num1]
add al, '0'
mov [num1], al
mov ecx, num1
mov edx, 1
int 0x80
; Display newline
mov eax, 4
mov ebx, 1
mov ecx, newline
mov edx, 1
int 0x80
; Exit program
mov eax, 1
xor ebx, ebx
int 0x80
CgpzZWN0aW9uIC5kYXRhCiAgICBwcm9tcHQxIGRiICJLZXkgaW4gdGhlIGZpcnN0IG51bWJlciA6ICIsIDAKICAgIHByb21wdDIgZGIgIktleSBpbiB0aGUgc2Vjb25kIG51bWJlciA6ICIsIDAKICAgIHJlc3VsdDEgZGIgIlRoZSB0b3RhbCBpcyAiLCAwCiAgICByZXN1bHQyIGRiICJUaGUgZGl2aXNpb24gcmVzdWx0IGlzICIsIDAKICAgIHJlc3VsdDMgZGIgIlRoZSByZW1haW5kZXIgdmFsdWUgaXMgIiwgMAogICAgbmV3bGluZSBkYiAxMCwgMAoKc2VjdGlvbiAuYnNzCiAgICBudW0xIHJlc2IgMgogICAgbnVtMiByZXNiIDIKCnNlY3Rpb24gLnRleHQKICAgIGdsb2JhbCBfc3RhcnQKCl9zdGFydDoKICAgIDsgRGlzcGxheSBwcm9tcHQgZm9yIGZpcnN0IG51bWJlcgogICAgbW92IGVheCwgNAogICAgbW92IGVieCwgMQogICAgbW92IGVjeCwgcHJvbXB0MQogICAgbW92IGVkeCwgMjMKICAgIGludCAweDgwCgogICAgOyBSZWFkIGZpcnN0IG51bWJlcgogICAgbW92IGVheCwgMwogICAgbW92IGVieCwgMAogICAgbW92IGVjeCwgbnVtMQogICAgbW92IGVkeCwgMgogICAgaW50IDB4ODAKCiAgICA7IERpc3BsYXkgcHJvbXB0IGZvciBzZWNvbmQgbnVtYmVyCiAgICBtb3YgZWF4LCA0CiAgICBtb3YgZWJ4LCAxCiAgICBtb3YgZWN4LCBwcm9tcHQyCiAgICBtb3YgZWR4LCAyNAogICAgaW50IDB4ODAKCiAgICA7IFJlYWQgc2Vjb25kIG51bWJlcgogICAgbW92IGVheCwgMwogICAgbW92IGVieCwgMAogICAgbW92IGVjeCwgbnVtMgogICAgbW92IGVkeCwgMgogICAgaW50IDB4ODAKCiAgICA7IENvbnZlcnQgZmlyc3QgbnVtYmVyIHRvIGludGVnZXIKICAgIG1vdiBhbCwgW251bTFdCiAgICBzdWIgYWwsICcwJwogICAgbW92IFtudW0xXSwgYWwKCiAgICA7IENvbnZlcnQgc2Vjb25kIG51bWJlciB0byBpbnRlZ2VyCiAgICBtb3YgYWwsIFtudW0yXQogICAgc3ViIGFsLCAnMCcKICAgIG1vdiBbbnVtMl0sIGFsCgogICAgOyBDYWxjdWxhdGUgbXVsdGlwbGljYXRpb24KICAgIG1vdiBhbCwgW251bTFdCiAgICBtdWwgYnl0ZSBbbnVtMl0KICAgIG1vdiBbbnVtMV0sIGFsCgogICAgOyBEaXNwbGF5IG11bHRpcGxpY2F0aW9uIHJlc3VsdAogICAgbW92IGVheCwgNAogICAgbW92IGVieCwgMQogICAgbW92IGVjeCwgcmVzdWx0MQogICAgbW92IGVkeCwgMTMKICAgIGludCAweDgwCgogICAgbW92IGFsLCBbbnVtMV0KICAgIGFkZCBhbCwgJzAnCiAgICBtb3YgW251bTFdLCBhbAogICAgbW92IGVjeCwgbnVtMQogICAgbW92IGVkeCwgMQogICAgaW50IDB4ODAKCiAgICA7IERpc3BsYXkgbmV3bGluZQogICAgbW92IGVheCwgNAogICAgbW92IGVieCwgMQogICAgbW92IGVjeCwgbmV3bGluZQogICAgbW92IGVkeCwgMQogICAgaW50IDB4ODAKCiAgICA7IENhbGN1bGF0ZSBkaXZpc2lvbgogICAgbW92IGFsLCBbbnVtMV0KICAgIGRpdiBieXRlIFtudW0yXQogICAgbW92IFtudW0xXSwgYWwKCiAgICA7IERpc3BsYXkgZGl2aXNpb24gcmVzdWx0CiAgICBtb3YgZWF4LCA0CiAgICBtb3YgZWJ4LCAxCiAgICBtb3YgZWN4LCByZXN1bHQyCiAgICBtb3YgZWR4LCAxNgogICAgaW50IDB4ODAKCiAgICBtb3YgYWwsIFtudW0xXQogICAgYWRkIGFsLCAnMCcKICAgIG1vdiBbbnVtMV0sIGFsCiAgICBtb3YgZWN4LCBudW0xCiAgICBtb3YgZWR4LCAxCiAgICBpbnQgMHg4MAoKICAgIDsgRGlzcGxheSBuZXdsaW5lCiAgICBtb3YgZWF4LCA0CiAgICBtb3YgZWJ4LCAxCiAgICBtb3YgZWN4LCBuZXdsaW5lCiAgICBt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