Skip to content

Commit

Permalink
Custom rom attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
rnentjes committed Feb 28, 2015
1 parent bde9f43 commit ca7bf01
Show file tree
Hide file tree
Showing 9 changed files with 7,574 additions and 15 deletions.
7,457 changes: 7,457 additions & 0 deletions asm/exec_disassembly.txt

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions asm/rom.x68
@@ -0,0 +1,40 @@
*-----------------------------------------------------------
* Title :
* Written by :
* Date :
* Description:
*-----------------------------------------------------------
ORG $0
DC.W $1111

INIT: ; first instruction of program

* Put program code here

JMP $FC00D2

; Skip to Start
DS.B $CA

START:
MOVE.L #$020000, D0
WAIT:
SUBQ.L #1, D0
BGT.S WAIT

MOVE.W $0, D0

LEA $DFF000, A4
LOOP:
MOVE.W D0, $0180(A4)
ADDQ.W #1, D0
JMP LOOP

END:
JMP END
END START

*~Font name~Courier New~
*~Font size~10~
*~Tab type~1~
*~Tab size~4~
Expand Down
1 change: 0 additions & 1 deletion asm/test.sh
@@ -1,2 +1 @@
java -jar ../lib/reasm.jar test.asm MC68000

8 changes: 8 additions & 0 deletions rom.md
@@ -0,0 +1,8 @@
Rom calls jmp 0x00fc00d2
rom start 0x00fc0000?
rom start 0x00f00000?



http://lallafa.de/blog/2013/06/added-segtracker-in-fs-uaes-debugger/

2 changes: 1 addition & 1 deletion src/m68k/Disassemble.java
Expand Up @@ -16,7 +16,7 @@ public class Disassemble {

public static void main(String[] args) throws Exception {

File file = new File("a.out");
File file = new File("kick13.rom");
byte [] data = new byte[(int) file.length()];

FileInputStream in = new FileInputStream(file);
Expand Down
17 changes: 17 additions & 0 deletions src/m68k/cpu/assemble/Assembler.java
Expand Up @@ -139,6 +139,20 @@ private Integer getLabelAddress(String label) {
return labelLocations.get(label);
}


private AssembledOperand handleLabel(Size size, AssembledOperand instruction) {
AssembledOperand result = instruction;

if (instruction instanceof LabelOperand) {
String label = ((LabelOperand) instruction).operand;
int pc = ((LabelOperand) instruction).memory_read;

setLabel(label, pc);
}

return result;
}

public DisassembledInstruction parseLine(String line) throws ParseException {
return parseLine(-1, line);
}
Expand Down Expand Up @@ -274,6 +288,9 @@ public DisassembledInstruction parseLine(int lineNumber, String line) throws Par
} else {
InstructionHandler handler = commandMapping.get(command);

//handleLabel(operand1);
//handleLabel(operand2);

AssembledInstruction instruction = new AssembledInstruction(mnemonic, size, operand1, operand2);

DisassembledInstruction disassembled = handler.assemble(pc, instruction);
Expand Down
11 changes: 11 additions & 0 deletions src/m68k/cpu/assemble/LabelOperand.java
@@ -0,0 +1,11 @@
package m68k.cpu.assemble;

/**
* Date: 9-10-14
* Time: 20:40
*/
public class LabelOperand extends AssembledOperand {
public LabelOperand(int pc, String operand) {
super(operand, 0, pc);
}
}
35 changes: 35 additions & 0 deletions src/m68k/cpu/assemble/Mnemonics.java
@@ -0,0 +1,35 @@
package m68k.cpu.assemble;

import m68k.cpu.InstructionHandler;
import m68k.cpu.instructions.EXG;

import java.util.HashMap;
import java.util.Map;

/**
* Date: 9-10-14
* Time: 20:29
*/
public class Mnemonics {

public static class Mnemonic {
public final InstructionHandler handler;
public final int src;
public final int dst;

public Mnemonic(InstructionHandler handler, int src, int dst) {
this.handler = handler;
this.src = src;
this.dst = dst;
}
}

public static int DATA_REGISTER = 1;
public static int ADDRESS_REGISTER = 2;

private static Map<String, Mnemonic> mapping = new HashMap<String, Mnemonic>();
static {
mapping.put("exg", new Mnemonic(new EXG(null), DATA_REGISTER | ADDRESS_REGISTER, DATA_REGISTER | ADDRESS_REGISTER));
}

}
18 changes: 5 additions & 13 deletions src/m68k/cpu/assemble/OperandParser.java
Expand Up @@ -7,7 +7,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
Expand Down Expand Up @@ -188,11 +187,11 @@ public AssembledOperand parse(Size size, int pc, int lineNumber, String operand)

if (mode == null) {
if (parts.isEmpty()) {
if (couldBeLabel(operand)) {
mode = AddressingMode.LABEL;
} else {
throw new ParseException("Unable to parse expression '" + operand + "'", lineNumber);
}
// if (couldBeLabel(operand)) {
// mode = AddressingMode.LABEL;
// } else {
// throw new ParseException("Unable to parse expression '" + operand + "'", lineNumber);
// }
}

boolean registerList = true;
Expand Down Expand Up @@ -311,7 +310,6 @@ public AssembledOperand parse(Size size, int pc, int lineNumber, String operand)
lastReg = reg;
lastType = part.type;
}
break;

}

Expand All @@ -333,12 +331,6 @@ public AssembledOperand parse(Size size, int pc, int lineNumber, String operand)
return new AssembledOperand(lower, bytes, memory_read, mode, conditional, register);
}

private boolean couldBeLabel(String operand) {
Matcher matcher = labelPattern.matcher(operand);

return matcher.matches();
}

public int parseValue(String value) {
if (value.charAt(0) == '$') {
return Integer.parseInt(value.substring(1), 16);
Expand Down

0 comments on commit ca7bf01

Please sign in to comment.