Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> I've put the image code on github (...)

Thank you! It's interesting to see how similar this code is to assembly code calling OS procedures, after declaring them external - I've recently been playing (again) with assembly for the win64 arch, and one sample program (a mish-mash of example code available for nasm, fasm and "go" assembler - is rather similar IMNHO - note this just displays a window, no loading of (image) files):

  ; Assemble and link with:
  ;   nasm -f win64 .\hello-nasm.asm
  ;   golink .\hello-nasm.obj \
  ;     Kernel32.dll User32.dll /entry:WinMain

  global WinMain
  extern ExitProcess
  extern MessageBoxA

  section '.text'

  WinMain:
    sub rsp,8*5 ; reserve stack for API use and make
                ; stack dqword aligned

    xor rcx, rcx         ; uType = MB_OK
    lea rdx, [szCaption] ; LPCSTR lpCaption
    lea r8, [szTitle]    ; LPCSTR lpText
    xor r9d, r9d         ; hWnd = HWND_DESKTOP
    call MessageBoxA

    mov ecx,eax
    call ExitProcess

  section '.rdata'
  szTitle:   db 'Hello, Title!', 0
  szCaption: db 'Hello, World!', 0
The more things change...

nasm: http://www.nasm.us/ go linker (and assembler): http://godevtool.com/ (not to be confused with Google's "golang" Go programming language and tools.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: