Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

ASM Print - Assembly Code Bank


ASM Print
Just a program that prints out the first argument
                section .text:
        global mystrlen ; int mystrlen(char* buf);
        global myprint   ; void myprint(char* buf);
        global _start      ; int _start(int argc, char* argv[])

; esp+4 = buf
mystrlen:
        xor eax,eax
        dec eax
        mov ebx,[esp+4]
        strloop:
                inc eax
                cmp [ebx+eax],byte 0
                jne strloop
        ret
; esp+4 = buf
myprint:
        mov ecx,[esp+4]
        push ecx
        call mystrlen
        mov edx,eax
        mov eax,4
        mov ebx,1
        int 80h
        pop ecx
        ret
_start:
        pop eax ; argc
        cmp eax,2 ; if(argc != 2) { end(); }
        jne end
        pop eax ; argv[0] - program name
        pop eax ; argv[1] - first argument
        push eax
        call myprint ; myprint(argv[1]);
        end:
                mov eax,1
                mov  ebx,0
                int 80h ; return 0
            
Comments
binary_man's avatar
binary_man 9 years ago

?