Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.msdos.programmer > #3256

Re: scan for a-z

Message-Id <otnjof-ni1.ln1@aretha.foo>
From Peter 'Shaggy' Haywood <phaywood@alphalink.com.au>
Subject Re: scan for a-z
Newsgroups comp.os.msdos.programmer
Date 2019-04-17 23:56 +1000
References <ja45aepid2pe3kgka19s1011br325ph479@4ax.com> <c227f968-52f0-4285-8b73-2f13343c9016@googlegroups.com> <alpine.BSF.2.02.1904021237040.63863@frieza.hoshinet.org> <ic47aede9ffq719atu7kbiikaemr0ecokr@4ax.com>

Show all headers | View raw


Groovy hepcat T. Ment was jivin' in comp.os.msdos.programmer on Wed, 3
Apr 2019 03:48 am. It's a cool scene! Dig it.

> On Tue, 2 Apr 2019 12:40:41 -0400, Steve Nickolas wrote:
> 
>>Now, I don't speak 8086 asm, so bear with me, because I'm going to use
>>the
>>only dialect I know - 6502.  But the logic would probably be the same
>>as 8086.
>>
>>ptr        =        $04
>>entry:    ldy       #$00
>>@1:       lda       (ptr), y
>>           beq       @3
>>           cmp       #'a'
>>           bcc       @2        ; less than
>>           cmp       #'z'+1
>>           bcs       @2        ; greater or equal
>>           and       #$5F
>>           sta       (ptr), y
>>@2:       iny
>>           bne       @1
>>@3:       rts
> 
> I have no knowledge of 6502. If anyone can translate to 8086, please
> do.

  I'll give it a go, but it's been quite some time since I've done any
8086 assembly.

            ptr equ $04
            mov si, 0
@1:         mov al, [si] + ptr
            je @3
            cmp al, 'a'
            jl @2
            cmp al, 'z" + 1
            jge @2
            and al, $5f
            mov [si] + ptr, al
@2:         inc si
            jmp @1
@3:         ret

  I hope I've got that right. How it works:

1) The string to be checked is apparently at address $04 (if I've
understood correctly). ptr represents this address.

2) We use an index register (y in 6502, si in 8086) to access characters
within the string. Start by setting this to 0 to select the first
character.

3) Get the selected character from the string.

4) If it's a nul, skip to step 9.

5) If the character is less than a lower case 'a', skip to step 8.

6) If the character is greater than or equal to lower case 'z' + 1 (in
other words, is greater than 'z'), skip to step 8.

7) By this point, the character must be a lower case letter. Clear bit 6
(and bit 7, but that is always 0 in ASCII) to make it capital.

8) Increment the index register to select the next character before
jumping back to step 3. The 6502 version uses a conditional branch
here, no doubt since the original 6502 lacks an unconditional branch.
(The 65C02 has such an instruction, however.) I've used an
unconditional branch in the 8086 version.

9) End.

-- 


----- Dig the NEW and IMPROVED news sig!! -----


-------------- Shaggy was here! ---------------
              Ain't I'm a dawg!!

Back to comp.os.msdos.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

scan for a-z T. Ment <t.ment@protocol.invalid> - 2019-04-01 22:43 +0000
  Re: scan for a-z "Alexei A. Frounze" <alexfrunews@gmail.com> - 2019-04-01 21:04 -0700
    Re: scan for a-z T. Ment <t.ment@protocol.invalid> - 2019-04-02 16:31 +0000
    Re: scan for a-z Steve Nickolas <usotsuki@buric.co> - 2019-04-02 12:40 -0400
      Re: scan for a-z T. Ment <t.ment@protocol.invalid> - 2019-04-02 16:48 +0000
        Re: scan for a-z Rod Pemberton <invalid@lkntrgzxc.com> - 2019-04-02 18:03 -0400
        Re: scan for a-z Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2019-04-17 23:56 +1000
  Re: scan for a-z "R.Wieser" <address@not.available> - 2019-04-02 09:00 +0200
    Re: scan for a-z "Kerr-Mudd,John" <notsaying@invalid.org> - 2019-04-02 09:06 +0000
      Re: scan for a-z "R.Wieser" <address@not.available> - 2019-04-02 14:37 +0200
  Re: scan for a-z Herbert Kleebauer <klee@unibwm.de> - 2019-04-02 12:39 +0200
    Re: scan for a-z "Kerr-Mudd,John" <notsaying@invalid.org> - 2019-04-02 14:27 +0000
      Re: scan for a-z Herbert Kleebauer <klee@unibwm.de> - 2019-04-02 20:17 +0200
        Re: scan for a-z "Kerr-Mudd,John" <notsaying@invalid.org> - 2019-04-02 19:16 +0000
        Re: scan for a-z wolfgang kern <nowhere@never.at> - 2019-04-03 16:13 +0200
          Re: scan for a-z T. Ment <t.ment@protocol.invalid> - 2019-04-03 19:36 +0000
          Re: scan for a-z "Kerr-Mudd,John" <notsaying@invalid.org> - 2019-04-04 14:43 +0000
            Re: scan for a-z wolfgang kern <nowhere@never.at> - 2019-04-05 00:41 +0200
  Re: scan for a-z JJ <jj4public@vfemail.net> - 2019-04-02 19:53 +0700
  Re: scan for a-z Mateusz Viste <mateusz@cant.remember> - 2019-04-02 13:00 +0000
    Re: scan for a-z T. Ment <t.ment@protocol.invalid> - 2019-04-02 16:44 +0000
  Re: scan for a-z Rod Pemberton <invalid@lkntrgzxc.com> - 2019-04-02 18:04 -0400
    Re: scan for a-z "Kerr-Mudd,John" <notsaying@invalid.org> - 2019-04-03 09:31 +0000
      Re: scan for a-z "Alexei A. Frounze" <alexfrunews@gmail.com> - 2019-04-03 02:48 -0700
        Re: scan for a-z "Kerr-Mudd,John" <notsaying@invalid.org> - 2019-04-03 12:25 +0000
          Re: scan for a-z Rod Pemberton <invalid@lkntrgzxc.com> - 2019-04-03 18:05 -0400
      Re: scan for a-z Bogus@Embarq.com (Steve) - 2019-04-03 11:58 +0000
  Re: scan for a-z wolfgang kern <nowhere@never.at> - 2019-04-03 15:58 +0200
    Re: scan for a-z wolfgang kern <nowhere@never.at> - 2019-04-03 16:05 +0200
    Re: scan for a-z "R.Wieser" <address@not.available> - 2019-04-03 17:40 +0200
    Re: scan for a-z "R.Wieser" <address@not.available> - 2019-04-03 17:47 +0200

csiph-web