[ASM] Min <=> Maj
salut à toi!
Source faite pour MASM
Source Win32asm utilsant deux routines de conversion.
Ne prend pas en compte les caractères accentués.
Principalement pour exemple de structure d'un code ASM
Telecharge
la source !
Ciao...
.386
.model flat, stdcall
option casemap :none
option prologue:none
option epilogue:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
IDD_APP EQU 111
IDED_MIN EQU 1000
IDED_MAJ EQU 1001
IDED_MAJ2 EQU 1002
IDED_MIN2 EQU 1003
.data
ALIGN 4
hinst DWORD 0
szini BYTE 0
ALIGN 4
sztest BYTE 256 dup(0)
sztest2 BYTE 256 dup(0)
.code
start:
ALIGN 4
push 0
call GetModuleHandle
push 0
push offset AppDlgProc
push 0
mov hinst, eax
push IDD_APP
push eax
call DialogBoxParam
push 0
call ExitProcess
AppDlgProc proc ; hdlg(esp+4), mssg(esp+8), wParam(esp+12), lParam(esp+16)
mov edx, [esp+8] ; EDX = mssg
mov ecx, [esp+12] ; ECX = wParam
xor eax, eax
cmp edx, WM_COMMAND
je short onCOMMAND
ret 16
onCOMMAND: ; ECX = wParam
cmp ecx, 30003E8h
je short onMotChange
cmp ecx, 30003EAh
je short onMotChange2
cmp ecx, IDCANCEL
je short onCANCEL
ret 16
onCANCEL:
mov eax, [esp+4] ; hdlg
push 0
push eax
call EndDialog
ret 16
onMotChange:
mov eax, [esp+4]
push eax
push 256
push offset sztest
push IDED_MIN
push eax
call GetDlgItemText
mov edx, offset sztest
call min2maj
; mov eax, [esp+4] ; limiter le plus possible les acces mémoires car trop lents
pop eax
push offset sztest
push IDED_MAJ
push eax
call SetDlgItemText
ALIGN 4
ret 16
onMotChange2:
mov eax, [esp+4]
push eax
push 256
push offset sztest2
push IDED_MAJ2
push eax
call GetDlgItemText
mov edx, offset sztest2
call maj2min
; mov eax, [esp+4] ; limiter le plus possible les acces mémoires car trop lents
pop eax
push offset sztest2
push IDED_MIN2
push eax
call SetDlgItemText
ALIGN 4
ret 16
AppDlgProc ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
min2maj PROC
;
; Auteur: Bigbang
;
; Convertit une chaine de caractère en Majuscules
;
; Paramètre: EDX pointe sur la chaine
; Retour: (rien)
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
debut:
mov al, BYTE PTR [edx]
cmp al,0
je short fin
cmp al, 61h
jb short inter
cmp al, 7Ah
ja short inter
and al,0DFh
mov BYTE PTR [edx], al
inter:
inc edx
jmp short debut
fin:
RET
min2maj ENDP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
maj2min PROC
;
; Auteur: Bigbang
;
; Convertit une chaine de caractère en minuscules
;
; Paramètre: EDX pointe sur la chaine
; Retour: (rien)
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
debut:
mov al, BYTE PTR [edx]
cmp al,0
je short fin
cmp al, 41h
jb short inter
cmp al, 5Ah
ja short inter
or al, 20h
mov BYTE PTR [edx], al
inter:
inc edx
jmp short debut
fin:
RET
maj2min ENDP
end start
Bigbang