LA Load Address
LA Instruction type: RX Explicit Coding: B1,D2(X2,B2) Example LA 5,3(4,5) Example LA 8,TABLE(7) Use: Creates an address (operand 2) which is loaded into the operand 1 register
What does it do? LA 8,Y R8 00 12 3D 8A (Before) R8 00 00 10 04 (After) Memory F1 F2 F3 F4 F5 F6 F7 F8 F9 Address X’1000’ Y
What does it do? LA 8,Y(9) R8 00 12 3D 8A R9 00 00 00 04 R8 (Before) R8 00 12 3D 8A R9 00 00 00 04 R8 00 00 10 08 (After) Memory F1 F2 F3 F4 F5 F6 F7 F8 F9 Address X’1000’ Y
What does it do? LA 7,5(8,9) (Before) R8 00 00 20 00 R9 00 00 10 00 R7 00 00 12 34 (Before) R7 00 00 30 05 (After)
What does it do? LA 7,5(0,9) or LA 7,5(,9) R8 00 00 20 00 R9 00 00 20 00 R9 00 00 10 00 (Before) R7 00 00 12 34 R7 00 00 10 05 (After)
What does it do? LA 7,5 or LA 7,5(0,0) R7 00 00 12 34 R7 (Before) R7 00 00 12 34 R7 00 00 00 05 (After) This is an effective way to load a “small” number into a register. Small means < 4096. Why?
An Assembly Listing 4180 3004 00004 9 LA 8,4(0,3) 4180 3004 00004 10 LA 8,4(,3) 4183 0004 00004 11 LA 8,4(3) 4180 0004 00004 12 LA 8,4(0,0) 4180 0004 00004 13 LA 8,4
LA Example use: Assume: TABLE DC F ‘1’ Assume address 1000 DC F ‘2’ TABENTRY DS F You execute: LA R7,8 LA R8,TABLE LA R9,0(R7,R8) MCV TABENTRY,0(R9) R9 After: 00001008
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)? LA is often used for loading multiple base registers: BASR R12,R0 USING *,R12,R11 LA R11,2048 LA R11,2048(R11,R12)
Try it in VisibleZ Try the following programs: la.obj