Jump to content
GDMike

Assembly code samples

Recommended Posts

Posted (edited)
18 hours ago, TheBF said:

I haven't test this but I think you could make a toggle function like this.

* TOGGLE higlight/normal
    LI  R0,STRPNT
    LI  R1,STRLEN
    LI  R2,>8000
LOOP    XOR R2,*R0+
        DEC R1
        JNE LOOP
 

 

No, you can't, because the destination of XOR is a register, nothing else. Only the source is a general address. So this takes a more complex route.

* TOGGLE higlight/normal
	LI  R0,STRPNT
	LI  R1,STRLEN
	LI  R2,>8000
LOOP    MOVB *R0,R3
	XOR  R2,R3
	MOVB R3,*R0+
	DEC  R1
	JNE  LOOP
 

However, if you have a table of bitmasks, where you want to calculate which one to apply to a register, then you can do that in one operation. XOR @BITTABLE(R5),R3 is perfectly legal.

The reason they have to limit the functionality of instructions like this one is that to have two general addresses in the instruction requires twelve bits. That means only four bits are remaining for the opcode, i.e. enough to describe 16 instructions. The TMS 9900 implements twelve instructions with two general addresses. The remaining four opcodes indicate that the opcode is longer than four bits. That's no problem for instructions requiring only one general address, like INC or CLR, since their general addresses will occupy six bits, leaving ten for the opcode. But for instructions like XOR and MPY, it is. They have to go down to ten bits for addresses, one four bit register number and one six bit general address.

Edited by apersson850
  • Like 2

Share this post


Link to post
Share on other sites

Ah yes I see. 

Thanks

16 hours ago, apersson850 said:

No, you can't, because the destination of XOR is a register, nothing else. Only the source is a general address. So this takes a more complex route.

* TOGGLE higlight/normal
	LI  R0,STRPNT
	LI  R1,STRLEN
	LI  R2,>8000
LOOP    MOVB *R0,R3
	XOR  R2,R3
	MOVB R3,*R0+
	DEC  R1
	JNE  LOOP
 

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
On 7/18/2020 at 2:10 PM, GDMike said:

I haven't had success with the earlier one. 

I'll save Lee's version, and push yours into where I had Lee's.

Is your version asking for the same parameters as Lee's? R0,R1,R2,R3

And your moving what you neeed from those? If not, I'll have to find out where and how to get my Params to where you need them.

I'm only Searching 860 bytes at a given address.  

Can you make it like Lee's, just take my 3 values, length of search word, starting address, buffer length and returning me an address or zero?

I must add this: I think this comes from thinking forth, Lee sets up the argument needs quite well, asking for parameters to be passed to his routines. I admire this thinking.

 

 

Hope this does what you want! I did try to match Lee Stewart's parameters.

 

...It's passed a few more tests than its predecessors.

 

       AORG >FE00
QUERI  TEXT 'COMEFINDMEBRO'

       AORG >A000
SAVRT  DATA 0
VALID  DATA 0
SEARCH MOV  R11,@SAVRT
       LI   R12,>4100
       LI   R13,>5A00
       LI   R14,>6100
       LI   R15,>7A00
       MOV  R0,R4
       MOV  R1,R10
       MOV  R2,R6
       MOV  R3,R9
CMPARE CB   *R6,*R0+
       JEQ  NEXT
       DEC  R1
       JNE  CMPARE
       BL   @CASE
       JEQ  NEXT
OUTNO  CLR  R0
       JMP  BYE
NEXT   MOV  R0,R5
CONT   MOV  R1,10
       MOV  R0,R4
       DEC  R9
       JEQ  OUTYES
       CI   R1,0
       JEQ  OUTNO
       INC  R6
       DEC  R1
       CB   *R6,*R0+
       JEQ  CONT
       BL   @CASE
       JEQ  CONT
       DEC  R1
       JEQ  OUTNO
RESTAR MOV  R5,R0
       JMP  SEARCH
OUTYES S    R3,R0
BYE    MOV  @SAVRT,R11
       RT

CASE   CB   *R6,R12
       JLT  OUT
       CB   *R6,R13
       JGT  HIVAL
       MOVB *R6,R8
       AI   R8,>2000
       JMP  SCAN1B
HIVAL  CB   *R6,R14
       JLT  OUT
       CB   *R6,R15
       JGT  OUT
       MOVB *R6,R8
       AI   R8,->2000
SCAN1B MOV  R4,R0
       MOV  R10,R1
