I am using OpenSUSE Leap latest version and my kernel version is Linux 5.3.18-59.19-default I start learning Assembly out of curiosity and I was following the tutorial on the tutorialspoint I accidentally wrote the code wrong and the code should have output the number I gave but instead of doing that code put the number I gave to the command line and pressed enter then I tried inputting 'neofetch' and it worked I just accidentally hacked myself great! I thought if I run the code as root it will execute the code as root but that didn't happened, only way I can run the inputted commands as root is when I run the code in the root terminal otherwise I have to add 'sudo' to the command I inputted which has no difference If I am the root why not just run the command but I am curious why did the command line did something which it shouldn't have done in the first place.
I wrote 'section .bbs' instead of 'section .bss' and compiler gave a warning but compiled the code that section of the code is like this:
Can anyone explain to me what just happened here?
The code that should have printed the num variable:
I wrote 'section .bbs' instead of 'section .bss' and compiler gave a warning but compiled the code that section of the code is like this:
Code:
section .data ;Data segment
userMsg db 'Please enter a number: ' ;Ask the user to enter a number
lenUserMsg equ $-userMsg ;The length of the message
dispMsg db 'You have entered: '
lenDispMsg equ $-dispMsg
section .bbs ; instead of 'section .bss'
num resb 5
Can anyone explain to me what just happened here?
The code that should have printed the num variable:
Code:
;Read and store the user input
mov eax, 3
mov ebx, 2
mov ecx, num
mov edx, 5 ;5 bytes (numeric, 1 for sign) of that information
int 80h
;Output the message 'The entered number is: '
mov eax, 4
mov ebx, 1
mov ecx, dispMsg
mov edx, lenDispMsg
int 80h