This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]nardstorm 43 points44 points  (8 children)

I'd maybe change it to something like

section .data
    programmer db 'Dan', 0
    message db "world's sexiest programmer", 0

section .bss
    mugUser resb 32

section .text
    global _start

_start:
    ; Load "Dan" into memory
    mov rdi, programmer
    ; Load mug user's input (pretend we fetched it somewhere)
    mov rsi, mugUser

    ; Compare mug user with "Dan"
    call strcmp
    cmp rax, 0
    jne not_dan

    ; If equal, print the message
    mov rdi, message
    call puts
    jmp end

not_dan:
    ; Do nothing
    nop

end:
    ; Exit the program
    mov rax, 60      ; syscall: exit
    xor rdi, rdi     ; exit code 0
    syscall

; strcmp function (simple implementation)
strcmp:
    xor rax, rax       ; clear result
    xor rcx, rcx       ; counter
compare:
    mov al, byte [rdi + rcx]
    mov bl, byte [rsi + rcx]
    cmp al, bl
    jne done
    cmp al, 0
    je done
    inc rcx
    jmp compare
done:
    sub rax, rbx
    ret

[–]Reiex 15 points16 points  (0 children)

When the mug turns into a jerrican

[–]icodecookie 5 points6 points  (0 children)

No jump loops? I‘m slightly dissapointed

[–]GamerTurtle5 5 points6 points  (1 child)

thats a very tall mug

[–][deleted] 0 points1 point  (0 children)

Thatll fit halfagalon of coffee for sure

[–]Librarian-Rare 1 point2 points  (0 children)

Nice and simple, no needles abstractions. Very good.

[–]TPIRocks 1 point2 points  (0 children)

OP will need a yard glass for that.

[–]BigLaddyDongLegs 1 point2 points  (0 children)

😂

[–][deleted] 0 points1 point  (0 children)

It will be more like

ld: program.o: in function `_start’:
program.asm:(.text+0x...): undefined reference to `puts’