😈ASM1 - Linux
Task1:

;nasm -f elf helloWorld.asm
;ld -m elf_i386 -s -o helloWorld helloWorld.o
section .data
msg db "Hello Kinabler", 0xa
len equ $-msg
section .text
global _start
_start:
mov edx, len
mov ecx, msg
mov ebx, 0x1
mov eax, 0x4
int 0x80
mov eax, 0x1
int 0x80
Task2:

;nasm -f elf input.asm
;ld -m elf_i386 -s -o input input.o
section .data
msg1 db "Input anythings here: ",0xa
len1 equ $-msg1
msg2 db "Your String entered: ", 0xa
len2 equ $-msg2
section .bss
buffer resb 32
section .text
global _start
_start:
mov eax, 0x4
mov ebx, 0x1
mov ecx, msg1
mov edx, len1
int 0x80
mov eax, 0x3
mov ebx, 0x0
mov ecx, buffer
mov edx, 32
int 0x80
mov eax, 0x4
mov ebx, 0x1
mov ecx, msg2
mov edx, len2
int 0x80
mov eax, 0x4
mov ebx, 0x1
mov ecx, buffer
mov edx, 32
int 0x80
mov eax, 0x1
int 0x80
Task3:

section .data
msg1 db "Input anythings here: ",0xa
len1 equ $-msg1
msg2 db "Your String entered: ", 0xa
len2 equ $-msg2
section .bss
buffer resb 0x20
section .text
global _start
_start:
;print out messege 1
mov eax, 0x4
mov ebx, 0x1
mov ecx, msg1
mov edx, len1
int 0x80
; receive strings
mov eax, 0x3
mov ebx, 0x0
mov ecx, buffer
mov edx, 0x20
int 0x80
; convert to Upper case:
mov ecx, 0x20
mov ebx, 0x0
mov esi, buffer
l1:
push ecx
cmp byte [esi+ebx], 0
je end_loop
cmp byte [esi+ebx], 'a'
jl end_loop
cmp byte [esi+ebx], 'z'
jg end_loop
sub byte [esi+ebx], 0x20
inc ebx
pop ecx
loop l1
end_loop:
;end a loop
; print out messege 2
mov eax, 0x4
mov ebx, 0x1
mov ecx, msg2
mov edx, len2
int 0x80
; print out strings entered
mov eax, 0x4
mov ebx, 0x1
mov ecx, buffer
mov edx, 0x20
int 0x80
mov eax, 0x1
int 0x80
compare byte-to-byte of a buffer: use byte
key. For example:
add byte [eax], 0x18 ;add byte at address, that saved in eax with value: 0x18.
Task4:

section .data
num1 dd 0x0
num2 dd 0x0
sum dd 0x0
msg1 db "Enter 2 number positive integer: ", 0xa
len1 equ $-msg1
msg2 db "Sum of 2 entered number: "
len2 equ $-msg2
newline db 0xa
section .bss
buffer resd 0x5
section .text
global _start
_start:
;print out message 1
mov eax, 0x4
mov ebx, 0x1
mov ecx, msg1
mov edx, len1
int 0x80
;Process number 1
mov eax, 0x3
mov ebx, 0x0
mov ecx, buffer
mov edx, 0x5
int 0x80
cmp eax, 0
je exit
cmp byte [buffer], 0x2d ;check "-" char
je exit
mov eax, dword [buffer]
mov dword [num1], eax
;Process Number 2
mov eax, 0x3
mov ebx, 0x0
mov ecx, buffer
mov edx, 0x5
int 0x80
cmp eax, 0
je exit
cmp byte [buffer], 0x2d
je exit
mov eax, dword [buffer]
mov dword [num2], eax
;print out message 2
mov eax, 0x4
mov ebx, 0x1
mov ecx, msg2
mov edx, len2
int 0x80
;Calculate 2 numbers
mov eax, [num2]
mov ebx, [num1]
add eax, ebx
mov dword [sum], eax
mov ecx, 0x4
mov esi, 0x3
l1:
push ecx
sub byte [sum+esi], 0x30
dec esi
pop ecx
loop l1
;print sum
mov eax, 0x4
mov ebx, 0x1
mov ecx, sum
mov edx, 0x4
int 0x80
;endline
mov eax, 0x4
mov ebx, 0x1
mov ecx, newline
mov edx, 0x1
int 0x80
exit:
mov eax, 0x1
int 0x80
Last updated