Assembler API

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Assembler API

pouzzler
Hello.

What is meant at various places in the API by 'should only be called when <condition>'.
Does it mean the method being described doesn't need to check for errors, or quite the contrary?

For example:

Returns the dest mnemonic in the current C-command (8 possibilities). Should be called only when commandType() is C_COMMAND.

Does this mean this method had to validate commandType() is C_COMMAND, or that the caller has to make that validation?

Best regards,
S├ębastien
Reply | Threaded
Open this post in threaded view
|

Re: Assembler API

ybakos
There are two instruction types, A and C. An A instruction does not have a dest component, so your assembler would probably not call a method for translating the DEST component of a C instruction if the instruction is not a C instruction.

Reply | Threaded
Open this post in threaded view
|

Re: Assembler API

cadet1620
Administrator
In reply to this post by pouzzler
pouzzler wrote
What is meant at various places in the API by 'should only be called when <condition>'.
Does it mean the method being described doesn't need to check for errors, or quite the contrary?

For example:

Returns the dest mnemonic in the current C-command (8 possibilities). Should be called only when commandType() is C_COMMAND.

Does this mean this method had to validate commandType() is C_COMMAND, or that the caller has to make that validation?
It does not need to do the validation. Since you are writing this module for your own use, you can control when it is called to ensure that there is a 'dest' to return. If you were writing objects for other programmers to use, you would want to spend more time making them bulletproof.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Assembler API

pouzzler
Alright, thank you both. Going back to it then, this thing is worse than heroin addiction, I don't believe I will willingly stop before the whole book is done with.

See you,
S├ębastien