SCANB  DEC  R1
       JEQ  OUT
       CB   R8,*R0+
       JNE  SCANB
OUT    RT

       AORG >B008
TEST   TEXT 'COMEFINDMEBRO'

*  TEST PROGRAM  *

       AORG >AA00
       DEF  START
       REF  VMBW
BUFF   TEXT 'HAHA...'
START  LI   R0,>B000
       LI   R1,960
       LI   R2,QUERI
       LI   R3,13
       BL   @SEARCH
       CI   R1,0
       JEQ  NOTFND
FOUND  MOV  R0,R1
       LI   R12,>F000
       SZC  R12,R0
       MOV  R3,R2
       BLWP @VMBW
       JMP  WAIT
NOTFND CLR  R0
       LI   R1,BUFF
       LI   R2,5
       BLWP @VMBW
WAIT   JMP  WAIT
       END

|:)

 

Edited by HOME AUTOMATION
  • Thanks 1

Share this post


Link to post
Share on other sites

Great, ok. I'll be beeezy at the house this week. I'll get back to this next week.

Thanks all

Share this post


Link to post
Share on other sites
On 7/16/2020 at 3:12 PM, Lee Stewart said:

 

Like I said, I am not convinced it is foolproof. The routine is currently restarting the search after a failure on the mismatched character. I am thinking it should probably start at the second matched character, i.e., move the search window by only one character upon failure.

 

