Moving and consolidating repos
This commit is contained in:
BIN
x86_64/Input Output Scripts/Basic IO/basic_io
Executable file
BIN
x86_64/Input Output Scripts/Basic IO/basic_io
Executable file
Binary file not shown.
39
x86_64/Input Output Scripts/Basic IO/basic_io.asm
Normal file
39
x86_64/Input Output Scripts/Basic IO/basic_io.asm
Normal file
@@ -0,0 +1,39 @@
|
||||
sction .data
|
||||
prompt db 'Please enter your name: ', 0 ; Null-terminated prompt message
|
||||
promptLen equ $ - prompt ; Length of the prompt message
|
||||
|
||||
buffer db 128 dup(0) ; Buffer for the input
|
||||
bufferLen equ 128 ; Maximum buffer length
|
||||
|
||||
section .bss
|
||||
name resb 128 ; Reserve buffer for name
|
||||
|
||||
section .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
; Print prompt
|
||||
mov eax, 4 ; sys_write syscall
|
||||
mov ebx, 1 ; File descriptor 1 - stdout
|
||||
mov ecx, prompt ; Pointer to the message to print
|
||||
mov edx, promptLen ; Message length
|
||||
int 0x80 ; Call the kernel
|
||||
|
||||
; Read input
|
||||
mov eax, 3 ; sys_read syscall
|
||||
mov ebx, 0 ; File descriptor 0 - stdin
|
||||
mov ecx, buffer ; Pointer to the input buffer
|
||||
mov edx, bufferLen ; Maximum number of bytes to read
|
||||
int 0x80 ; Call the kernel
|
||||
|
||||
; Print greeting
|
||||
mov eax, 4 ; sys_write syscall
|
||||
mov ebx, 1 ; File descriptor 1 - stdout
|
||||
mov ecx, buffer ; Pointer to the buffer to print
|
||||
; Use the number of bytes read as the length to write
|
||||
int 0x80 ; Call the kernel
|
||||
|
||||
; Exit program
|
||||
mov eax, 1 ; sys_exit syscall
|
||||
xor ebx, ebx ; Exit code 0
|
||||
int 0x80 ; Call the kernel
|
||||
BIN
x86_64/Input Output Scripts/Basic IO/basic_io.o
Normal file
BIN
x86_64/Input Output Scripts/Basic IO/basic_io.o
Normal file
Binary file not shown.
BIN
x86_64/Input Output Scripts/Calculator/add
Executable file
BIN
x86_64/Input Output Scripts/Calculator/add
Executable file
Binary file not shown.
61
x86_64/Input Output Scripts/Calculator/addition.asm
Normal file
61
x86_64/Input Output Scripts/Calculator/addition.asm
Normal file
@@ -0,0 +1,61 @@
|
||||
section .data
|
||||
numberone db 'Enter fst number: ', 0 ; Null terminated string
|
||||
numbertwo db 'Enter snd number: ', 0 ; Null terminated string
|
||||
numonelen equ $ - numberone ; length of prompt 1
|
||||
numtwolen equ $ - numbertwo ; length of prompt 2
|
||||
|
||||
section .bss
|
||||
numone resb 128 ; reserve for number 1 input
|
||||
numtwo resb 128 ; reserve for number 2 input
|
||||
result resb 128 ; reserve for result of addition
|
||||
section .text
|
||||
global _start
|
||||
_start:
|
||||
; Number 1 prompt
|
||||
mov eax, 4 ; sys_write syscall in 32 bit registry eax
|
||||
mov ebx, 1 ; Stdout syscall in 32 bit registry ebx
|
||||
mov ecx, numberone ; move null terminated string to 32 bit registry ecx
|
||||
mov edx, numtwolen ; length of null terminated (value) moved to 32 bit registry edx
|
||||
int 0x80 ; Interrupt kernel, reset
|
||||
|
||||
; Number 1 Read
|
||||
mov eax, 3 ; Sys_read sysclal in 32 bit registry
|
||||
mov ebx, 0 ; stdin file descriptor in 32 bit regstry
|
||||
mov ecx, numone ; pointer for input
|
||||
mov edx, 128 ; maxomim number of bytes to Read
|
||||
int 0x80 ; Interrupt kernel, reset
|
||||
|
||||
; Number 2 prompt
|
||||
mov eax, 4
|
||||
mov ebx, 1
|
||||
mov ecx, numbertwo
|
||||
mov edx, numtwolen
|
||||
int 0x80
|
||||
|
||||
; Number 2 Read
|
||||
mov eax, 3
|
||||
mov ebx, 0
|
||||
mov ecx, numtwo
|
||||
mov edx, 128
|
||||
int 0x80
|
||||
|
||||
|
||||
; Print result
|
||||
mov eax, 4 ; Sys_write syscall for 32 bit register eax
|
||||
mov ebx, 1 ; Stdout
|
||||
mov ecx, numone
|
||||
int 0x80
|
||||
|
||||
mov eax, 4
|
||||
mov ebx, 1
|
||||
mov ecx, numtwo
|
||||
int 0x80
|
||||
|
||||
; exit
|
||||
mov eax, 1 ; sys_exit
|
||||
xor ebx, ebx ; exit with code 0
|
||||
int 0x80
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
x86_64/Input Output Scripts/Calculator/adds.o
Normal file
BIN
x86_64/Input Output Scripts/Calculator/adds.o
Normal file
Binary file not shown.
BIN
x86_64/Input Output Scripts/get_user_input/name
Executable file
BIN
x86_64/Input Output Scripts/get_user_input/name
Executable file
Binary file not shown.
49
x86_64/Input Output Scripts/get_user_input/name.asm
Normal file
49
x86_64/Input Output Scripts/get_user_input/name.asm
Normal file
@@ -0,0 +1,49 @@
|
||||
section .data
|
||||
prompt db "What is your name? ", 10
|
||||
output1 db "Hello, "
|
||||
|
||||
section .bss
|
||||
input resb 34
|
||||
|
||||
section .text
|
||||
global _start
|
||||
|
||||
_start:
|
||||
call _getInput
|
||||
call _printOutput1
|
||||
call _printInput
|
||||
mov rax, 60
|
||||
mov rdi, 0
|
||||
syscall
|
||||
|
||||
_getInput:
|
||||
mov rax, 0
|
||||
mov rdi, 0
|
||||
mov rsi, input
|
||||
mov rdx, 34 ; related to resb
|
||||
syscall
|
||||
ret
|
||||
|
||||
_printPrompt:
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, prompt
|
||||
mov rdx, 20 ; change for size of bytes reserved
|
||||
syscall
|
||||
ret
|
||||
|
||||
_printOutput1:
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, output1
|
||||
mov rdx, 7 ; change for size of db
|
||||
syscall
|
||||
ret
|
||||
|
||||
_printInput:
|
||||
mov rax, 1
|
||||
mov rdi, 1
|
||||
mov rsi, input
|
||||
mov rdx, 34 ; change for resb
|
||||
syscall
|
||||
ret
|
||||
BIN
x86_64/Input Output Scripts/get_user_input/name.o
Normal file
BIN
x86_64/Input Output Scripts/get_user_input/name.o
Normal file
Binary file not shown.
Reference in New Issue
Block a user