1
0
mirror of https://github.com/t-edson/P65Utils.git synced 2024-06-08 11:32:30 +00:00

Add files via upload

This commit is contained in:
Tito Hinostroza 2018-09-07 08:50:05 -05:00 committed by GitHub
parent 3ba07ff57c
commit 5a33e75171
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,14 +123,6 @@ type //Instructions set
optCycles: string); optCycles: string);
end; end;
//Indica el destino de la instrucción
TPIC16destin = (
toW = %00000000, //al acumulador
toF = %10000000 //a memoria
);
const //Constants of address and bit positions for some registers const //Constants of address and bit positions for some registers
_C = 0; _C = 0;
_Z = 1; _Z = 1;
@ -199,12 +191,14 @@ type
function ValidRAMaddr(addr: word): boolean; //indica si una posición de memoria es válida function ValidRAMaddr(addr: word): boolean; //indica si una posición de memoria es válida
public //Métthods to code instructions according to syntax public //Métthods to code instructions according to syntax
procedure useRAM; procedure useRAM;
procedure codByte(const value: byte; isData: boolean);
procedure codAsm(const inst: TP6502Inst; addMode: TP6502AddMode; param: word); procedure codAsm(const inst: TP6502Inst; addMode: TP6502AddMode; param: word);
procedure codGotoAt(iRam0: integer; const k: word); procedure cod_JMP_at(iRam0: integer; const k: word);
procedure codCallAt(iRam0: integer; const k: word); procedure cod_REL_JMP_at(iRam0: integer; const k: word);
function codInsert(iRam0, nInsert, nWords: integer): boolean; function codInsert(iRam0, nInsert, nWords: integer): boolean;
public //Adicional methods public //Aditional methods
function FindOpcode(Op: string): TP6502Inst; //busca Opcode function FindOpcode(Op: string): TP6502Inst; //Find Opcode
function IsRelJump(idInst: TP6502Inst): boolean; //Idnetify realtive jumps Opcodes
procedure GenHex(hexFile: string); //genera un archivo hex procedure GenHex(hexFile: string); //genera un archivo hex
procedure DumpCodeAsm(lOut: TStrings; incAdrr, incValues, incCom, procedure DumpCodeAsm(lOut: TStrings; incAdrr, incValues, incCom,
incVarNam: boolean); incVarNam: boolean);
@ -255,8 +249,19 @@ begin
ram[iRam].used := true; //marca como usado ram[iRam].used := true; //marca como usado
inc(iRam); inc(iRam);
end; end;
procedure TP6502.codByte(const value: byte; isData: boolean);
{Write a byte to the RAM memory.}
begin
if iRam >= CPUMAXRAM then begin
MsjError := 'RAM Memory limit exceeded.';
exit;
end;
ram[iRam].value := value;
if isData then ram[iRam].name := 'data';
useRAM; //marca como usado e incrementa puntero.
end;
procedure TP6502.codAsm(const inst: TP6502Inst; addMode: TP6502AddMode; param: word); procedure TP6502.codAsm(const inst: TP6502Inst; addMode: TP6502AddMode; param: word);
{Rutina general para codificar instrucciones en ensamblador} {General routine to codify assembler instructions.}
var var
rInst: TP6502Instruct; rInst: TP6502Instruct;
begin begin
@ -267,6 +272,10 @@ begin
exit; exit;
end; end;
//Write OpCode //Write OpCode
if not (addMode in rInst.addressModes) then begin
MsjError := 'Invalid Adrress mode.';
exit;
end;
ram[iRam].value := rInst.instrInform[addMode].Opcode; ram[iRam].value := rInst.instrInform[addMode].Opcode;
useRAM; //marca como usado e incrementa puntero. useRAM; //marca como usado e incrementa puntero.
//Codifica parámetros //Codifica parámetros
@ -348,25 +357,26 @@ begin
raise Exception.Create('Implementation Error.'); raise Exception.Create('Implementation Error.');
end; end;
end; end;
procedure TP6502.codGotoAt(iRam0: integer; const k: word); procedure TP6502.cod_JMP_at(iRam0: integer; const k: word);
{Codifica una instrucción GOTO, en una posición específica y sin alterar el puntero "iFlash" {Codiica la parte de la dirección de una instrucción de salto. Se usa
actual. Se usa para completar saltos indefinidos} para completar saltos indefinidos}
var var
rInst: TP6502Instruct; rInst: TP6502Instruct;
begin begin
rInst := PIC16InstName[i_JMP]; // rInst := PIC16InstName[i_JMP];
ram[iRam0].value := rInst.instrInform[aAbsolute].Opcode; // ram[iRam0].value := rInst.instrInform[aAbsolute].Opcode;
ram[iRam0+1].value := lo(k); ram[iRam0+1].value := lo(k);
ram[iRam0+2].value := hi(k); ram[iRam0+2].value := hi(k);
end; end;
procedure TP6502.codCallAt(iRam0: integer; const k: word); procedure TP6502.cod_REL_JMP_at(iRam0: integer; const k: word);
{Codifica una instrucción i_CALL, en una posición específica y sin alterar el puntero "iFlash" {Codifica la parte de la dirección relativa de una instrucción condicional. Se usa
actual. Se usa para completar llamadas indefinidas} para completar llamadas indefinidas}
var var
rInst: TP6502Instruct; rInst: TP6502Instruct;
begin begin
rInst := PIC16InstName[i_JSR]; // rInst := PIC16InstName[i_JSR];
ram[iRam0].value := rInst.instrInform[aAbsolute].Opcode; // ram[iRam0].value := rInst.instrInform[aAbsolute].Opcode;
ram[iRam0+1].value := lo(k);
end; end;
function TP6502.codInsert(iRam0, nInsert, nWords: integer): boolean; function TP6502.codInsert(iRam0, nInsert, nWords: integer): boolean;
{Inserta en la posición iRam0, "nInsert" palabras, desplazando "nWords" palabras. {Inserta en la posición iRam0, "nInsert" palabras, desplazando "nWords" palabras.
@ -407,6 +417,11 @@ begin
//No encontró //No encontró
Result := i_Inval; Result := i_Inval;
end; end;
function TP6502.IsRelJump(idInst: TP6502Inst): boolean;
{Returns TRUE if the instruction accept the relative address mode}
begin
Result := PIC16InstName[idInst].instrInform[aRelative].Opcode<>0;
end;
//Campos para procesar instrucciones //Campos para procesar instrucciones
function TP6502.GetSTATUS_Z: boolean; function TP6502.GetSTATUS_Z: boolean;
begin begin