I made an asm program that makes all of the lowercase letters in a string capital and I'm wondering if there are any optimizations I could make. I am still new to asm programming, just so you know. Thanks in advance. Wink

Code:
header blah blah
 bcall ansname
 rst 10h
 ex de,hl
 ld c,(hl)
 inc hl
 ld b,(hl)
 inc hl
 push hl
 push bc
 ld de,0
loop:
 ld a,BBh
 cpir
 jr nz,finish
 push de
 push bc
 ld d,h
 ld e,l
 dec de
 push de
 ldir
 pop hl
 pop de
 pop bc
 inc de
 cp (hl)
 ld a,(hl)
 sbc 6Fh
 ld (hl),a
 jr loop
finish:
 pop bc
 pop hl
 ld a,d
 or e
 ret z
 push hl
 push de
 push bc
 add hl,bc
 sbc hl,de
 bcall delmem
 pop hl
 pop de
 or a
 sbc hl,de
 ex de,hl
 pop hl
 dec hl
 ld (hl),d
 dec hl
 ld (hl),e
 ret
Since I really don't feel like thinking right now, how 'bout if I try to make one and we compare?

Code:

 B_CALL AnsName
 rst 10h
 ex de,hl
 push hl
 pop ix
 ld c,(hl)
 inc hl
 ld b,(hl)
 inc hl
loop:
 ld a,(hl)
 cp firstbyteofalowercasetoken
 jr nz,advance
 inc hl
 dec bc
 ld a,(hl)
 cp t_lowercase_a
 jr c,advance
 cp t_lowercase_z+1
 jr nc,advance
 sub (t_lowercase_a-tA) ;I just want the difference between the second byte of "a" and "A", and I don't want to figure out the tokens right now
 dec hl
 ld (hl),a
 push hl
 inc hl
 inc hl
 push bc
 dec bc
 ld d,h
 ld e,l
 dec de
 ldir
 pop bc
 pop hl
 inc (IX+0)
 jr nz,advance
 inc (IX+1)

advance:
 inc hl
 dec bc
 ld a,b
 or c
 ret z
 jr loop
 
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement