/*
AorgDirective.java
(c) 2008-2013 Edward Swartz
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
*/
package v9t9.tools.asm.directive;
import java.util.List;
import v9t9.common.asm.IInstruction;
import v9t9.common.asm.ResolveException;
import v9t9.tools.asm.IAssembler;
import v9t9.tools.asm.operand.hl.AssemblerOperand;
import v9t9.tools.asm.operand.ll.LLImmedOperand;
import v9t9.tools.asm.operand.ll.LLOperand;
/**
* @author Ed
*
*/
public class AorgDirective extends Directive {
private AssemblerOperand op;
public AorgDirective(List<AssemblerOperand> ops) {
this.op = ops.get(0);
}
@Override
public String toString() {
return "AORG " + op;
}
public IInstruction[] resolve(IAssembler assembler, IInstruction previous, boolean finalPass) throws ResolveException {
LLOperand lop = op.resolve(assembler, this);
if (!(lop instanceof LLImmedOperand))
throw new ResolveException(op, "Expected number");
op = lop;
assembler.setPc(lop.getImmediate());
setPc(lop.getImmediate());
return new IInstruction[] { this };
}
}