URL
https://opencores.org/ocsvn/tinycpu/tinycpu/trunk
Subversion Repositories tinycpu
[/] [tinycpu/] [trunk/] [assembler/] [asm.rb] - Rev 36
Go to most recent revision | Compare with Previous | Blame | View Log
PREFIX = "MemIn <= x\"";SUFFIX = "\";";SEPERATOR = "\n";class OpcodeByte1attr_accessor :op, :register, :cond;def to_hexs = (op << 4 | register.number << 1 | cond).to_s(16);if s.length == 1"0"+s;elsif s.length == 0"00";elsesendendendclass Register8attr_accessor :numberdef initialize(num)@number=numendend$iftr = 0; #0 for no condition, 1 for if TR, 2 for if not TRdef mov_r8_imm8(reg,imm)o = OpcodeByte1.new();o.op = 0;o.register=reg;if $iftr<2 theno.cond=$iftr;elseraise "if_tr_notset is not allowed with this opcode";endputs PREFIX + o.to_hex + imm.to_s(16) + SUFFIX;puts SEPERATOR;enddef mov(arg1,arg2)if arg1.kind_of? Register8 and arg2.kind_of? Integer and arg2<0x100 then mov_r8_imm8 arg1,arg2 endenddef if_tr_set$iftr = 1yield$iftr = 0endr0=Register8.new(0)r1=Register8.new(1)r2=Register8.new(2)r3=Register8.new(3)#test code follows. Only do it here for convenience.. real usage should prefix assembly files with `require "asm.rb"`if_tr_set{mov r1,0x10}mov r1,0x20
Go to most recent revision | Compare with Previous | Blame | View Log
