EvilZone
Programming and Scripting => Assembly - Embedded => : $Clone March 19, 2015, 11:21:47 AM
-
hi.....am new to asm so i wanted to do a simple 1+2=3 and get the output three but it seems i can't get what i want :( .....there are no syntax error but maybe register but i can't seem to pin point the place.
section .text
global _start
_start:
mov eax,1
add eax,2
mov ebx,1
mov eax,4
int 0x80
mov eax,1
int 0x80
so i thought maybe save the result so:
section .text
global _start
_start:
mov eax,1
add eax,2
mov [result],eax
mov ebx,1
mov eax,4
mov ecx,result
mov ebx,1
int 0x80
mov eax,1
int 0x80
section .bss
result resb 1
help :-\ ....
-
section .bss
datVariable resb 4
section .text
global _start
_start:
mov eax, 1 ;wuts this a number?
mov ebx, 2 ; wut, another one?
add eax,ebx ; shit's getting cray
add eax, 30h ;here be black magic
mov [datVariable], eax ;black magic also here
mov eax, 4 ;dat syscall
mov ebx, 1 ;dat fd
mov ecx, datVariable ;The lack of [] is important yo
mov edx, 1 ;dat length tho
int 0x80 ;you got this from here?
mov eax, 1 ;coo
mov ebx, 0 ;i'd really hate to explain it
int 0x80 ;bye bye for now
orrr if you wanna use the stack directly instead of the bss section..
section .text
global _start
_start:
mov eax, 1 ;wuts this a number?
mov ebx, 2 ; wut, another one?
add eax,ebx ; shit's getting cray
add eax, 30h ;here be black magic
push eax ;different type of black magic
mov eax, 4 ;dat syscall
mov ebx, 1 ;dat fd
mov ecx, esp ;wut is dis? A potential problem? of course it is.
mov edx, 1 ;dat length tho
int 0x80 ;you got this from here?
mov eax, 1 ;coo
mov ebx, 0 ;i'd really hate to explain it
int 0x80 ;bye bye for now
tl;dr you weren't dealing with an ascii value and you were trying to print the address of 3, not an address where 3 was.