implementing macro in plan 9 assembly

331 views
Skip to first unread message

saurav deshpande

unread,
Oct 15, 2020, 12:42:10 PM10/15/20
to golang-nuts
How to implement  macro in plan9 assembly? I read the documentation of plan9 assembly but could not find it. Is there any alternative for macro in plan9?

Anthony Martin

unread,
Oct 15, 2020, 2:37:23 PM10/15/20
to saurav deshpande, golang-nuts
Assembly language source files are preprocessed just like C source.
The familiar #define and #include directives should work as expected.

Anthony

saurav deshpande

unread,
Oct 16, 2020, 6:19:55 AM10/16/20
to golang-nuts
Thank you for the reply.
I do not understand, actually I am trying to define the fuctions in plan9 assembly  whoes declaration is done in a go file. I want to use macro like the macro in nasm, but couldn't understand how to do it.
It would be very helpful if you could give an example.

Thank you.

Joop Kiefte

unread,
Oct 16, 2020, 8:09:33 AM10/16/20
to saurav.des...@gmail.com, golan...@googlegroups.com
I don't know how this should actually be done, but remember that the Go assembly is not actually Plan 9 assembly, it's an abstraction by itself, meant for internal use first and foremost.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/c779e51f-ff41-4686-a843-0830316383c3n%40googlegroups.com.

saurav deshpande

unread,
Oct 16, 2020, 8:30:29 AM10/16/20
to golang-nuts
So, is it possible to define functions declared in go and defined in nasm assembly? If yes then can you please share an example.

Thank you

Joop Kiefte

unread,
Oct 16, 2020, 8:36:34 AM10/16/20
to saurav.des...@gmail.com, golan...@googlegroups.com
I think you can use nasm assembly through inline ASM in cgo indirectly... Go supports writing .s-files written in Go's internal assembly format, which should be much faster than cgo to compile and is probably preferable, but needs a bit of learning.

q9zcd

saurav deshpande

unread,
Oct 16, 2020, 8:37:41 AM10/16/20
to golang-nuts
okay, Thank you 

Diego Joss

unread,
Oct 19, 2020, 1:12:45 PM10/19/20
to golang-nuts
Have a look at https://golang.org/doc/asm
and examples are always a good source of inspiration. For example https://golang.org/src/math/dim.go at line 35 defines the prototype for function Max, which is implemented in assembly in https://golang.org/src/math/dim_amd64.s

-- Diego

JX Zhang

unread,
Apr 9, 2021, 8:15:45 AM4/9/21
to golang-nuts
Go does can define functions in a plan9 style assembly file.
I have a question about how to compile a plan9 style asm file to an ELF .o object?
Reply all
Reply to author
Forward
0 new messages