home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / Information / MACHINE-LANGUAGE-PART-2 < prev    next >
Encoding:
Text File  |  2019-04-13  |  6.8 KB  |  179 lines

  1.               Machine Language for Beginners (Part 2)
  2.                          by
  3.                      Lyle Giese
  4.                  DELPHI Mail:  LYLEG
  5.  
  6.    One of the Tools of the trade for Machine Language Programing!  
  7.  
  8. When you wanted to learn about BASIC you read and played directly 
  9. with BASIC programs. Using the BASIC editor, you listed programs to 
  10. the screen and printer,  
  11. wrote simple programs, and modifyed others. In order to do that you 
  12. used BASIC itself in the form of its editor. The equivelent of that 
  13. for ML is the Monitor. There are several good PD monitors availible 
  14. and we have some of them in our databases in the Flagship under 
  15. Languages & ML.  
  16.  
  17. One of the simpler ones is Supermon, writen by Jim Butterfield. It's 
  18. features became the standard for monitors and most monitors have more 
  19. features, but they are generally supersets of the instructions found 
  20. in Supermon. That is the other  
  21. monitors took Supermon and added more features with out changing any 
  22. of the features or syntax of the commands found in Supermon. Micromon 
  23. is one of them and there is more that one version of it around. The 
  24. main difference in them is where in memory the program is loaded and 
  25. run from. One of the features that Micromon added was to be ability 
  26. to output the disassembly to a printer.  
  27. So if you use Supermon and can use all of the instruction in it, you 
  28. won't have much trouble upgrading to a better one. By the way one of 
  29. my favorites that I use is 'HESMON' from Hesware. When I am doing 
  30. some heavy duty work I use that because it is in cartiridge form. 
  31. When I lock up the computer, it is right there  
  32. when I power back up, but it does have the disadvantage of occupying 
  33. memory from  $8000 to $9FFF. It too follows the basic syntax of
  34. Supermon.  
  35.  
  36. To use Supermon, load "SUPERMON",8 and run. It has now sealed itself 
  37. off up at the top of basic. If you exit Supermon, you can go back by 
  38. SYS(peek(55)+peek(56)*256). When it first boots up and after the
  39. title you see:  
  40.  
  41.      PC  SR AC XR YR SP
  42.  .;  0000 01 02 03 04 05 .  
  43.  
  44. If you type any commands they will be displayed on the third line 
  45. right after the period.  
  46. This will be the same display that you will get after typing the 'R' 
  47. command.
  48.  Two notes: all commands are followed by a carriage return in 
  49. order to be executed and all adresses and numbers are in Hex even 
  50. though they are not prefixed  
  51. with a '$'. The 'R' command is for displaying the registers.  
  52. The first line identifies the registers. The second line shows the 
  53. contents of them, and of course will be different that that shown. 
  54. The first is the Program Counter. The second is the Status Register, 
  55. this is where those flags are that we use in our branch instructions. 
  56. The next one is the A register or Accumulator. The fourth is the X 
  57. register followed by Y Register. And the last one is the Stack 
  58. Pointer, that is the index into the stack pointing to the next 
  59. availible storage position.  
  60.  
  61. The rest of the commands are as follows:
  62.  
  63.  .A C000 LDA #$00
  64.  
  65.  This starts 
  66. a single line assembly at $C000(49152) with the instruction LDA #$00. 
  67. Of course you will use any instruction that your program needs. The 
  68. assembler will check the syntax of the instruction(if it doesn't like 
  69. it, it will  
  70. respond with a ? on the same line.) and on the next line respond with 
  71. the next address for you. Like this:  
  72.  
  73. .A C002  
  74.  
  75. So after the first line the assembler will supply the address. When 
  76. you are finished simply type a return to get out of the assemble 
  77. mode.  
  78.  
  79. .C 1000 1010 0E  
  80.  
  81. This command calculates the offset needed for branch instructions. 
  82. The first address is where the branch instruction is and the second 
  83. is the destination address. The monitor will calculate the 
  84. offset ($0E).  
  85. This command, in my opinion, is of little value. When writing with 
  86. this assembler, it calculates branches for you by you specifying the 
  87. target address in the instruction, such as;
  88.  
  89.  .A C011 BNE C01F
  90.  
  91.  However, 
  92. sometimes you need to do a forward branch (as in the above example) 
  93. and you are not sure where the target will be until you code all the 
  94. instructions. In that case it would be easy to branch to the same 
  95. instruction as you are on. Jot down the address for that instruction 
  96. and later fill in the exact address you will need.
  97.  
  98.  .A C011 BNE C011 
  99.  
  100. You would need to write down $C011. Later after you wrote the code 
  101. you want to branch around, you find out you want to branch to C01F: 
  102.  
  103. .A C011 BNE C01F  
  104. .D C000  
  105.  
  106. This will disassemble 22 instructions starting at $C000. The display 
  107. can be modified and entered by using the cursor keys and hitting the 
  108. return key while on the line being modified. To see the next set of 
  109. instructions, (the cursor is on the space after the period of the 
  110. last line) type 'D' and return.  
  111.  
  112. .F CE00 CF00 FF  
  113.  
  114. This monitor instruction will fill the memory from $CE00 to $CF00, 
  115. inclusive, with the value $FF.  
  116.  
  117. .G C000  
  118.  
  119. This is simular to the 'SYS' instruction in BASIC except the number 
  120. is expected to be in Hex instead of decimal. Also if no start address 
  121. is given, the monitor will go to the address currently shown in the 
  122. PC register.  
  123.  
  124. .H C000 D000 'READ  
  125.  
  126. This command will Hunt from $C000 to $D000 for the occurence of the 
  127. ASCII string  
  128. 'READ'. It will respond with the addresses where it is found(if any). 
  129.  
  130.  .L "Filename" 08  
  131.  
  132. Will load the program 'Filename' from device 8. If you don't specify 
  133. a device Supermon will default to the cassette drive.  
  134.  
  135. .M C000 C02F  
  136.  
  137. This command will show a hex dump of the memory locations from $C000 
  138. to $C02F. Like this:
  139.  
  140.  .:  C000 00 01 02 03 04 05 06 07
  141.  
  142.  Some of the 
  143. newer monitors also give you an ASCII representation of the bytes to  
  144. the right of the numbers. Again the information can be modifyed and 
  145. changed by editing and hitting return for each line.  
  146.  
  147. .R
  148.  
  149.       PC  SR AC XR YR SP
  150.  .;  C000 01 02 03 04 05  
  151.  
  152. This command returns a display of the current register commands in 
  153. the following  
  154. order: Program Counter, Status Register, Accumlator, X Register, Y 
  155. Register, and  Stack Register.  
  156.  
  157. .S "filename",08,C000,C101  
  158.  
  159. This command saves an area of memory under 'filename' to device 08. 
  160. The memory saved is from $C000 to $C100. THIS IS IMPORTANT! All 
  161. Commodore monitors do NOT save that byte under the specified ending 
  162. adress. You must specify the ending address +1 of your program.  
  163.  
  164. .T C000 C100 CE00  
  165.  
  166. This command copies or transfers the contents of memory locations 
  167. $C000-$C100 to $CE00-$CF00.  
  168.  
  169. .X  
  170.  
  171. This is the last command in our long journey today. This command 
  172. returns to our friendly(?) BASIC. Remember to return to 
  173. Supermon-SYS(PEEK(55)+256*PEEK(56)).  
  174.  
  175. This was a journey one of the tools of the trade for ML work. For 
  176. more information stay tuned for an article on help with 
  177. MADS, Commodore's label based assembler.  
  178.  
  179.