LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Assembly language Hello World not working (https://www.linuxquestions.org/questions/programming-9/assembly-language-hello-world-not-working-4175610855/)

Fractal Cat 07-29-2017 09:49 AM

Assembly language Hello World not working
 
Hi,

I have been using the SASM assembly language editor for a couple of days now and I've found a number of programs on the net to display a Hello World message. I have tried a number of these and none of them output anything at all. Below is an example of the code I've found :

.intel_syntax noprefix

.bss

.data

msg:
.asciz "Hello, world!\n\r"
.equ len, 15

.text

.global _start

_start:
push rbp
mov ebp,esp
mov edx,len
mov ecx,msg
mov ebx,1
mov eax,4
int 0x80
pop rbp
mov eax,1
int 0x80
.end

Another thing I want is to output all files, source, object files and so on to the same folder when assembling. How do I do this, because when the object file is assembled it outputs to the folder /tmp/SASM and not my folder ?

Thanks

FC.

BW-userx 07-29-2017 12:33 PM

here is a show me

Hello, world!


SASM: The Simple Assembler
Reference Manual


In care of google. ;)

that is all I know about it , sorry :(

Fractal Cat 07-31-2017 10:05 AM

Sorted
 
Hi,

After much hair pulling concerning this problem I thought I would try the NASM assembler instead of the GCC
assembler and the programs work, albeit with a little bit of tweaking. So I will continue using NASM when writing assembly language coding in Linux.

FC.

BW-userx 07-31-2017 10:29 AM

Quote:

Originally Posted by Fractal Cat (Post 5742132)
Hi,

After much hair pulling concerning this problem I thought I would try the NASM assembler instead of the GCC
assembler and the programs work, albeit with a little bit of tweaking. So I will continue using NASM when writing assembly language coding in Linux.

FC.

:thumbsup:

pls - mark solved. cheers! :hattip:

Fat_Elvis 08-09-2017 10:21 AM

For 64 bit, you might want syscall, instead of int 0x80.

Code:

        movq        $1, %rax                # syscall: write.
        movq        $1, %rdi                # File descriptor: stdout.
        movq        $msg, %rsi        # String pointer.
        movq        $0x0E, %rdx        # String length.

        syscall

        movq        $0x3C, %rax        # syscall: exit.
        movq        $0, %rbx                # Return value.

        syscall


Jjanel 08-10-2017 07:52 AM

You don't really need an OS, just <446 bytes in the boot sector :D
https://www.google.com/search?q=bios+hello+world Wiki is your friend!
Now, that's what I'd enjoy doing :eek:

BW-userx 08-10-2017 09:22 AM

Quote:

Originally Posted by Jjanel (Post 5746686)
You don't really need an OS, just <446 bytes in the boot sector :D
https://www.google.com/search?q=bios+hello+world Wiki is your friend!
Now, that's what I'd enjoy doing :eek:

Writing Hello World Bootloader interesting.


All times are GMT -5. The time now is 03:55 PM.