0

To preface, I am taking systems programming at the local university. We are using Ubuntu on vBox to assemble with yasm and run our programs. I have functioning code, but I believe the vm overhead is causing issues with timing execution. We are working on a threaded program.

I would like to assemble and run the program on my native win7 installation, but get a link error. The commands I am using on windows are:

yasm -f x64 hw12.asm
ld -o hw12.exe hw12.obj

It assembles, but when I link I get hw12.obj: file not recognized: File format not recognized

Here is version information:

yasm --version
yasm 1.3.0
Compiled on Aug 17 2014.
Copyright (c) 2001-2014 Peter Johnson and other Yasm developers.
Run yasm --license for licensing overview and summary.

ld --version
GNU ld (GNU Binutils) 2.25.1
Copyright (C) 2014 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

A related question, I don't know if it will solve the issue or not (I assume not):

I currently hard code the constants and syscall codes in section .data. Here is the code for reference:

section .data

; -----
;  Define standard constants.

LF          equ 10          ; line feed
NULL        equ 0           ; end of string
ESC         equ 27          ; escape key

TRUE        equ 1
FALSE       equ 0

SUCCESS     equ 0           ; Successful operation
NOSUCCESS   equ 1           ; Unsuccessful operation

STDIN       equ 0           ; standard input
STDOUT      equ 1           ; standard output
STDERR      equ 2           ; standard error

SYS_read    equ 0           ; system call code for read
SYS_write   equ 1           ; system call code for write
SYS_open    equ 2           ; system call code for file open
SYS_close   equ 3           ; system call code for file close
SYS_fork    equ 57          ; system call code for fork
SYS_exit    equ 60          ; system call code for terminate
SYS_creat   equ 85          ; system call code for file open/create
SYS_time    equ 201         ; system call code for get time

My professor had mentioned there is a file that contains all these already, that could be included but did not mention how. I have been unable to find how to do such a thing, and would also like to know the equivalent for win as well, so as not to have to look up syscodes. aka I would simply change the include in order to assemble on windows.

Arod529
  • 3
  • 2
  • 1
    Is your `ld` 64 bit? As for the second half, no you are not defining them _"in .data"_ because those are just equates, won't be put in the file. Also, system calls don't work like that in windows, changing the numbers won't help you at all. If you already have this list, you can `%include` it. See the [yasm manual](http://www.tortall.net/projects/yasm/manual/html/nasm-include.html). – Jester Nov 02 '15 at 23:30
  • Well, my path variable points to the bin folder for 64 bit MinGW, which is where ld it is located, so I assume so. Is there a command to check explicitly? Also, I was under the impression that the file to include already existed, I'll just make my own. Pretty sure the professor stated that all I would have to do was change the syscode numbers... will have to explicitly ask about this now. – Arod529 Nov 03 '15 at 03:52
  • Check using `ld --help` it should print something like: `supported targets: pe-x86-64 pei-x86-64` – Jester Nov 03 '15 at 12:34

0 Answers0