asm/*: Move directive processing to its own file, refactor error handling