Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hacker test's ASM
09-07-2009, 09:50 AM
Post: #1
Hacker test's ASM
So do we have any aspiring assembly programmers here...create an assembly program that will output a text string “this is the message to display\n” like this:

Quote:this is the message to display
his is the message to display
is is the message to display
s is the message to display
is the message to display
is the message to display
s the message to display
the message to display
the message to display
he message to display
e message to display
message to display
message to display
essage to display
ssage to display
sage to display
age to display
ge to display
e to display
to display
to display
o display
display
display
isplay
splay
play
lay
ay
y

Here's my solution in 64 bit Intel/AMD AT&T assembler...

Code:
.section .data
    mydata: .ascii "this is the message to display\n"
    .equ mylen, . - mydata
    mycount: .quad mylen

.section .text

printit:
        pushq    %rbp
        movq    %rsp, %rbp

        movq    $mydata, %rsi

tohere:

        movq    $1, %rax
        movq    $1, %rdi
        movq    mycount, %rdx
        syscall

        decq    mycount
        incq    %rsi

        cmpq    $1, mycount
        jle    endit
        jmp    tohere

endit:        movq    %rbp, %rsp
        popq    %rbp
        ret

.section .text
    .global _start
_start:
        call    printit

        movq    $60, %rax
        movq    $0, %rdi
        syscall
Find all posts by this user
Quote this message in a reply
09-07-2009, 04:28 PM
Post: #2
RE: Hacker test's ASM
I don't know much about assembler, but i can do this in several languages, just in a few lines of code.
Good task.

There's a fine line between genius and insanity. I have erased this line.
Oscar Levant
There's a fine line between an administrator and black hat hacker. I have erased this line.
Dr DEBCOL
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: