Der Nachfolger des WDR-Computerclub mit Wolfgang Back und Wolfgang Rudolph - ...und immer ein Bit übrigbehalten!


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 Demoprogramm: 6808-Disassembler Kategorie: Open-Micro/Open-Mini/Open-Midi/Open-Macro/Open-Maxi (von Dietmar, Homepage - 9.12.2018 10:10)
Dietmar nutzt:  Open-Micro, Open-Mini, Open-Midi, Open-Macro, Open-Maxi, Open-Mini M-Unit, Open-Mini Station
' ============================================================================
' Ein einfacher 6808-Disassembler für die Open-Maxi
' In OCBASIC 1.12a_e1 von Dietmar Harlos am 9. Dezember 2018
' ============================================================================

' Es gibt bereits zwei Vorgängerversionen dieses 6808-Disassemblers, die
' jedoch nur auf der Open-Micro und Open-Mini arbeiteten. Hier nun eine
' Version für die Open-Maxi. Die Open-Maxi besitzt allerdings eine S08-CPU,
' die neue Assemblerbefehle unterstützt. Diese neuen Assemblerbefehle werden
' nicht korrekt disassembliert.

' Dieses Programm demonstriert unter anderem die Verwendung von Zeichenketten
' (Strings) in Tabellen, LOOKTABBYTE, PEEK und PEEKW.

' --- Definitionen für das System --------------------------------------------

INCLUDE "omax.def"         'Definitionen für die Open-Maxi

' --- Definitionen des Anwenders ---------------------------------------------

DIM a,b,o,code,data BYTE   'einige Variablen definieren
DIM adr,index WORD

' --- Das Hauptprogramm ------------------------------------------------------

adr=&h0ad2                 'Startadresse des Betriebssystems

PrintHex=ON                'PRINT hexadezimal statt dezimal

WHILE TRUE
  PRINT adr;": ";
  code=PEEK(adr)
  ADD adr,1
  hex code
  PUT " "

  index=lookup_bas(code)

  WHILE LOOKTABBYTE(tabdisa,index)
    b=LOOKTABBYTE(tabdisa,index)
    ADD index,1

    IF b="#" THEN PUT " "
    IF b="$" THEN PUT " "
    IF b="A" THEN GOSUB printa
    IF b="B" THEN GOSUB printb
    IF b="C" THEN GOSUB printc
    IF b="X" THEN GOSUB printx

    IF b THEN PUT b
    o=b
  WEND

  PRINT
WEND

End2Host=ON                'Nach Programmende in den Host-Modus
END                        'Programmende, Neustart mit der Enter-Taste

' --- Subroutinen ------------------------------------------------------------

' Byte-Operand ausgeben

PROCEDURE printa
  IF o<>"#" AND o<>"," THEN PUT " "
  PUT "$"
  code=PEEK(adr)
  ADD adr,1
  hex code
  b=0
  RETURN
END PROCEDURE

' Branch ausgeben

PROCEDURE printb
  IF o<>"," THEN PUT " "
  PUT "$"
  code=PEEK(adr)
  ADD adr,1
  IF code AND &h80 THEN
    PRINT adr-256+code;
  ELSE
    PRINT adr+code;
  END IF
  b=0
  RETURN
END PROCEDURE

' Word-Operand ausgeben

PROCEDURE printc
  IF o<>"#" THEN PUT " "
  PUT "$"
  PRINT PEEKW(adr);
  ADD adr,2
  b=0
  RETURN
END PROCEDURE

' Indexed ausgeben

PROCEDURE printx
  IF o<>"#" AND o<>0 THEN PUT " "
  PRINT ",x";
  b=0
  RETURN
END PROCEDURE

' Table-LookUp in OCBASIC (Assemblercode wäre schneller!)

FUNCTION lookup_bas(a)
  index=0
  WHILE a                  'String in Tabelle suchen
    WHILE LOOKTABBYTE(tabdisa,index)
      ADD index,1
    WEND
    ADD index,1
    SUB a,1
  WEND
  RETURN index
END FUNCTION

' HEX$ für BYTE in Kleinbuchstaben unter Verwendung von nur einer Variable.

' Besonderheit: Die Variable wird nicht verändert.

PROCEDURE hex(data)
  PUT (data SHR 4)+48+(((data SHR 4)>9) AND 39)
  PUT (data AND 15)+48+(((data AND 15)>9) AND 39)
  RETURN
END PROCEDURE

' --- Tabellen ---------------------------------------------------------------

