Were the first assemblers written in machine code?
According to Wikipedia, the first ever assembler / assembly language was implemented for the IBM 701 by Nathaniel Rochester. (The dates are a little uncertain from the Wikipedia article. It states that Rochester joined IBM in 1948, but another Wikipedia page states that the 701 was publicly announced in 1952. And this IBM page states that "[a]ctual design started on February 1, 1951 and was completed a year later".)
HoweverHowever "Assemblers and Loaders" by David Salomon states (on page 7) that EDSAC also had an assembler:
"One of the first stored program computers was the EDSAC (Electronic Delay Storage Automatic Calculator) developed at Cambridge University in 1949 by Maurice Wilkes and W. Renwick. From its very first days the EDSAC had an assembler, called Initial Orders. It was implemented in a read-only memory formed from a set of rotary telephone selectors, and it accepted symbolic instructions. Each instruction consisted of a one letter mnemonic, a decimal address, and a third field that was a letter. The third field caused one of 12 constants preset by the programmer to be added to the address at assembly time." (References omitted ... see the original.)
Assuming we accept that "Initial Orders"Initial Orders takes precedence, we have clear evidence that the first assembler was implemented in machine code.
This pattern (writing the initial assemblers in machine code) would have been the norm well into the 1950s. However, according to Wikipedia, "[a]ssemblers were the first language tools to bootstrap themselves". See also this section which explains how a primordial assembler written machine code was used to bootstrap a more advanced assembler that was coded in assembly language.
And a correlated question... how about today? If a brand new CPU architecture comes out, with a brand new instruction set, and a brand new assembly syntax, how would the assembler be constructed?
These days assemblers and(and compilers) are written in higher level languages, and an assembler or compiler for a new machine architecture is typically developed on an existing system with a different (older) architecture and cross-compiled for the new platform.
(FWIW - writing Writing and debugging non-trivial programs in machine code is an exceedingly laborious process. Someone developing an assembler in machine code would most likely bootstrap to an assembler written in assembler as soon as possible.)
This Wikipedia page on bootstrapping compilers and assemblers is worth a read ... if this is all baffling to you.