String case: Difference between revisions

Add 8080 assembly
(→‎{{header|APL (Dyalog)}}: Replace deprecated I-Beam example with Case Convert system function)
(Add 8080 assembly)
Line 191:
ALPHA, BETA, GAMMA, {[(<123@_>)]}.
alpha, beta, gamma, {[(<123@_>)]}.</pre>
 
=={{header|8080 Assembly}}==
<lang 8080asm> org 100h
jmp demo
;;; Convert CP/M string under [HL] to upper case
unext: inx h
ucase: mov a,m ; Get character <- entry point is here
cpi '$' ; Done?
rz ; If so, stop
cpi 'a' ; >= 'a'?
jc unext ; If not, next character
cpi 'z'+1 ; <= 'z'?
jnc unext ; If not, next character
sui 32 ; Subtract 32
mov m,a ; Write character back
jmp unext
;;; Convert CP/M string under [HL] to lower case
lnext: inx h
lcase: mov a,m ; Get character <- entry point is here
cpi '$' ; Done?
rz ; If so, stop
cpi 'A' ; >= 'A'?
jc lnext ; If not, next character
cpi 'Z'+1 ; <= 'Z'?
jnc lnext ; If not, next character
adi 32 ; Subtract 32
mov m,a ; Write character back
jmp lnext
;;; Apply to given string
demo: call print ; Print without change
lxi h,str
call ucase ; Make uppercase
call print ; Print uppercase version
lxi h,str
call lcase ; Make lowercase (fall through to print)
print: lxi d,str ; Print string using CP/M call
mvi c,9
jmp 5
str: db 'alphaBETA',13,10,'$'</lang>
 
{{out}}
 
<pre>alphaBETA
ALPHABETA
alphabeta</pre>
 
=={{header|ActionScript}}==
2,125

edits