+ 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?
12 Respuestas
+ 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
+ 8
Dear VeryHard,
You disappointed me!
+ 8
Yeah dear. That's the kind of syntax that SL C++ compiler accepts. Unfortunately, most of us just worked with Intel based ASM.
+ 8
Yeah Martin,
Intrestingly, some people believe that Assembly programers are the only real programmers!
+ 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.
+ 4
Hmmm....? What kind of that assembler?
+ 4
AT&T Syntax (x86)
+ 4
Oh well I'm similar to Intel Syntax not the syntax like that
+ 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
+ 3
(I rarely happen to program asm)
+ 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?