90 likes | 217 Views
This document explores the Load (L) instruction in assembly programming, detailing its usage and effects on registers and memory. Through practical examples, we illustrate how a word from a specified memory address is loaded into a register, demonstrating the potential implications, such as protection exceptions when accessing restricted memory regions. We provide programming tips to avoid common mistakes associated with the Load and Load Address (LA) instructions, ensuring clarity in coding practices. Utilize the examples for hands-on practice in visible coding environments.
E N D
L • Instruction type: RX • Explicit Coding: R1,D2(X2,B2) • Example L 5,3(4,5) • Example L 8,TABLE(R7) • Use: The word (4 bytes) at the operand 2 address is loaded into the operand 1 register
What does it do? L R8,Y R8 00 12 3D 8A (Before) R8 F5 F6 F7 F8 (After) Memory F1 F2 F3 F4 F5 F6 F7 F8 F9 Y
What does it do? L R8,Y(9) (Before) R8 00 12 3D 8A R9 00 00 00 04 R8 F6 F7 F8 F9 (After) Memory F1 F2 F3 F4 F5 F6 F7 F8 F9 Y
What does it do? L R7,4(R8,R9) (Before) R8 00 00 20 00 R9 00 00 10 00 R7 FF FF FF FF 22 33 44 55 (After) 00 00 00 11 22 33 44 55 66 Memory X’3000’ X’3004’
What does it do? L R7,4 (Before) R7 12 34 56 78 This effective address is 4. Executing this instruction causes a protection exception (SOC 4) since we are referencing storage that is outside of our assigned region.
L Example • Example use: Assume: TABLE DC F ‘1’ Assume address 1000 DC F ‘2’ DC F ‘3’ You execute: LA R7,TABLE L R8,0(R0,R7) L R9,4(R0,R7) L R10,8(R0,R7) R8 After: R9 After: R10 After: 00000001 00000002 00000003
Programming Tips • It’s easy to make a simple mistake by coding L for LA or LA for L. Give it a moment’s extra thought when you code these. Do you want an address (LA)? Or do you want the contents at an address (L)?
Try it in VisibleZ • Try the following programs: • l.obj • l1.obj • l2.obj