home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / genie-commodore-file-library / Information / CAT5-MSGS.ARC / 6.CAT5-930915 < prev   
Encoding:
Text File  |  2019-04-13  |  14.1 KB  |  379 lines

  1.  
  2.  
  3.  program does and how it functions when they reuse the code a year after
  4.  they wrote it.This also helps the person reading the code and gives them
  5.  insight into why the author wrote the routine the way they did.
  6.  
  7.  You are allowed to use the Bellterm code on a few conditions.  The main ones
  8.  being the signing of a license for the code if used commercially.  It is
  9.  covered in the "README" file within the SFX files.
  10.  
  11.  >It seems to me that ML is very difficult to edit.
  12.  That is the value of the source code!  I uploaded some ML tutor programs a
  13. year
  14.  or so back.  Check them out.
  15.  ------------
  16. Category 5,  Topic 33
  17. Message 20        Thu Aug 19, 1993
  18. CBM-ED [e.g.bell]            at 08:49 EDT
  19.  
  20.  Well put John!
  21.  ------------
  22. Category 5,  Topic 33
  23. Message 21        Tue Aug 24, 1993
  24. M.SEABRUM                    at 20:35 EDT
  25.  
  26. Ok. Ok. I have done some reading on a trip to Kansas and on the way back and
  27. everything is kinda falling into place. I have Jim Butterfields book and it's
  28. helping me out alot.
  29.  
  30. Tell me this. I guess I will have to buy a SYMBOLIC ASSEMBLER from TENEX or
  31. somewhere. If I had the source code for say this ML that I am working with, I
  32. can change the address from within the source and it will load at it's new
  33. location changing all the JMPS and JSR's along the way. Right?
  34.  
  35. I guess this might depend on the programmers style. I would like to thank
  36. everyone for introducing me to ML. Now I have ran into something that I'm
  37. total confused about. It's the Logical operators.
  38.  
  39. AND, OR, and EOR. I understand that AND turns bits off, OR does the opposite,
  40. and EOR flips the bit (0 becomes 1, 1 becomes 0).
  41.  
  42. What's the purpose of these operators. I have read and read and still don't
  43. understand them.
  44.  
  45. I know that they are dealing with bits and are very confusing. I'm writing ML
  46. programs [Hand on Experience] thanks to Mr. Butterfield. Little things, not
  47. biggies yet.
  48.  
  49. I'm curious. If I change the error vectors and point them to a area of memory
  50. where I will store a ML program to reboot my BBS if a error occrs, how will I
  51. say Load "Filename",8 in ML?
  52.  
  53. I know I must disable the interrupts before my routine and enable them after
  54. it is complete. Just before I say load the program I guess. Any help?
  55.  
  56.  ------------
  57. Category 5,  Topic 33
  58. Message 22        Tue Aug 24, 1993
  59. C128.JBEE                    at 20:56 EDT
  60.  
  61.  >M.SEABRUM
  62.  >If I had the source code for say this ML that I am working with, I can
  63.  >change  the address from within the source and it will load at it's new
  64.  >location changing all the JMPS and JSR's along the way. Right?
  65.  
  66.  Yes, it is usually as simple as that.
  67.  ------------
  68. Category 5,  Topic 33
  69. Message 23        Wed Aug 25, 1993
  70. R.KNOP1 [Rob Knop]           at 01:17 EDT
  71.  
  72. Re: AND and OR and EOR.  The easiest way to understand these is with a truth
  73. table.  Consider a single bit (with apologies to those in 40 columns):
  74.  
  75.             input2               input2
  76.    AND      ------        OR     ------
  77.              1   0                1   0
  78.  input1: 1   1   0    input1: 1   1   1
  79.          0   0   0            0   1   0
  80.  
  81.   EOR      input2
  82.            ------
  83.             1   0
  84.  input1: 1  0   1
  85.          0  1   0
  86.  
  87. When you do this to the whole byte, you do it bit-by-bit, so, for example:
  88.  
  89.   $35 AND $6D  =     %0011 1001
  90.                  AND %0110 1101
  91.                      ----------
  92.                      %0010 1001  = $29
  93.  
  94.  $35 OR $6D    =     %0011 1001
  95.                  OR  %0110 1101
  96.                      ----------
  97.                      %0111 1101  = $7D
  98.  
  99. As to why would you use this.  Well, once you learn how they work and get a
  100. feel for them, you will start seeing circumstances in which they will be
  101. useful.  For intance, suppose you wanted to test to see if the joystick
  102. firebutton was held down.  However, the register for the joystick actually has
  103. 5 bits controlled by the 'stick: for directions (up, down, left, right) and
  104. the button.  Given that the button is controlled by the highest bit, bit 7,
  105. you could extract the state of the button using:
  106.  
  107.      lda    $DC00      ;Control register for Joystick port 2
  108.      and    #$80       ;$80 = %1000000
  109.  
  110. At this point, the accumulator holds $80 if the button is up, $00 if the
  111. button is pressed, regardless of the direction in which the joystick is being
  112. pushed.
  113.  
  114. Hope this is of some help.
  115.  
  116. Re: buying a symbolic assembler, before you do so be sure to ask folks here
  117. for advise.  There are some that are better than others.  Once you get to the
  118. good ones, though, you will never get all of us here to agree as to which is
  119. the best!  Some will swear by Buddy, others won't budge from Merlin, while
  120. others are addicted to LADS and derivatives.
  121.  
  122. Are you on a 64 or a 128?
  123.  
  124. -Rob
  125.  ------------
  126. Category 5,  Topic 33
  127. Message 24        Wed Aug 25, 1993
  128. CBM-ED [e.g.bell]            at 08:50 EDT
  129.  
  130.  Michael:  You have already gotten some good answers from John and
  131.  Rob, but I'll add a few logs too...
  132.  
  133.   MR> I know that they are dealing with bits and are very confusing.
  134.   MR> I'm writing ML programs [Hand on Experience] thanks to Mr.
  135.   MR> Butterfield. Little things, not biggies yet.
  136.  
  137.  Rob's answer was very good.  I was going to use sprites as an example.
  138.  Sprites are bit controlled... for example, the sprite control register
  139.  turns the eight sprites on and off using a corresponding bit for each
  140.  sprite.  To turn on sprite 1 without affecting the rest of the sprites
  141.  you would, for example, use the instructions:
  142.  
  143.  lda 53269
  144.  ora %00000001
  145.  sta 53269
  146.  
  147.  To turn it off, you would use the instruction:
  148.  
  149.  lda 53269
  150.  and %11111110
  151.  sta 53269
  152.  
  153.  The AND and OR are used so that you can affect just the desired bit or
  154.  bits and leave the ones you don't want to change alone.
  155.  
  156.  EOR has a more practical use, or one that I use all the time.  I use it
  157.  to toggle bits.  For example, if I want something to happen when a flag
  158.  is set (greater than zero) and something else when it is not set (equal
  159.  to zero) I use EOR to toggle a bit in the flag.  This way, I only need
  160.  1 routine with 1 entry point to toggle the flag.  For example:
  161.  
  162.  lda flag
  163.  eor %00000001
  164.  sta flag
  165.  
  166.  Every time you used this bit of code, the variable 'flag' would change
  167.  from 0 to 1 (assuming no other bits are being used as flags).
  168.  
  169.   MR> I'm curious. If I change the error vectors and point them to a
  170.   MR> area of memory where I will store a ML program to reboot my
  171.   MR> BBS if a error occurs, how will I say Load "Filename",8 in ML?
  172.  
  173.  Depends on whether you are doing it in BASIC or ML.  If in BASIC, you 
  174.  will just execute your BASIC program at the appropriate line number,
  175.  something beyond the scope of this answer (tho not all that difficult).
  176.  If in ML, an example might be:
  177.  
  178.  lda length-of-name:ldx #<name.low:ldy #>name.high:jsr setnam
  179.  lda #0:tax:jsr setbnk;       (c128 mode only)
  180.  lda channel:ldx drive number:ldy #$01:jsr setlfs:jsr load
  181.  
  182.  This will do a 'relocating' load to the address in the file header, which
  183.  should work ok for most of your program files.  However, this will not
  184.  do all that you want if the file being loaded is a BASIC file, because
  185.  you will still have to RUN it.  But what you are asking about the error
  186.  vectors will work if you do it right.
  187.  
  188.   MR> I know I must disable the interrupts before my routine and
  189.   MR> enable them after it is complete. Just before I say load the
  190.   MR> program I guess. Any help?
  191.  
  192.  Not sure why you have to do this.  The vectors are not really involved
  193.  with the interrupts, at least not the error vector. & Y N6 j
  194.  ^   I don't think it
  195.  would hurt tho.
  196.  ------------
  197. Category 5,  Topic 33
  198. Message 25        Wed Aug 25, 1993
  199. R.KNOP1 [Rob Knop]           at 22:26 EDT
  200.  
  201. Another clever little use of ora is to check multi-byte values vs. zero.
  202. Suppose you want to test if a 2-byte variable is zero; the most boneheaded way
  203. to do this is (pardon my geoProgrammer accent):
  204.  
  205.       lda  var
  206.       cmp  #$00
  207.       bne  10$
  208.       lda  var+1
  209.       cmp  #$00
  210.       bne  10$
  211.       ;  -- code for var=0
  212.       rts
  213.  
  214.  10$  ;  -- code for var<>0
  215.       rts
  216.  
  217. Now, of course, the cmp's are wholly gratuitous here, since lda will set the Z
  218. flag, so you can shave off four bytes by cutting the code to:
  219.  
  220.       lda var
  221.       bne 10$
  222.       lda var+1
  223.       bne 10$
  224.       ;  -- code for var=0
  225.       rts
  226.  
  227.  10$  ;  -- code for var<>0
  228.       rts
  229.  
  230. However, with the use of the ORA opcode, you can cut of another two bytes:
  231.  
  232.       lda var
  233.       ora var+1
  234.       bne 10$
  235.       ;  -- code for var=0
  236.       rts
  237.  
  238. 10$   ;  -- code for var<>0
  239.  
  240. If you then go to variables longer than two bytes, the savings becomes more
  241. significant.  I have used this method routinely myself in code that needed to
  242. repeatedly check various four-byte variables vs. 0.  Instead of four lda's and
  243. four bne's, I have one lda, three ora's, and one bne -- a savings of three
  244. bne's, or six bytes.
  245.  
  246. -Rob
  247.  ------------
  248. Category 5,  Topic 33
  249. Message 26        Fri Aug 27, 1993
  250. M.SEABRUM                    at 00:29 EDT
  251.  
  252. Thank you guys for all of your input! I really appreciate it. I have saved all
  253. the comments/suggestion concerning this matter and will save it to disk to try
  254. to make some sense out of it. I have a new question now. Don't I always :)!
  255.  
  256. Here we go. As mentioned in a previous statement, I'm basically thru with GM-
  257. BBS V4.0 and it has been released.
  258.  
  259. Since the release, I have noticed a few minor bug. These are dealing with
  260. LINEFEEDS of all things. I was not responsible enough to check the ML to see
  261. if it sends out linefeeds after each carriage return. The linefeeds are added
  262. automatically if the characters going out is sent from within the program.
  263. However, no linefeeds are going out if I read something from a disk. Like a
  264. SEQ file or something. I know if you open the modem channel above 127
  265. linefeeds will follow carriage return. Is that correct? It really does not
  266. matter because it will be too much trouble to go back and change it open
  267. statement. Wait a minute, it should not be that much trouble after all. So I
  268. can get that open as a option. Anyway, the BBS is located at 40960 (A000) and
  269. ends at 42040 (a438).
  270.  
  271. As you can see, the ML is located at the bottom of basic! How in the world can
  272. he get a prgram to enter the bottom of basic [Basic Rom]. I thought ROM meant
  273. 'Read Only Memory' and that it could not be written to. Somehow there's a
  274. trick that lets him do this. Another question, why when I go to disassemble
  275. this ML it does not work.
  276.  
  277. My procedure for editing this ML is as follows:
  278.  
  279. 1) Turn off computer
  280.  
  281. 2) Load Supermon + (w/,8) 3) Type Run [Once in Supermon] l "gm-bbsml-2",08
  282. [Calls the BBSML into memory]. Remember, it's at the bottom of BASIC.
  283.  
  284. After the ML has loaded, I do the following:
  285.  
  286. d +40960
  287.  
  288. It's suppose to disassemble the ML, instead it gives me a whole diffrent
  289. reading... For example:
  290.  
  291. Address 40960 (A000) in the BBS ML read ... brk
  292.  
  293. Ok.. But when I disassemble that address I get something else not the BRK.
  294.  
  295. In other words, I have printed out the ML and when I disassemble it things are
  296. not matching as they suppose to. All the address when disassembled are
  297. something diffrent from what's on the printer paper...
  298.  
  299. Now the second half of the problem ... LINEFEEDS!!
  300.  
  301. When the ML reads a seq or something of the disk LINEFEEDS are not coming thru
  302. or being sent to the modem. I will include the section of the ML that reads
  303. from disk and sends it to the modem. Here we go...
  304.  
  305. 41298 jsr clrchn 41301 ldy #0 41303 sty 41297 41306 sty 41296 41309 ldx #8
  306. 41311 lda #0 41313 jsr chkin 41316 cmp #8 41318 beq 41321 41320 rts
  307.  
  308. 41321 jsr getin 41324 sta 41256,y 41327 iny 41328 cmp #13 41330 beq 41344
  309. 41332 cpy #40 41334 beq 41344 41336 ldx +144 [?] 41338 stx +155 [?] 41340 cpx
  310. #64 41342 bne 41321
  311.  
  312. 41344 ldx +144 [?] 41346 stx +255 [?] 41348 sty 41297 41351 jsr clrchn 41354
  313. ldy #0 41356 lda 41256,y 41359 sta 41019 41362 jsr chrout 41365 ldx 831 send2
  314. modem 0=n 255=y 41368 cpx #0 41370 bne 41395 41372 ldx #5 [Modem] 41374 jsr
  315. chkout 41377 lda 41019 41380 ldx 832 [0=graphics 255=ASC] 41383 cpx #0 41385
  316. cpx #0  [Twice, why?] 41387 beq 41392 41389 jsr 40961 41392 jsr chrout 41395
  317. jsr clrchn 41398 ldx 41296 41401 cpx #0 41403 bne 41408 41405 jsr 41432 41408
  318. iny 41409 cpy 41297 41412 bne 41356 41414 ldx +255 41416 cpx #64 41418 beq
  319. 41426 41420 jmp 41471 [* not included] 41423 jmp 41301 41426 lda #8 41428 jsr
  320. close 41431 close
  321.  
  322. 41432 sty 40960 41435 jsr getin 41438 cmp #0 41440 bne 41461 41442 ldx 831
  323. 41445 cpx #0 41447 bne 41467 41449 ldx #5 41451 jsr chkin 41454 jsr getin
  324. 41457 cmp #0 41459 beq 41467 41461 sta 41296 41464 jsr clrchn 41467 ldy 40960
  325. 41470 rts
  326.  
  327. 40960 brk 40961 cmp #65 40963 bcc 40973 40965 cmp #91 40967 bcs 40973 40969
  328. ora #32 [?] 40971 bne 40983 40973 cmp #93 40975 bcc 40983 40977 cmp #219 40979
  329. bcs 40983 40981 and #127 40983 RTS
  330.  
  331. Ok, there you have it. I was thinking if I relocated the area at location
  332. 40960 and placed it somewhere after the ML at 42040 say 42045 and added a
  333. routine to check the accumlator for a return key ($0D) then print it. A
  334. linefeed ($0A) will loaded into the accumulator and printed right after the
  335. return ($0D). I guess I will have to stash the contents of the accumulator
  336. away before I load it with the carriage return and linefeed. This area we are
  337. working in is a CALL FROM JSR. Therefore I was thinking the accumulator should
  338. be exactly what it was when the routine was called. So I'll stash the
  339. accumulator away when the routine is first called and will load it contents
  340. back in from memory when this routine is finished. This way, the accumulator
  341. is not altered.
  342.  
  343. How does this all sound? You think it will work? Please help.
  344.  
  345. DON'T FORGET to instruct me how to disassmeble this thing from the BOTTOM OF
  346. BASIC.
  347.  
  348. Notes on ML program listed above:
  349.  
  350. [?]= What's the function of the statement.
  351.  
  352. All of this just to add a LINEFEED to data going out from disk. Is there a
  353. easier way?
  354.  
  355. P.S. I know I will have to ADD JMP at address 40961. The JMP will point to the
  356. new address location (42045)
  357.  
  358. Any help. I know it's quite a shopping list.
  359.  
  360.  ------------
  361. Category 5,  Topic 33
  362. Message 27        Mon Aug 30, 1993
  363. CBM-MARK                     at 23:46 EDT
  364.  
  365.  Whenever you want to send a formatted list, like the source listing in the
  366.  previous message, use '*sn' to send the message.  The formatting won't be
  367.  all messed up.
  368.  
  369.                 Mark ;)
  370.  ------------
  371. Category 5,  Topic 33
  372. Message 28        Tue Aug 31, 1993
  373. M.SEABRUM                    at 03:35 EDT
  374.  
  375. I see. You can delete the message because the problem has been solved.
  376. Thanks..
  377.  ------------
  378.