Live data from Hacker News

Asm-declaration – Embed assembly language code within a C++ program (2017)

en.cppreference.com

11–20 of 53 posts

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#11
In a string literal?!?! We did better almost 40 years ago..., this is assembly in turbo pascal:

  procedure init; assembler;
  asm
    mov ax,13h
    int 10h
  end;
You can even have only the asm block in a regular pascal function and make use of regular arguments in the asm block.

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#12

In a string literal?!?! We did better almost 40 years ago..., this is assembly in turbo pascal: procedure init; assembler; asm mov ax,13h int 10h end; You can even have only the asm block in a regular pascal function and make use of regular arguments in the asm block.

It gives me nostalgia seeing mode 13 graphics. What's next, mode x? Triangle drawing routines? :)

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#13
post #4

Odd bit of news reporting on something that was part of a standard published in 1997. What's next, breaking news on a standard 7-bit code used by Americans for information interchange?

This is a link to a reference page, not a news report.

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#14

In a string literal?!?! We did better almost 40 years ago..., this is assembly in turbo pascal: procedure init; assembler; asm mov ax,13h int 10h end; You can even have only the asm block in a regular pascal function and make use of regular arguments in the asm block.

For some cultural reason C and C++ compilers for UNIX do it the hard way.

PC compilers always followed that path.

The same in Turbo C would be:

    void init()
    {
        asm {
            mov ax, 0x13
            int 0x10
        }
    }

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#16
post #2

Old, well-known feature of one of the most popular languages. I must be missing something, because I have no idea how this became a hacker "news" :)

Hacker News Guidelines

What to Submit

On-Topic: Anything that good hackers would find interesting. That includes more than hacking and startups. If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity.

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#17
post #14

In a string literal?!?! We did better almost 40 years ago..., this is assembly in turbo pascal: procedure init; assembler; asm mov ax,13h int 10h end; You can even have only the asm block in a regular pascal function and make use of regular arguments in the asm block.

For some cultural reason C and C++ compilers for UNIX do it the hard way. PC compilers always followed that path. The same in Turbo C would be: void init() { asm { mov ax, 0x13 int 0x10 } }

Also Rust uses strings for asm. It can't be bad.

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#18
post #2

Old, well-known feature of one of the most popular languages. I must be missing something, because I have no idea how this became a hacker "news" :)

It's not technically a feature of the language, as it is not standardized and is compiler-specific.

But thing you are talking about indeed recurs here. The way I typically guess is that new generations of programmers are coming up all the time and may be unfamiliar with some old stuff. Or, maybe even some experienced people who never happened to touch c or c++ [there are more of those as time goes on].

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#19
post #14

Earlier quoted context omitted.

For some cultural reason C and C++ compilers for UNIX do it the hard way. PC compilers always followed that path. The same in Turbo C would be: void init() { asm { mov ax, 0x13 int 0x10 } }

Also Rust uses strings for asm. It can't be bad.

Rust stdlib uses strings because it's just piping through to LLVM and that's what LLVM expects: http://llvm.org/docs/LangRef.html#inline-assembler-expressio...

There's also a Rust version of Dynasm.

Re: Asm-declaration – Embed assembly language code within a C++ program (2017)

#20
post #12

In a string literal?!?! We did better almost 40 years ago..., this is assembly in turbo pascal: procedure init; assembler; asm mov ax,13h int 10h end; You can even have only the asm block in a regular pascal function and make use of regular arguments in the asm block.

It gives me nostalgia seeing mode 13 graphics. What's next, mode x? Triangle drawing routines? :)

next, we implement bresenham's algorithms, then we embed antialiasing.
Post reply on HN