Monday, November 30, 2009 12:55 AM,
A student writes: Dr. Patt: Quick Question- Although we have generally placed our constants, .BLKWs, .FILLs, .STRINGZs, etc between the TRAP x25 and the .END in our program, is it permissible to place these pieces of code in other places in the program, so long as we arrange the code to ensure that they are not executed? Regards, <<student who likes to move things around>> I guess we are about to finish the course. The signature above was generated by the student sending me the email, not by me. AND, when that starts to happen, I know we are getting close to the end of the semester! Anyhow, the short answer is: Sure. The long answer is that it is actually good practice to do what I think the student has in mind: put the constants after the subroutine they go with. ...and, of course, after the RET, guaranteeing that they won't get executed. It may also be that the student is motivated by the smallness of the 9-bit offset for LD and ST. Recall what we did in the discussion of I/O where the device registers were very far away from the code that was accessing them. LDI and STI works in this context also. What is to be avoided is spaghetti code, such as the following to load x4000 into R0 and increment it.: LD R0,A BRnzp B A .FILL x4000 B ADD R0,R0,#1 Yech! Good luck finishing this up by Tuesday night. See you in class. Yale Patt