|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
[MASM] CONVERSION EBCDIC VERS ASCII
Information sur la source
Description
Bonjour ! Voila mon premier programme en assembleur. Ca permet d'effectuer une conversion de fichier. rien de parametrable pour l'instant, mais ca fonctionne... Input.txt > Output.txt
Source
- .586
-
- .model flat,stdcall
- option casemap:none
-
- include windows.inc
- include user32.inc
- include kernel32.inc
-
- includelib user32.lib
- includelib kernel32.lib
-
- BUFLENGTH equ 1024
-
- .data
- e2a db 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15
- db 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31
- db 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7
- db 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26
- db 32,160,161,162,163,164,165,166,167,168, 91, 46, 60, 40, 43, 33
- db 38,169,170,171,172,173,174,175,176,177, 93, 36, 42, 41, 59, 94
- db 45, 47,178,179,180,181,182,183,184,185,124, 44, 37, 95, 62, 63
- db 186,187,188,189,190,191,192,193,194, 96, 58, 35, 64, 39, 61, 34
- db 195, 97, 98, 99,100,101,102,103,104,105,196,197,198,199,200,201
- db 202,106,107,108,109,110,111,112,113,114,203,204,205,206,207,208
- db 209,126,115,116,117,118,119,120,121,122,210,211,212,213,214,215
- db 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231
- db 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,232,233,234,235,236,237
- db 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,238,239,240,241,242,243
- db 92,159, 83, 84, 85, 86, 87, 88, 89, 90,244,245,246,247,248,249
- db 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,250,251,252,253,254,255
-
- szINPUTFAIL db 'Le fichier d''entree n''a pas ete trouve',0
- szOUTPUTFAIL db 'Le fichier de sortie n''a pas pu être créé',0
- szJOBDONE db 'Conversion terminée',0
- szAppName db 'Ebcdic2Ascii',0
- szWORKING db 'Working',0
- szIFilename db "input.txt",0
- szOFilename db "output.txt",0
- .data?
- iFile dd ?
- oFile dd ?
- buffer db BUFLENGTH dup (?)
- .code
- start:
- invoke CreateFile,addr szIFilename, GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
- cmp eax, INVALID_HANDLE_VALUE
- jnz short @F
- invoke MessageBox,NULL, addr szINPUTFAIL, addr szAppName, MB_ICONERROR or MB_OK
- push 1
- call ExitProcess
- @@:
- mov iFile , eax
- invoke CreateFile,addr szOFilename, GENERIC_WRITE,FILE_SHARE_WRITE or FILE_SHARE_READ , NULL, OPEN_ALWAYS ,FILE_ATTRIBUTE_NORMAL,0
- cmp eax, INVALID_HANDLE_VALUE
- jnz short @F
- invoke MessageBox,NULL, addr szOUTPUTFAIL, addr szAppName, MB_ICONERROR or MB_OK
- push 1
- call ExitProcess
- @@:
- mov oFile, eax
- lea ebx, [esp]
- push NULL
- push ebx
- push BUFLENGTH
- push offset buffer
- push iFile
- call ReadFile
- mov eax, [ebx]
- test eax, eax
- jz short @endw
- mov esi, offset buffer
- @while:
- xor edx, edx
- mov ebx, offset e2a
- push eax
- mov ecx, eax
- @@:
- dec ecx
- mov dl,[esi+ecx]
- mov eax,[ebx+edx]
- mov [esi+ecx], al
- jnz @B
- pop eax
- lea ebx, [esp]
- push NULL
- push ebx
- push eax
- push offset buffer
- push oFile
- call WriteFile
- lea ebx, [esp]
- push NULL
- push ebx
- push BUFLENGTH
- push offset buffer
- push iFile
- call ReadFile
- mov eax, [ebx]
- test eax, eax
- jnz short @while
- @endw:
- push oFile
- call CloseHandle
- push iFile
- call CloseHandle
- invoke MessageBox,NULL, addr szJOBDONE, addr szAppName, MB_OK or MB_ICONINFORMATION
- push 0
- call ExitProcess
- end start
.586
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
BUFLENGTH equ 1024
.data
e2a db 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15
db 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31
db 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7
db 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26
db 32,160,161,162,163,164,165,166,167,168, 91, 46, 60, 40, 43, 33
db 38,169,170,171,172,173,174,175,176,177, 93, 36, 42, 41, 59, 94
db 45, 47,178,179,180,181,182,183,184,185,124, 44, 37, 95, 62, 63
db 186,187,188,189,190,191,192,193,194, 96, 58, 35, 64, 39, 61, 34
db 195, 97, 98, 99,100,101,102,103,104,105,196,197,198,199,200,201
db 202,106,107,108,109,110,111,112,113,114,203,204,205,206,207,208
db 209,126,115,116,117,118,119,120,121,122,210,211,212,213,214,215
db 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231
db 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,232,233,234,235,236,237
db 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,238,239,240,241,242,243
db 92,159, 83, 84, 85, 86, 87, 88, 89, 90,244,245,246,247,248,249
db 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,250,251,252,253,254,255
szINPUTFAIL db 'Le fichier d''entree n''a pas ete trouve',0
szOUTPUTFAIL db 'Le fichier de sortie n''a pas pu être créé',0
szJOBDONE db 'Conversion terminée',0
szAppName db 'Ebcdic2Ascii',0
szWORKING db 'Working',0
szIFilename db "input.txt",0
szOFilename db "output.txt",0
.data?
iFile dd ?
oFile dd ?
buffer db BUFLENGTH dup (?)
.code
start:
invoke CreateFile,addr szIFilename, GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
cmp eax, INVALID_HANDLE_VALUE
jnz short @F
invoke MessageBox,NULL, addr szINPUTFAIL, addr szAppName, MB_ICONERROR or MB_OK
push 1
call ExitProcess
@@:
mov iFile , eax
invoke CreateFile,addr szOFilename, GENERIC_WRITE,FILE_SHARE_WRITE or FILE_SHARE_READ , NULL, OPEN_ALWAYS ,FILE_ATTRIBUTE_NORMAL,0
cmp eax, INVALID_HANDLE_VALUE
jnz short @F
invoke MessageBox,NULL, addr szOUTPUTFAIL, addr szAppName, MB_ICONERROR or MB_OK
push 1
call ExitProcess
@@:
mov oFile, eax
lea ebx, [esp]
push NULL
push ebx
push BUFLENGTH
push offset buffer
push iFile
call ReadFile
mov eax, [ebx]
test eax, eax
jz short @endw
mov esi, offset buffer
@while:
xor edx, edx
mov ebx, offset e2a
push eax
mov ecx, eax
@@:
dec ecx
mov dl,[esi+ecx]
mov eax,[ebx+edx]
mov [esi+ecx], al
jnz @B
pop eax
lea ebx, [esp]
push NULL
push ebx
push eax
push offset buffer
push oFile
call WriteFile
lea ebx, [esp]
push NULL
push ebx
push BUFLENGTH
push offset buffer
push iFile
call ReadFile
mov eax, [ebx]
test eax, eax
jnz short @while
@endw:
push oFile
call CloseHandle
push iFile
call CloseHandle
invoke MessageBox,NULL, addr szJOBDONE, addr szAppName, MB_OK or MB_ICONINFORMATION
push 0
call ExitProcess
end start
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Sources de la même categorie
Commentaires et avis
|
Comparez les prix Nouvelle version
|