Here is a case-sensitive search routine that is more robust than my last one [Note—See better version in post #151]:

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* String Search Routine                     ..Lee Stewart 20JUL2020 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                   *
*   BL to this routine.                                             *
*                                                                   *
*   Input                                                           *
*     R0: Starting address to search                                *
*     R1: Search range (i.e., length of search buffer)              *
*     R2: Address of search string                                  *
*     R3: Length of search string                                   *
*                                                                   *
*   Output                                                          *
*     R0: 0--if not found..address--if found                        *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
SEARCH MOV  R2,R4          ; copy search string address
       MOV  R3,R5          ; copy search string size
       INC  R1             ; adjust range for next instruction
SLOOP  DEC  R1             ; decrement search range
       JEQ  SNFND          ; to SNFND if out of range
       CB   *R4,*R0+       ; first char of search string found?
       JNE  SLOOP          ; if not, check next char
       INC  R4             ; if so, set to second search char
       MOV  R0,R6          ; save buffer restsrt location
       MOV  R1,R7          ; save buffer restart range+1
       DEC  R7             ; correct restart range
SLOOP1 DEC  R5             ; decrement search char count
       JEQ  SFOUND         ; if done, string is found!
       DEC  R1             ; decrement search range
       JEQ  SNFND          ; to SNFND if out of range
       CB   *R4+,*R0+      ; next char found?
       JEQ  SLOOP1         ; if so, check next char
       MOV  R6,R0          ; if not, get buffer restart address
       MOV  R7,R1          ; get buffer restart range
       JMP  SEARCH         ; reset search string parameters
SNFND  CLR  R0             ; string not found in range
       RT                  ; return with R0 = 0
SFOUND S    R3,R0          ; we found it! correct address
       RT                  ; return with address of found string

 

...lee

  • Thanks 1

Share this post


Link to post
Share on other sites
4 hours ago, Lee Stewart said:

 

Here is a case-sensitive search routine that is more robust than my last one:

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* String Search Routine                     ..Lee Stewart 20JUL2020 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                   *
*   BL to this routine.                                             *
*                                                                   *
*   Input                                                           *
*     R0: Starting address to search                                *
*     R1: Search range (i.e., length of search buffer)              *
*     R2: Address of search string                                  *
*     R3: Length of search string                                   *
*                                                                   *
*   Output                                                          *
*     R0: 0--if not found..address--if found                        *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
SEARCH MOV  R2,R4          ; copy search string address
       MOV  R3,R5          ; copy search string size
       INC  R1             ; adjust range for next instruction
SLOOP  DEC  R1             ; decrement search range
       JEQ  SNFND          ; to SNFND if out of range
       CB   *R4,*R0+       ; first char of search string found?
       JNE  SLOOP          ; if not, check next char
       INC  R4             ; if so, set to second search char
       MOV  R0,R6          ; save buffer restsrt location
       MOV  R1,R7          ; save buffer restart range+1
       DEC  R7             ; correct restart range
SLOOP1 DEC  R5             ; decrement search char count
       JEQ  SFOUND         ; if done, string is found!
       DEC  R1             ; decrement search range
       JEQ  SNFND          ; to SNFND if out of range
       CB   *R4+,*R0+      ; next char found?
       JEQ  SLOOP1         ; if so, check next char
       MOV  R6,R0          ; if not, get buffer restart address
       MOV  R7,R1          ; get buffer restart range
       JMP  SEARCH         ; reset search string parameters
SNFND  CLR  R0             ; string not found in range
       RT                  ; return with R0 = 0
SFOUND S    R3,R0          ; we found it! correct address
       RT                  ; return with address of found string

 

...lee

Lee,

 

Just want to confirm, R1 is set to the length, and NOT the last address to search?

 

Beery

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, BeeryMiller said:

Just want to confirm, R1 is set to the length, and NOT the last address to search?

 

That is correct.

 

Your question, though, has sparked an idea for reducing the code size. Input for R1 will still be the buffer length, however.

 

...lee

  • Like 1

Share this post


Link to post
Share on other sites
27 minutes ago, Lee Stewart said:

Your question, though, has sparked an idea for reducing the code size. Input for R1 will still be the buffer length, however.

 

Here is the more tightly coded String Search Routine alluded to above (3 fewer instructions):

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* String Search Routine (Case Sensitive)    ..Lee Stewart 20JUL2020 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                   *
*   BL to this routine.                                             *
*                                                                   *
*   Input                                                           *
*     R0: Starting address to search                                *
*     R1: Search range (i.e., length of search buffer)              *
*     R2: Address of search string                                  *
*     R3: Length of search string                                   *
*                                                                   *
*   Output                                                          *
*     R0: 0--if not found..address--if found                        *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
SEARCH A    R0,R1          ; point R1 to address past end of buffer
SRCH1  MOV  R2,R4          ; copy search string address
       MOV  R3,R5          ; copy search string size
SLOOP  C    R0,R1          ; check range
       JEQ  SNFND          ; to SNFND if out of range
       CB   *R4,*R0+       ; first char of search string found?
       JNE  SLOOP          ; if not, check next char
       INC  R4             ; if so, set to second search char
       MOV  R0,R6          ; save buffer restsrt location
SLOOP1 DEC  R5             ; decrement search char count
       JEQ  SFOUND         ; if done, string is found!
       C    R0,R1          ; check range
       JEQ  SNFND          ; to SNFND if out of range
       CB   *R4+,*R0+      ; next char found?
       JEQ  SLOOP1         ; if so, check next char
       MOV  R6,R0          ; if not, get buffer restart address
       JMP  SRCH1          ; reset search string parameters
SNFND  CLR  R0             ; string not found in range
       RT                  ; return with R0 = 0
SFOUND S    R3,R0          ; we found it! correct address
       RT                  ; return with address of found string

 

...lee

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
On 7/17/2020 at 9:49 AM, BeeryMiller said:

Now, only if the search string function was case insensitive...……………………...

 

On 7/17/2020 at 10:18 AM, Lee Stewart said:

That should not be too difficult. I will work on it.

 

OK—Here is a case-insensitive version of my string search routine, with @apersson850’s improvement included:

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* String Search Routine (Case Insensitive)  ..Lee Stewart 22JUL2020 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                   *
*   BL to this routine.                                             *
*                                                                   *
*   Input                                                           *
*     R0: Starting address to search                                *
*     R1: Search range (i.e., length of search buffer)              *
*     R2: Address of search string                                  *
*     R3: Length of search string                                   *
*                                                                   *
*   Output                                                          *
*     R0: 0--if not found..address--if found                        *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
SEARCH MOV  R11,R12        ; save return address

* Make search string uppercase (UC)
       CLR  R7             ; zero R7 for UC comparisons
       MOV  R2,R4          ; copy search string address
       MOV  R3,R5          ; copy search string size
SRCH1  MOVB *R4,R7         ; move next char to R7
       BL   @UPCASE        ; force char to UC
       MOVB R7,*R4+        ; copy UC char to search string
       DEC  R5             ; decrement string length
       JNE  SRCH1          ; check next char if not done

* Look for a match  to the first search char
       A    R0,R1          ; point R1 to address past end of buffer
SRCH2  MOV  R2,R4          ; copy search string address
       MOV  R3,R5          ; copy search string size
SLOOP  C    R0,R1          ; check range
       JEQ  SNFND          ; to SNFND if out of range
       MOVB *R0+,R7        ; copy next char for UC conversion
       BL   @UPCASE        ; force char to UC
       CB   *R4,R7         ; first char of search string found?
       JNE  SLOOP          ; if not, check next char

* Look for rest of search string
       INC  R4             ; if so, set to second search char
       MOV  R0,R6          ; save buffer restsrt location
SLOOP1 DEC  R5             ; decrement search char count
       JEQ  SFOUND         ; if done, string is found!
       C    R0,R1          ; check range
       JEQ  SNFND          ; to SNFND if out of range
       MOVB *R0+,R7        ; copy next char for UC conversion
       BL   @UPCASE        ; force char to UC
       CB   *R4+,R7        ; next char found?
       JEQ  SLOOP1         ; if so, check next char

* Start over after first char match
       MOV  R6,R0          ; if not, get buffer restart address
       JMP  SRCH2          ; reset search string parameters

* Found/not-found returns
SNFND  CLR  R0             ; string not found in range
       B    *R12           ; return with R0 = 0
SFOUND S    R3,R0          ; we found it! correct address
       B    *R12           ; return with address of found string

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Uppercase Character Conversion Routine    ..Lee Stewart 20JUL2020 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                   *
*   BL to this routine.                                             *
*                                                                   *
*   Input                                                           *
*     R7: Character to convert in MSB..0 in LSB                     *
*                                                                   *
*   Output                                                          *
*     R7: Character possibly converted to uppercase (UC) in MSB     *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

UPCASE CI   R7,>6100       ; compare char to 'a'
       JL   UPCXIT         ; return if lower
       CI   R7,>7A00       ; compare char to 'z'
       JH   UPCXIT         ; return if higher
       ANDI R7,>DF00       ; force char to UC
UPCXIT RT                  ; return to caller

 

Because the main routine is using 9 registers (10, if you count R11), it might be better to BLWP to the routine with its own registers. That would also allow the uppercase conversion routine to use a lower-numbered register rather than the awkward R7, which makes it a little more difficult to use as a general-purpose routine.

 

...lee

Edited by Lee Stewart
Code Improvement...
  • Like 1

Share this post


Link to post
Share on other sites
SEARCH MOV  R11,R12        ; save return address

* Make search string uppercase (UC)
       CLR  R7             ; zero R7 for UC comparisons
       MOV  R2,R4          ; copy search string address
       MOV  R3,R5          ; copy search string size
SRCH1  MOVB *R4,R7         ; move next char to R7
       BL   @UPCASE        ; force char to UC
       MOVB R7,*R4+         ; copy UC char to search string AUTOINCREMENT
       DEC  R5             ; decrement string length
       JNE  SRCH1          ; check next char if not done

By using autoincrement, you can remove one instruction at the beginning.

  • Like 2

Share this post


Link to post
Share on other sites

I'll test within my SNP program, probably over the weekend, I really can't wait, but my computer's are tied up restoring files from a crashed 1tb drive, so it's a little beezy. But I really am happy to see this.

Thanks again!!

Share this post


Link to post
Share on other sites

Lee,

 

I typed in the case sensitive version last night.  Someplace, I must be doing something wrong and still trying to debug things as my string is not being found.  Just wanted to let you know that I do REALLY appreciate the time you put into writing the code and it isn't going to the netherworld.

 

I should have time tonight to update the code to use your case insensitive version which should remove my case conversion code.  Somewhere, something is staying in a loop and I haven't figured out where yet.

 

The ANDI R7,>DF00 piece of code...… I will need to check to see if that leaves the space character >20 and the >0D character unmodified for my particular situation.

 

What I am doing with my code is reading in a DIS/VAR 80 file with 40 character max line lengths, then copying them into a CPU buffer.  The last character (variable length) is >0D with two more characters after each buffer of >0D,>00.  Each buffer before copying the string into it is filled with >00 as my display/send routine terminates with >00.

 

If I find a hit in the 4 x 40 lines, plus 4 x 2 (>0D,>00) with a total of 168 bytes, then I display the 4 lines.

 

I'm searching a DIS/VAR 80 file for a string when someone wants to find a file.  After I get this working the way I want, I will add another check to the BBS code to avoid the BBS display on the Sysop end of things to speed things up further.

 

Beery

 

  • Like 2

Share this post


Link to post
Share on other sites
40 minutes ago, BeeryMiller said:

 

The ANDI R7,>DF00 piece of code...… I will need to check to see if that leaves the space character >20 and the >0D character unmodified for my particular situation.

 

That piece of code only executes if the character is in the 'a' -- 'z' range, so you're safe.

 

...lee

  • Like 2

Share this post


Link to post
Share on other sites

There's a thing to think about if you do this for the Swedish language instead. Then you have to extend the range by three, since some special Swedish charactes occupy the codes for [\] and {|}, for upper and lower case. Something similar is true for German etc.

  • Like 1

Share this post


Link to post
Share on other sites
24 minutes ago, apersson850 said:

There's a thing to think about if you do this for the Swedish language instead. Then you have to extend the range by three, since some special Swedish charactes occupy the codes for [\] and {|}, for upper and lower case. Something similar is true for German etc.

This is just for informational purposes.  Does the TI-99/4A (PAL version???) have different keycodes/definitions for those characters?  Or, is that more of a Windows/Mac keyboard/font support?  I always thought the keys were standard for the TI-99/4A whether European or US.

 

I just always assumed there was only the difference in NTSC/PAL, not other font/key issue on the TI-99/4A.  Maybe I am wrong, but I though some of the special language versions of the cartridges that were out there just redefined the character definition table when they were used.


Beery

 

  • Like 1

Share this post


Link to post
Share on other sites

the keyboard and innner functions (ASCII-codes) are identical, only difference came with the character definition files (CHARA1) in e.g. TI-Writer. You had to type [ for Ä, { for ä, \ for Ö, ] for Ü and so on (German language)

  • Like 2

Share this post


Link to post
Share on other sites
7 minutes ago, jens-eike said:

the keyboard and innner functions (ASCII-codes) are identical, only difference came with the character definition files (CHARA1) in e.g. TI-Writer. You had to type [ for Ä, { for ä, \ for Ö, ] for Ü and so on (German language)

OK, that makes sense.

  • Like 1

Share this post


Link to post
Share on other sites

I can't wait to get into my system (s) to try this. I agree, I absolutely appreciate this work,time put into it too. I'm just sad I couldn't come up with the fix, I got close but, I couldn't stay focused long enough with so many things going on here, over the weekend I hope to have a video done with this piece applied.

 

 

Share this post


Link to post
Share on other sites
14 minutes ago, GDMike said:

 I couldn't stay focused long enough with so many things going on here, over the weekend I hope to have a video done with this piece applied.

 

 

I know how you feel.  I work 4 x 10's, so I always have Sat-Sun-Mon off.  This past weekend, my Sat. and Mon. were very energy intensive work outside that when I came back into the house, I chose to watch TV in the Man Cave (55"), rather than going into my office to turn on the Geneve and watching TV on the 32".  I just wanted to relax.  I did spend an hour modifying code last night after finally being able to sit down, relax, and unwind.

 

I'm hoping now it will rain this afternoon so I can put off mowing grass this evening when I get home.

 

Beery

 

 

 

  • Haha 1

Share this post


Link to post
Share on other sites
2 hours ago, jens-eike said:

the keyboard and innner functions (ASCII-codes) are identical, only difference came with the character definition files (CHARA1) in e.g. TI-Writer. You had to type [ for Ä, { for ä, \ for Ö, ] for Ü and so on (German language)

And with Swedish definitions, you would use the same keys for Ä, Ö and Å. Unfortunately, the common ASCII definitions for Swedish and German hade the two identical characters, Ä and Ö, on the same codes. That left us in Sweden with Å following Ä and Ö. But the correct alphabetical order in Swedish is ÅÄÖ, so everything sorted with computers (without special handling) these days always had the wrong alphabetical order! The Swedish alphabet is ABC...XYZÅÄÖ, but in German, you don't really see any difference between O and Ö in that aspect.

Share this post


Link to post
Share on other sites
13 hours ago, Lee Stewart said:

 

 

OK—Here is a case-insensitive version of my string search routine, with @apersson850’s improvement included:

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* String Search Routine (Case Insensitive)  ..Lee Stewart 22JUL2020 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                   *
*   BL to this routine.                                             *
*                                                                   *
*   Input                                                           *
*     R0: Starting address to search                                *
*     R1: Search range (i.e., length of search buffer)              *
*     R2: Address of search string                                  *
*     R3: Length of search string                                   *
*                                                                   *
*   Output                                                          *
*     R0: 0--if not found..address--if found                        *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
SEARCH MOV  R11,R12        ; save return address

* Make search string uppercase (UC)
       CLR  R7             ; zero R7 for UC comparisons
       MOV  R2,R4          ; copy search string address
       MOV  R3,R5          ; copy search string size
SRCH1  MOVB *R4,R7         ; move next char to R7
       BL   @UPCASE        ; force char to UC
       MOVB R7,*R4+        ; copy UC char to search string
       DEC  R5             ; decrement string length
       JNE  SRCH1          ; check next char if not done

* Look for a match  to the first search char
       A    R0,R1          ; point R1 to address past end of buffer
SRCH2  MOV  R2,R4          ; copy search string address
       MOV  R3,R5          ; copy search string size
SLOOP  C    R0,R1          ; check range
       JEQ  SNFND          ; to SNFND if out of range
       MOVB *R0+,R7        ; copy next char for UC conversion
       BL   @UPCASE        ; force char to UC
       CB   *R4,R7         ; first char of search string found?
       JNE  SLOOP          ; if not, check next char

* Look for rest of search string
       INC  R4             ; if so, set to second search char
       MOV  R0,R6          ; save buffer restsrt location
SLOOP1 DEC  R5             ; decrement search char count
       JEQ  SFOUND         ; if done, string is found!
       C    R0,R1          ; check range
       JEQ  SNFND          ; to SNFND if out of range
       MOVB *R0+,R7        ; copy next char for UC conversion
       BL   @UPCASE        ; force char to UC
       CB   *R4+,R7        ; next char found?
       JEQ  SLOOP1         ; if so, check next char

* Start over after first char match
       MOV  R6,R0          ; if not, get buffer restart address
       JMP  SRCH2          ; reset search string parameters

* Found/not-found returns
SNFND  CLR  R0             ; string not found in range
       B    *R12           ; return with R0 = 0
SFOUND S    R3,R0          ; we found it! correct address
       B    *R12           ; return with address of found string

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Uppercase Character Conversion Routine    ..Lee Stewart 20JUL2020 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                   *
*   BL to this routine.                                             *
*                                                                   *
*   Input                                                           *
*     R7: Character to convert in MSB..0 in LSB                     *
*                                                                   *
*   Output                                                          *
*     R7: Character possibly converted to uppercase (UC) in MSB     *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

UPCASE CI   R7,>6100       ; compare char to 'a'
       JL   UPCXIT         ; return if lower
       CI   R7,>7A00       ; compare char to 'z'
       JH   UPCXIT         ; return if higher
       ANDI R7,>DF00       ; force char to UC
UPCXIT RT                  ; return to caller

 

Because the main routine is using 9 registers (10, if you count R11), it might be better to BLWP to the routine with its own registers. That would also allow the uppercase conversion routine to use a lower-numbered register rather than the awkward R7, which makes it a little more difficult to use as a general-purpose routine.

 

...lee

I've got this code working and finally found my coding error.  I had an INC instruction in the wrong place that was incrementing the string length too early before testing for a termination character.

 

Glad that monkey is off my back.  Now, to clean it up as I am searching a file that is just over 3300 sectors in length and it just takes time to search that much data.


Beery

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
On 7/22/2020 at 12:06 PM, BeeryMiller said:

I know how you feel.  I work 4 x 10's, so I always have Sat-Sun-Mon off.  This past weekend, my Sat. and Mon. were very energy intensive work outside that when I came back into the house...

I worked those hours for years and years.

This weekend may also be tough for me, I'm looking to pull the PEB power supply and add this extra ATX 800 watt supply and fan, but I gotta make sure I can find all the power needed first.

This code is looking so beautiful!

 

Well,, gotta mow the yard.

 

Edited by GDMike

Share this post


Link to post
Share on other sites

It's been awhile since my last message, and I just wanna say, yippppeeee!!

I just added in the:

-----------------------------------------------------

OK—Here is a case-insensitive version of my string search routine, with @apersson850’s improvement included:

-------------------------------------------------------

and it's just superb! Here's a video I made showing, what I did with it in SNP.

I've yet to add it for each page, this is just a page 1 example find, but it will basically find the occurrence and load that page up and put the cursor on the first word found. I will make an option once found: to C - continue, S- stop SEARCHING and I thought there was something else, but I've forgotten what it was, I suppose I'll figure it out later. But rt now, this is impressive.

thanks very much again for showing your talent.

 

Edited by GDMike

Share this post


Link to post
Share on other sites

Thanks so very much for the code assistance!!! It's absolutely beautiful.

 

Haha.. regarding the flaming tree,  on the right side of this video, nope, no explosions, byt they've just cut the tree down and left the trunk about a foot above ground. No one wants to be the one to finish the job. Haha..

Edited by GDMike

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...