TABLE tabdisa BYTE
"brset#0,A,B",0,"brclr#0,A,B",0,"brset#1,A,B",0,"brclr#1,A,B",0
"brset#2,A,B",0,"brclr#2,A,B",0,"brset#3,A,B",0,"brclr#3,A,B",0
"brset#4,A,B",0,"brclr#4,A,B",0,"brset#5,A,B",0,"brclr#5,A,B",0
"brset#6,A,B",0,"brclr#6,A,B",0,"brset#7,A,B",0,"brclr#7,A,B",0
"bset#0,A",0,"bclr#0,A",0,"bset#1,A",0,"bclr#1,A",0
"bset#2,A",0,"bclr#2,A",0,"bset#3,A",0,"bclr#3,A",0
"bset#4,A",0,"bclr#4,A",0,"bset#5,A",0,"bclr#5,A",0
"bset#6,A",0,"bclr#6,A",0,"bset#7,A",0,"bclr#7,A",0
"braB",0,"brnB",0,"bhiB",0,"blsB",0,"bhsB",0,"bloB",0,"bneB",0,"beqB",0
"bhccB",0,"bhcsB",0,"bplB",0,"bmiB",0,"bmcB",0,"bmsB",0,"bilB",0,"bihB",0
"negA",0,"cbeqA,B",0,"db$32",0,"comA",0,"lsrA",0,"sthxA",0,"rorA",0,"asrA",0
"lslA",0,"rolA",0,"decA",0,"dbnzA,B",0,"incA",0,"tstA",0,"db$3e",0,"clrA",0
"nega",0,"cbeqa#A,B",0,"mul",0,"coma",0,"lsra",0,"ldhx#C",0,"rora",0,"asra",0
"lsla",0,"rola",0,"deca",0,"dbnzaB",0,"inca",0,"tsta",0,"movA,A",0,"clra",0
"negx",0,"cbeqx#A,B",0,"div",0,"comx",0,"lsrx",0,"ldhxA",0,"rorx",0,"asrx",0
"lslx",0,"rolx",0,"decx",0,"dbnzxB",0,"incx",0,"tstx",0,"movAX+",0,"clrx",0
"negAX",0,"cbeqAX+,B",0,"nsa",0,"comAX",0,"lsrAX",0,"cmphx#C",0,"rorAX",0,"asrAX",0
"lslAX",0,"rolAX",0,"decAX",0,"dbnzAX,B",0,"incAX",0,"tstAX",0,"mov#A,A",0,"clrAX",0
"negX",0,"cbeqX+,B",0,"daa",0,"comX",0,"lsrX",0,"cmphxA",0,"rorX",0,"asrX",0
"lslX",0,"rolX",0,"decX",0,"dbnzX,B",0,"incX",0,"tstX",0,"mov x+,A",0,"clrX",0
"rti",0,"rts",0,"db$82",0,"swi",0,"tap",0,"tpa",0,"popa",0,"pusha",0
"popx",0,"pushx",0,"poph",0,"pushh",0,"clrh",0,"db$8d",0,"stop",0,"wait",0
"bgeB",0,"bltB",0,"bgtB",0,"bleB",0,"txs",0,"tsx",0,"db$96",0,"tax",0
"clc",0,"sec",0,"cli",0,"sei",0,"rsp",0,"nop",0,"db$9e",0,"txa",0
"sub#A",0,"cmp#A",0,"sbc#A",0,"cmpx#A",0,"and#A",0,"bit#A",0,"lda#A",0,"ais#A",0
"eor#A",0,"adc#A",0,"ora#A",0,"add#A",0,"db$ac",0,"bsrB",0,"ldx#A",0,"aix#A",0
"subA",0,"cmpA",0,"sbcA",0,"cmpxA",0,"andA",0,"bitA",0,"ldaA",0,"staA",0
"eorA",0,"adcA",0,"oraA",0,"addA",0,"jmpA",0,"jsrA",0,"ldxA",0,"stxA",0
"subC",0,"cmpC",0,"sbcC",0,"cmpxC",0,"andC",0,"bitC",0,"ldaC",0,"staC",0
"eorC",0,"adcC",0,"oraC",0,"addC",0,"jmpC",0,"jsrC",0,"ldxC",0,"stxC",0
"subCX",0,"cmpCX",0,"sbcCX",0,"cmpxCX",0,"andCX",0,"bitCX",0,"ldaCX",0,"staCX",0
"eorCX",0,"adcCX",0,"oraCX",0,"addCX",0,"jmpCX",0,"jsrCX",0,"ldxCX",0,"stxCX",0
"subAX",0,"cmpAX",0,"sbcAX",0,"cmpxAX",0,"andAX",0,"bitAX",0,"ldaAX",0,"staAX",0
"eorAX",0,"adcAX",0,"oraAX",0,"addAX",0,"jmpAX",0,"jsrAX",0,"ldxAX",0,"stxAX",0
"subX",0,"cmpX",0,"sbcX",0,"cmpxX",0,"andX",0,"bitX",0,"ldaX",0,"staX",0
"eorX",0,"adcX",0,"oraX",0,"addX",0,"jmpX",0,"jsrX",0,"ldxX",0,"stxX",0
0
END TABLE

' --- Programmende ----------------------------------------------------------


Passender Link: Bedienungsanleitung zur Open-Macro und Open-Maxi

Meine Homepage: http://ccintern.dharlos.de

 Antwort schreiben

Bisherige Antworten: