參考資訊:
http://www.winprog.org/tutorial/start.html
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
經典的Hello, world!程式框架總是能夠讓人細心品味一款程式語言的美好,司徒就使用一個簡單的Message對話盒來展現Hello, world!框架
main.s
.global WinMain .extern MessageBoxA .extern ExitProcess .data szCaption: .asciz "main" szContent: .asciz "Hello, world!" .text WinMain: stp x29, x30, [sp, #-0x10]! mov x0, 0 ldr x1, =szContent ldr x2, =szCaption mov x3, 0 bl MessageBoxA mov x0, 0 bl ExitProcess mov x0, 0 ldp x29, x30, [sp], #0x10 ret
Line 1:程式進入點
Line 2~3:external function
Line 5:初始化的資料區段
Line 6~7:初始化的Global變數,型態是byte(char)且最後一個byte是0
Line 13~17:顯示Message對話盒
Line 19~20:結束Process並且釋放相關資源
編譯、執行
$ winegcc main.s -o main $ wine ./main.exe