As An assembly language implements a symbolic representation of CPU instructions which are independent on OSes while assemblers are always running under some OS, I was wonde
An assembler translates mnemonics (e.g. jump
, mov
, add
, etc.) from an assembly language into machine instructions. Machine instructions are entirely dependent on the hardware (they represent the hardware/CPU instruction set).
If you ever wanted to come up with an assembly language, you would need to also design/write an assembler that would do the mapping to machine instructions. In that sense if you target a given machine architecture, the assembler should produce machine specific code, not OS specific code. However, the assembler implementation may (and generally is) OS-specific, because of the output program it produces (a Unix executable is not the same as a Windows executable, even though the underlying machine instruction set is x86, for example).
See here what I mean.