Reputation: 21
For one of my classes I need to write an LC-3 program in machine code and I can't seem to find the machine codes for the commands that have a period for them:
.ORIG
.END
.BLKW
etc
Does anyone know what they are? I have all of the commands done, for example:
AND R2, R2, #0
--> 0101 010 010 1 00000
However I can't find what the first four bits for the .ORIG
, .END
, .BLKW
commands are anywhere online.
Upvotes: 1
Views: 4264
Reputation: 225042
I'm not familiar with your particular dialect, but in most assembly languages, keywords starting with a .
aren't instruction mnemonics but assembler directives. In your case, it looks like possibly .ORIG
means the start of a program and .END
the end. .BLKW
seems like a memory filling operation of some kind.
Edit: I did a google search and came up with this presentation. It says that .ORIG
describes where to place the following block in memory. For example .ORIG 0x3000
would set the next instruction at address 0x3000
. .END
, as I mentioned above, describes the end of the program. .BLKW
means "block word" and is used to reserve space for use as an array, for example.
In all cases, there aren't any specific machine codes for these directives. For .ORIG
, just write out the following opcodes or data at the specified location. .END
won't show up in the machine code at all, and .BLKW
means you can just copy the specified bytes directly from the assembly program into machine code.
Upvotes: 3