REVAS V2 Z80/8080 DISASSEMBLER .USER'S MANUAL Copyright (c) 1978 A.E. HAWLEY LOS ANGELES, CALIF. 1 INTRODUCTION *** REVAS *** REVERSE ASSEMBLER FOR Z80 OBJECT CODE PROGRAMS REVAÓ  ió aî interactivå reverså assembleò (disassembler© designeä  tï translatå Z8° oò 808° machinå languagå codå intï  aî assembly-likå listing®  Iô ió writteî iî Z8° codå anä caî bå useä iî  anù systeí thaô useó á Z8° centraì processor®  Iô supportó  á puncè anä linå printeò aó welì aó á CRÔ oò TTY. Witè  2²  commands¬  REVAÓ  caî helð  youº  **Analyså undocumenteä programó           **Documenô youò machinå languagå patches           **Documenô youò speciaì I/Ï routines           **Debuç developmentaì programs           **Modifù anä relocatå youò software Herå arå somå oæ REVAS§ featuresº           **Assemblù formaô listings           **Outpuô suitablå foò reassembly           **Generateó synthetiã labels           **Acceptó youò choicå oæ reaì labels           **Printó tableó iî datá format           **Displayó alphanumeriã equivalentó oæ thå machinå code           **Displayó symboì tablå aô anù time           **Crosó referencå listinç showó wherå anä ho÷ eacè           symboì ió used           **Uð tï ³ outpuô deviceó caî bå used           **Yoõ arå alwayó iî completå controì oæ thå           disassemblù process..stoð anä restart¬ returî tï           monitor¬ oò returî tï commanä modå aô will 2 INTRODUCTION Thå  instructioî mnemonicó produceä bù REVAÓ arå thå samå aó thoså useä bù thå Technicaì Desigî Labs§ Z-8° Relocatinç Macrï Assembler¬ anä bù Inteì foò thå 8080. Thå  remaindeò oæ thió manuaì showó yoõ ho÷ tï makå REVAÓ worë foò you. Thå  'Á  LITTLÅ INSIGHT§ sectioî introduceó  thå  generaì algorithí  bù  whicè REVAÓ performó á  disassembly®  Thå  uså  oæ tableó  ió  explaineä anä relateä tï thå commandó thaô uså  theså tables® Yoõ wilì neeä tï understanä thió subjecô iî ordeò tï makå mosô effectivå uså oæ thå REVAÓ capabilities®  Iî particular¬ thå twï mosô frequentlù useä commandó arå introduceä iî thaô section. Iî thå 'REVAÓ COMMANDS§ section¬ yoõ wilì finä á detaileä descriptioî  oæ thå syntaø anä operatioî oæ eacè  command®  Untiì yoõ  becomå thoroughlù familiaò witè thå commanä  set¬  yoõ  wilì havå  frequenô  uså foò thió section®  Á carefuì readinç  oæ  thå formaì  commanä  descriptionó wilì reveaì thå freedoí  oæ  formaô thaô  ió designeä intï theså commands®  Á lisô oæ REVAÓ  COMMANDÓ appearó oî thå bacë coveò foò readù reference. Thå  IMPLEMENTATIOÎ sectioî containó thå informatioî  yoõ neeä  tï  loaä REVAÓ intï youò systeí anä properlù  interfacå  tï youò  I/Ï devices®  Thå I/Ï jumð vectoró arå explaineä there¬  aó welì  aó  thå registeò usagå associateä witè  I/O®  Somå  oæ  thå addresseó  anä  theiò functionó withiî REVAÓ arå giveî tï  permiô minoò changeó tï bå madå iî outpuô formaô iæ yoõ wish. Reaä  thå manuaì cleaò througè beforå tryinç  tï  operatå REVAS¬ theî refeò tï iô frequently® Theî gï aheaä anä disassemblå something! Onå caution! Thinë carefullù beforå yoõ uså thå 'A§ commanä oò thå 'G§ command®  Theù  caî  causå  á systeí crash»  thå 'A§  commanä  bù assigninç  tableó  iî  á prograí area¬  anä thå  'G§  commanä  bù callinç aî addresó thaô ió noô thå subroutinå yoõ  intended®  Yoõ havå  controì  oæ  sucè situationó becauså yoõ arå  thå  onå  whï specifieó thå addresó foò theså commands. Iô  ió  mù intenô tï furnisè softwarå  anä  documentatioî thaô  ió  aó  usefuì anä freå oæ erroró aó  possible®  Thå  REVAÓ prograí  haó beeî iî constanô uså durinç itó  owî  development(!© anä foò manù monthó bù severaì useró beforå thå firsô versioî waó released®  Alì knowî bugó havå beeî exterminated® É aí interesteä iî improvinç whereveò possiblå thå qualitù oæ thå prograí anä itó documentation®  Thus¬  É wilì welcomå anä responä tï commentó anä recommendationó  senô tï thå addresó below®  (accoladeó arå  alsï welcome!© Pleaså includå á stampeä self-addresseä envelopå iæ yoõ wisè á reply. Aì Hawley 3 A LITTLE INSIGHT HO× THÅ DISASSEMBLEÒ WORKS Herå ió á brieæ descriptioî oæ REVAS: Prograí  size-- 4ë byteó Symboì tablå location--enä oæ REVAÓ oò aó assigned Symboì tablå usage-- synthetiã symboló ´ bytes/symbol assigneä labeló ¶ bytes/label Symboì tablå lengtè ió initiallù zero¬  increasinç aó requireä tï accomodatå symboló anä uð tï 68² labels. Thå  objecô prograí tï bå disassembleä musô bå iî  memorù aô  it'ó normaì location®  Wheî controì ió passeä tï  REVAS¬  thå prompô  character(#© wilì appeaò anä yoõ maù responä witè onå  oæ thå commandó describeä iî thå nexô section®  Let'ó starô witè thå 'D§ (displaù disassembly© command: REVAÓ  wilì examinå thå bytå locateä aô thå starô addresó anä analyså iô aó thå firsô bytå oæ aî instructioî bù findinç  iô iî internaì lookuð tables® Thå operatoò mnemoniã ió obtaineä froí thå  tables¬  aó  welì  aó  thå numbeò oæ byteó  iî  thå  currenô instruction. Thå operanä fielä contents¬  iæ any¬  arå nexô determineä bù á combinatioî oæ logicaì operationó anä tablå lookup. Thå operatoò anä operanä arå storeä iî appropriatå fieldó oæ thå linå buffer(LB). Next¬  thå addresó oæ thå instructioî anä thå objecô codå arå  storeä iî thå LÂ aó heø characters¬  anä thå objecô codå  ió converteä  anä  placeä  iî thå commenô fielä oæ  thå  buffeò  foò printouô aó ASCIÉ data. Thå  symboì tableó arå searcheä foò á labeì  assigneä  tï thå addresó jusô defined®  Iæ á labeì ió found¬ iô ió inserteä iî thå  labeì fielä oæ thå linå buffer®  Iæ therå ió nï label¬  theî thå tableó arå searcheä foò á synthetiã labeì tï insert®  Iæ nonå exists¬ theî thå fielä ió lefô blank® Labeló caî bå righô oò lefô justifieä (seå Patcè Locationó below). No÷ thå contentó oæ LÂ arå printeä oî thå outpuô devices¬ thå consolå ió checkeä foò anù pendinç commands¬  anä thå procesó ió repeateä untiì terminateä bù reachinç thå lasô addresó oò bù á commanä froí thå console® Thå symboì tableó compriså twï tablesº aî indeø tablå anä á labeì table® Thå indeø tablå ió constructeä durinç executioî oæ thå  'B§  command®  Iô  containó thå heø valuå  oæ  eacè  1¶  biô argumenô  encountereä  iî  thå  addresó  rangeó  thaô  havå  beeî disassembled®  Iô  alsï  containó flagó whicè indicatå  foò  eacè entrù  thå presencå oæ aî assigneä label¬  thå modå oæ thå  labeì (instructioî  modå oò tablå mode)¬  anä á pointeò tï thå locatioî oæ thå assigneä labeì iî thå seconä (label)table® Thå 'K§ commanä Š 4 A LITTLE INSIGHT deleteó entrieó froí thå index®  Thå 'M§ commanä changeó thå flaç whicè indicateó labeì mode® Thå 'F§ commanä addó it'ó argumenô tï thå indeø tablå iæ iô ió noô alreadù there. Thå  labeì tablå (assigneä labels© ió constructeä  durinç executioî  oæ thå 'L','S'¬  oò 'T§ commands®  Wheî onå  oæ  theså commandó ió given¬ thå labeì specifieä iî thå commanä ió addeä tï thå  labeì  table®  Thå  indeø  tablå ió theî  searcheä  foò  thå correspondinç  heø  valuå  (addresó oæ thå labeì  iî  thå  objecô program© anä á pointeò ió entereä iî thå indeø tablå thaô  pointó tï  thå  labeì entry®  Iæ therå ió nï correspondinç entrù iî  thå indeø table¬  theî onå ió created®  Thus¬ theså commandó alsï acô tï  builä  thå  indeø table®  Thå 'S§ commanä resetó  á  flaç  tï indicatå  thaô  thió labeì belongó tï  aî  instruction®  Thå  'T§ commanä  setó  thå flaç tï indicatå thaô thió labeì belongó tï  á bytå  iî á tablå oæ data®  Thå 'L§ commanä leaveó thå  modå  flaç unchanged. Á  descriptioî  oæ  thå flaç anä pointeò  wordó  foò  thå symboì  tableó ió includeä iî thå implementatioî section®  Iæ yoõ chooså  tï storå thå tableó (oî tapå oò disc¬  foò  example©  foò futurå use¬  theî yoõ musô bå surå tï alsï recorä theså locationó anä restorå theí wheî yoõ restorå thå tables. Mode¬ Modå Character¬ anä Modå Control Thå  characteò  immediatelù followinç thå 'D§ oò  'B§  iî thoså  commandó  ió thå modå character®  Twï modeó arå  possibleº instructioî modå anä tablå mode®  Tablå modå ió specifieä iæ  thå modå characteò ió á 'T'» anù otheò specifieó instructioî mode. Iî  thå instructioî mode¬  byteó froí thå objecô  prograí arå interpreteä aó Z-8° anä 808° instructions. Iî  thå  tablå mode¬  byteó froí thå objecô  prograí  arå interpreteä aó single-bytå constantó whicè arå parô oæ á tablå oæ data. Therå  arå  twï flagó associateä witè modå  control®  Thå modå controì flaç ió seô (oò reset© bù thå modå controì characteò wheî thå 'D§ oò 'B§ commanä ió issueä tï REVAS®  Thå seconä flag¬ thå  modå bit¬  ió parô oæ thå datá storeä foò eacè entrù iî  thå indeø table® Thå modå biô ió seô oò reseô durinç executioî oæ thå 'B','M','S',anä 'T§ commands®  Thå functioî oæ thå 'M§ commanä ió tï  definå thå statå oæ thå modå biô foò á  particulaò  (address© entrù  iî  thå  indeø table¬  creatinç á dummù entrù iæ  nonå  ió presenô wheî thå commanä ió given. Operatioî oæ thå 'D§ Command Thå 'D§ commanä displayó thå disassemblù oî thå  selecteä outpuô  device(s)¬  usinç thå modå controì flaç tï determinå  thå formaô oæ thå output. Š 5 A LITTLE INSIGHT ***Iæ   aî   indeø  tablå  entrù  matchinç  thå   currenô instructioî  oò datá bytå addresó ió encountered¬  theî thå  modå biô  froí thaô tablå entrù replaceó thå modå  controì  flag»  thå outpuô  formaô  (oò mode© ió controlleä foò thió  anä  subsequenô byteó bù thió ne÷ modå controì flag.*** Clearly¬ wheî thå indeø tablå ió emptù (aô thå starô oæ á sessioî  oò afteò thå 'I§ command© alì outpuô formaô ió specifieä bù  thå modå controì character®  Afteò anù oæ thå tablå  buildinç commandó  (B,L,M,S,T© havå beeî executed¬  modå informatioî  froí thå indeø tablå entrieó wilì bå useä aó appropriate. Operatioî oæ thå 'B§ Command Thå 'B§ commanä functionó mucè likå thå 'D§ command®  Onå differencå ió iî thå uså oæ thå modå flags. ***When¬  durinç  disassembly¬  aî indeø tablå  entrù  ió founä whicè matcheó thå currenô instructioî oò bytå address¬  thå modå  biô  oæ  thå  entrù  ió changeä  tï  corresponä  witè  thaô specifieä bù thå currenô modå controì flag.*** Anotheò differencå ió thå tablå buildinç function® Wheî á 1¶  biô  argumenô ió founä iî thå currenô operanä  field¬  iô  ió replaceä bù á synthetiã symboì formeä bù thå concatenatioî oæ  aî 'S§ oò 'T§ anä thå heø representatioî oæ thå argument®  Thå firsô letteò  wilì bå aî 'S§ iæ therå ió nï indeø tablå entry®  Iô wilì bå  eitheò  'S§ oò 'T§ (dependinç oî thå statå oæ thå  modå  bit© wheî aî entrù alreadù exists®  Iæ thió ió thå firsô occurencå  oæ thå  argumenô value¬  theî aî entrù ió createä iî thå indeø tablå whoså  modå biô specifieó instructioî  modå  ('S')®  Later¬  wheî tableó  oæ  datá  arå beinç disassembleä witè thå  'BT§  command¬ thoså  argumentó iî thå indeø tablå thaô refeò tï labeló  iî  thå object-prograí  tablå  areá wilì havå theiò modå bitó changeä  tï specifù tablå ('T'© mode®  Incidentally¬  thå indeø tablå  itselæ caî bå listeä usinç thå 'DT§ command. Notå  thaô  iæ á tablå oæ datá iî thå objecô  prograí  ió disassembleä usinç thå 'B?§ (¿  noô á 'T'© command¬ manù spuriouó argumentó  wilì  bå generateä anä storeä iî thå indeø tablå  witè curiouó effectó durinç lateò listing®  Foò example¬  thå heø codå sequencå  2°  20...(ASCIÉ  blanks©  woulä  bå  interpreteä  aó  á relativå jumð froí thå Z-8° instructioî set¬  anä thå destinatioî oæ  thå jumð woulä bå storeä iî thå indeø aó thå currenô  addresó pluó 20H®  similaò situationó exisô foò codå sequenceó thaô  looë likå LXI¬ SHLD¬ LDA¬ etc.¬ froí thå 8080/Z-8° instructioî sets. Becauså  oæ thå abovå considerations¬  iô ió usuallù besô tï analyså objecô codå initiallù witè thå 'D§ command¬  reservinç thå uså oæ thå 'B§ commanä untiì thå instructioî anä tablå  areaó havå  beeî  located®  Theî thå 'B§ commanä caî bå useä  tï  builä tableó  (anä assigî synthetiã symbols)¬  firsô tï thå instructioî areas¬ anä theî tï thå tableó oæ data® Š 6 A LITTLE INSIGHT 7