flat assembler
Message board for the users of flat assembler.

Index > Main > Part of _start executing even after jumping:

Author
Thread Post new topic Reply to topic
naburgondux



Joined: 05 Sep 2024
Posts: 7
naburgondux 15 Oct 2024, 00:27
so the issue i have is pretty simple,i have a simple program here that prints hello,get user input,and compares the input to a string,it works fine,the only problem is that even after i jump to the right label,it continues to run things that were define in _start!,how can i fix this? Sad


MY CODE:


Code:
format ELF64
section '.text' executable
        public _start

IF_text_eq_ah:
        ;; PRINT("YES")
        mov rax, 1
        mov rdi, 1
        lea rsi, [yes]
        mov rdx, yes_s
        syscall
        ;; EXIT(0)
        mov rax, 60
        xor rdi, rdi   
        syscall

_start:
        ;; PRINT("HELLO!")
        mov rax, 1
        mov rdi, 1
        lea rsi, [hello]
        mov rdx, hello_s
        syscall

        ;; GET(STDIN, &TEXT)
        mov rax, 0
        mov rdi, 0
        lea rsi, [text]
        mov rdx, 3
        syscall
        ;; PRINT(&TEXT)
        mov rax, 1
        mov rdi, 1
        lea rsi, [text]
        mov rdx, 3
        syscall
        ;; IF(&TEXT == "AH")
        lea rdi, [text]
        lea rsi, [ahh]
        mov rcx, 2
        repe cmpsb
        je IF_text_eq_ah
        ;; PRINT("YOU DID NOT SAY AH")
        mov rax, 1
        mov rdi, 1
        lea rsi, [not_say]
        mov rdx, not_say_s
        syscall
        ;; EXIT(0)
        mov rax, 60
        xor rdi, rdi
        syscall

section '.data' writable
        hello: db "Hello!", 10,"Say whatever: "
        hello_s = $ - hello
        text: db 0, 0, 0
        ahh: db "ah"
        yes: db "YES",10
        not_say: db "You did not say ah", 10
        not_say_s = $ - not_say
        yes_s = $ - yes
    


Last edited by naburgondux on 15 Oct 2024, 02:56; edited 1 time in total
Post 15 Oct 2024, 00:27
View user's profile Send private message Visit poster's website Reply with quote
naburgondux



Joined: 05 Sep 2024
Posts: 7
naburgondux 15 Oct 2024, 02:53
so,i forgot to specify what it was outputting,
here it is:


Code:
Hello!
Say whatever: ah
ah
YES
You did not say ah : (
    
Post 15 Oct 2024, 02:53
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1011
Location: Russia
macomics 15 Oct 2024, 13:39
Code:
section '.data' writable
        hello: db "Hello!", 10,"Say whatever: "
        hello_s = $ - hello
        text: db 80 dup 0, 0 ; <--
        ahh: db "ah"
        yes: db "YES",10
        yes_s = $ - yes ; <---
        not_say: db "You did not say ah", 10
        not_say_s = $ - not_say
;       yes_s = $ - yes    
Post 15 Oct 2024, 13:39
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.