+ 2

is there any faster way to "Hello, world!\n" ?

.section .data msg: .ascii "Hello, world!\n" .section .text .global _start _start: movl $4, %eax # syscall 4 (write) in eax movl $1, %ebx # fd of stdout (1) in ebx as first argument leal msg, %ecx # string as second argument movl $14, %edx # string length as third argument int $0x80 # interrupt xor %eax, %eax # clear eax movl $1, %eax # syscall 1 (exit) in eax int $0x80 # interrupt Is there any way to print "Hello, world!\n" which is faster than doing it in asm?

29th Aug 2017, 1:12 PM
Michael Vigato
Michael Vigato - avatar
11 Respostas
+ 10
Why not Michael. I didn't do so much inline stuff but it certainly makes your code faster in order to do its job, especially complex one. Here I have an inline ASM but I don't think it makes so difference just for an addition operation. https://code.sololearn.com/c6TMOWzn7kC4/?ref=app
30th Aug 2017, 5:59 AM
Babak
Babak - avatar
+ 8
Dear VeryHard, You disappointed me!
29th Aug 2017, 1:53 PM
Babak
Babak - avatar
+ 8
Yeah dear. That's the kind of syntax that SL C++ compiler accepts. Unfortunately, most of us just worked with Intel based ASM.
29th Aug 2017, 2:00 PM
Babak
Babak - avatar
+ 8
Yeah Martin, Intrestingly, some people believe that Assembly programers are the only real programmers!
29th Aug 2017, 5:51 PM
Babak
Babak - avatar
+ 8
I see Michael, I think nowadays, ASM usage has confined to some special cases such as optimization or critical routines of a bigger system.
29th Aug 2017, 6:03 PM
Babak
Babak - avatar
+ 4
Hmmm....? What kind of that assembler?
29th Aug 2017, 1:38 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 4
AT&T Syntax (x86)
29th Aug 2017, 1:42 PM
Michael Vigato
Michael Vigato - avatar
+ 4
Oh well I'm similar to Intel Syntax not the syntax like that
29th Aug 2017, 1:57 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 4
You can write directly to video memory (technically, buffers). This displays "Hi" in one instruction: mov [0xb8000], 0x07690748 edit: 0x07 is grey(7) on black(0). 0x69 is 'i', 0x48 is 'H'. If I recall correctly, that's little-endian byte order (and not a reverse string). Source: http://wiki.osdev.org/Printing_To_Screen
29th Aug 2017, 2:07 PM
Kirk Schafer
Kirk Schafer - avatar
+ 3
(I rarely happen to program asm)
29th Aug 2017, 5:55 PM
Michael Vigato
Michael Vigato - avatar
+ 3
I've learned about asm Inline used to write asm lines inside a C program (guess it works on C++/C# as well). isn't it a reasonably good way to make elaboration faster?
30th Aug 2017, 5:45 AM
Michael Vigato
Michael Vigato - avatar