flat assembler
Message board for the users of flat assembler.

Index > Main > up/low case, with a lut.

Author
Thread Post new topic Reply to topic
edfed



Joined: 20 Feb 2006
Posts: 4332
Location: Now
edfed 14 Mar 2011, 19:06
hello, today, i've made a basic function set to change the case of chars.
it takes the modifier from a 256 bytes LUT, and it translates the char.

then, of course, it is using the charset of européan letters. with accents, etc...


let's go!!

Code:
;;change case:
;usage:
;
;force lower case:
;       mov al,char
;       call case.low
;
;force upper case:
;       mov al,char
;       call case.up
;
;inverse case:
;       mov al,char
;       call case.inv
case:
;al=char
;trashes eax,ebx
.low:
        mov ah,al
        mov ebx,.lut
        xlatb
        or ah,al
        mov al,ah
        ret
.up:
        mov ah,al
        mov ebx,.lut
        xlatb
        not al
        and ah,al
        mov al,ah
        ret
.inv:
        mov ah,al
        mov ebx,.lut
        xlatb
        xor ah,al
        mov al,ah
        ret
.lut:
.00 db 0          ;.
.01 db 0          ;.
.02 db 0          ;.
.03 db 0          ;.
.04 db 0          ;.
.05 db 0          ;.
.06 db 0          ;.
.07 db 0          ;.
.08 db 0          ;.
.09 db 0          ;.
.0A db 0          ;.
.0B db 0          ;.
.0C db 0          ;.
.0D db 0          ;.
.0E db 0          ;.
.0F db 0          ;.
.10 db 0          ;.
.11 db 0          ;.
.12 db 0          ;.
.13 db 0          ;.
.14 db 0          ;.
.15 db 0          ;.
.16 db 0          ;.
.17 db 0          ;.
.18 db 0          ;.
.19 db 0          ;.
.1A db 0          ;.
.1B db 0          ;.
.1C db 0          ;.
.1D db 0          ;.
.1E db 0          ;.
.1F db 0          ;.
.20 db 0          ;
.21 db 0          ;!
.22 db 0          ;"
.23 db 0          ;#
.24 db 0          ;$
.25 db 0          ;%
.26 db 0          ;&
.27 db 0          ;'
.28 db 0          ;(
.29 db 0          Wink
.2A db 0          ;*
.2B db 0          ;+
.2C db 0          ;,
.2D db 0          ;-
.2E db 0          ;.
.2F db 0          ;/
.30 db 0          ;0
.31 db 0          ;1
.32 db 0          ;2
.33 db 0          ;3
.34 db 0          ;4
.35 db 0          ;5
.36 db 0          ;6
.37 db 0          ;7
.38 db 0          ;8
.39 db 0          ;9
.3A db 0          ;:
.3B db 0          ;;
.3C db 0          ;<
.3D db 0          ;=
.3E db 0          ;>
.3F db 0          ;?
.40 db 0          ;@
.41 db 20h        ;Aa
.42 db 20h        ;Bb
.43 db 20h        ;Cc
.44 db 20h        ;Dd
.45 db 20h        ;Ee
.46 db 20h        ;Ff
.47 db 20h        ;Gg
.48 db 20h        ;Hh
.49 db 20h        ;Ii
.4A db 20h        ;Jj
.4B db 20h        ;Kk
.4C db 20h        ;Ll
.4D db 20h        ;Mm
.4E db 20h        ;Nn
.4F db 20h        ;Oo
.50 db 20h        ;Pp
.51 db 20h        ;Qq
.52 db 20h        ;Rr
.53 db 20h        ;Ss
.54 db 20h        ;Tt
.55 db 20h        ;Uu
.56 db 20h        ;Vv
.57 db 20h        ;Ww
.58 db 20h        ;Xx
.59 db 20h        ;Yy
.5A db 20h        ;Zz
.5B db 0          ;[
.5C db 0          ;\
.5D db 0          ;]
.5E db 0          ;^
.5F db 0          ;_
.60 db 0          ;`
.61 db 20h        ;aA
.62 db 20h        ;bB
.63 db 20h        ;cC
.64 db 20h        ;dD
.65 db 20h        ;eE
.66 db 20h        ;fF
.67 db 20h        ;gG
.68 db 20h        ;hH
.69 db 20h        ;iI
.6A db 20h        ;jJ
.6B db 20h        ;kK
.6C db 20h        ;lL
.6D db 20h        ;mM
.6E db 20h        ;nN
.6F db 20h        ;oO
.70 db 20h        ;pP
.71 db 20h        ;qQ
.72 db 20h        ;rR
.73 db 20h        ;sS
.74 db 20h        ;tT
.75 db 20h        ;uU
.76 db 20h        ;vV
.77 db 20h        ;wW
.78 db 20h        ;xX
.79 db 20h        ;yY
.7A db 20h        ;zZ
.7B db 0          ;{
.7C db 0          ;|
.7D db 0          ;}
.7E db 0          ;~
.7F db 0          ;.
.80 db 0          ;€
.81 db 0          ;.
.82 db 0          ;‚
.83 db 0          
.84 db 0          ;„
.85 db 0          ;…
.86 db 0          ;†
.87 db 0          ;‡
.88 db 0          
.89 db 0          ;‰
.8A db 10h        ;Šš
.8B db 0          ;‹
.8C db 10h        ;Œœ
.8D db 0          ;.
.8E db 0          
.8F db 0          ;.
.90 db 0          ;.
.91 db 0          ;‘
.92 db 0          ;’
.93 db 0          ;“
.94 db 0          ;”
.95 db 0          ;•
.96 db 0          ;–
.97 db 0          ;—
.98 db 0          
.99 db 0          ;™
.9A db 10h        ;šŠ
.9B db 0          ;›
.9C db 10h        ;œŒ
.9D db 0          ;.
.9E db 0          
.9F db 60h        ;Ÿÿ
.A0 db 0          ; 
.A1 db 0          
.A2 db 0          
.A3 db 0          
.A4 db 0          
.A5 db 0          
.A6 db 0          
.A7 db 0          
.A8 db 0          
.A9 db 0          
.AA db 0          
.AB db 0          
.AC db 0          
.AD db 0          
.AE db 0          
.AF db 0          
.B0 db 0          
.B1 db 0          
.B2 db 0          
.B3 db 0          
.B4 db 0          
.B5 db 0          
.B6 db 0          
.B7 db 0          
.B8 db 0          
.B9 db 0          
.BA db 0          
.BB db 0          
.BC db 0          
.BD db 0          
.BE db 0          
.BF db 0          ;¿
.C0 db 20h        ;Àà
.C1 db 20h        ;Áá
.C2 db 20h        ;Ââ
.C3 db 20h        ;Ãã
.C4 db 20h        ;Ää
.C5 db 20h        ;Åå
.C6 db 20h        ;Ææ
.C7 db 20h        ;Çç
.C8 db 20h        ;Èè
.C9 db 20h        ;Éé
.CA db 20h        ;Êê
.CB db 20h        ;Ëë
.CC db 20h        ;Ìì
.CD db 20h        ;Íí
.CE db 20h        ;Îî
.CF db 20h        ;Ïï
.D0 db 20h        ;Ðð
.D1 db 20h        ;Ññ
.D2 db 20h        ;Òò
.D3 db 20h        ;Óó
.D4 db 20h        ;Ôô
.D5 db 20h        ;Õõ
.D6 db 20h        ;Öö
.D7 db 0          
.D8 db 20h        ;Øø
.D9 db 20h        ;Ùù
.DA db 20h        ;Úú
.DB db 20h        ;Ûû
.DC db 20h        ;Üü
.DD db 20h        ;Ýý
.DE db 20h        ;Þþ
.DF db 0          
.E0 db 20h        ;àÀ
.E1 db 20h        ;áÁ
.E2 db 20h        ;âÂ
.E3 db 20h        ;ãÃ
.E4 db 20h        ;äÄ
.E5 db 20h        ;åÅ
.E6 db 20h        ;æÆ
.E7 db 20h        ;çÇ
.E8 db 20h        ;èÈ
.E9 db 20h        ;éÉ
.EA db 20h        ;êÊ
.EB db 20h        ;ëË
.EC db 20h        ;ìÌ
.ED db 20h        ;íÍ
.EE db 20h        ;îÎ
.EF db 20h        ;ïÏ
.F0 db 20h        ;ðÐ
.F1 db 20h        ;ñÑ
.F2 db 20h        ;òÒ
.F3 db 20h        ;óÓ
.F4 db 20h        ;ôÔ
.F5 db 20h        ;õÕ
.F6 db 20h        ;öÖ
.F7 db 0          
.F8 db 20h        ;øØ
.F9 db 20h        ;ùÙ
.FA db 20h        ;úÚ
.FB db 20h        ;ûÛ
.FC db 20h        ;üÜ
.FD db 20h        ;ýÝ
.FE db 20h        ;þÞ
.FF db 60h        ;ÿŸ         
    


to use it, just include it in your source.

i am not responsible for the explosion of your fridge nor the tsunami.


Last edited by edfed on 14 Mar 2011, 23:50; edited 1 time in total
Post 14 Mar 2011, 19:06
View user's profile Send private message Visit poster's website Reply with quote
b1528932



Joined: 21 May 2010
Posts: 287
b1528932 14 Mar 2011, 20:04
Any reaosn besides video text modes to use this?
Post 14 Mar 2011, 20:04
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4332
Location: Now
edfed 14 Mar 2011, 20:47
i don't know, maybe just text files edition.

as i saw, under linux, it is not the same as under DOS.

names of files are always f***g case sensitive under linux.
that's a little boring because, when i write a name under windows, the name can be in lowase...
and DOS makes something, it puts every chars in UP case.
then, the problem, when i try to compile under linux is...
file not found, file not found, etc...

that's one reason to create a up/low case function.

after, in text editors too it can be very good to have lowcase, upcase, reversecase function, on right click...
etc.
Post 14 Mar 2011, 20:47
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.