Re: All is right !



Hi every body.

If you remember, i would like to remove a byte in a file.
Rod; Franck ask answers.

Now, i build a part :
The spirit is : I type lettres " F " and " A " and i put the byte "
0FAh " in the file.
So for the next step, i can identify the byte i choose.

If some body have a better code, i will appréciate.
If some body have an other way to do it, i am also interrest.

Best regards
Almas


; i type the value of an ASCII...
; it put in a Byte this ascii
; this code can be run alone.

mov si,0082h ; i suppose i begin à 82h
lodsb
cmp al,3Ah
jb chiffre_d ; d for ten : ( forty, fivety, 60 and so long)
cmp al,41h ; is it an Hexa letter ?
jb error
cmp al,46h
ja error
sub al,37h ; "A" > 0Ah "F" become 0Fh
jmp short high_size
chiffre_d:
sub al,30h ; "0" > 00h "9" become 09h
high_size:
mov cx,0010h
mul cx ; get high position ascii
xor bx,bx
xchg ax,bx ; ax into bx

lodsb
cmp al,3Ah
jb chiffre_u : U like Unit
cmp al,41h
jb error
cmp al,46h
ja error
sub al,37h
jmp short low_size
chiffre_u:
sub al,30h
low_size:
mov cx,0016
add ax,bx
mov offset hexa,ax
mov dx,offset hexa
jmp short display_it
int 20h

error:
mov dx,offset txt
display_it:
mov ah,9
int 21h
int 20h
txt db: "Use Asci2Hex" ,13,10
hexa db: ,0,0,0 ,13,10,36







"almas" <almes@xxxxxxxxxx> a écrit dans le message de news:
4803ceeb$0$877$ba4acef3@xxxxxxxxxxxxxxxxx
Hello.
I ofen need help... but, this day, i built a COm alone.
The aim : Open a file, modify bytes, write it in an other file.
Now, i just write 256 bytes, just for test.
Next step : modify particular Ascii.
Then use largers files.
Below, my usefull code.
If you have betters methods, , sure i will apprecate.
Best Regards Almas

mov ax, 3D12h
mov dx, offset input
int 21h
mov offset handle1, ax
mov bx, [offset handle1] ; A86 need this syntax !
mov ah, 3Fh
mov cx,100h ; read 256 Bytes
mov dx, offset address ; buffer
int 21h
cmp ax,0 ; End of File ?
ja continue
int 20h
continue:
mov cx,ax ; Nbr of bytes usefull if less than 256
mov offset size_byte, ax ; rescue the size
mov si, offset address ; change bytes in buffer
mloop:
add byte [si],20h
inc si ; modify here...
loop mloop
jmp short do_it

creat_fil:
mov ah,3Ch
mov dx,offset output
xor cx,cx ; attrib
int 21h
do_it:
mov ax,3D01h ; Open for Write
mov dx, offset output
int 21h
jb creat_fil ; if not exist
mov offset handle2,ax
mov bx, [offset handle2]
mov ax,4202h
xor cx,cx
xor dx,dx ; BX keeps same value
int 21h
; mov dx,ax ; size, give an offset
xor dx,dx ; begin a byte 0
mov ax,4200h
xor cx,cx
int 21h
mov ah,40h
mov cx, [offset size_byte]
mov dx, offset address
int 21h
mov ah,3Eh
int 21h ; BX keep value Handle2

mov bx, [offset handle1] ; close first file
mov ah, 3Eh
int 21h
int 20h
; data -----------
size_byte db: ,0,0,0,0
input db: "FILE.IN" ,0
output db: "FILE.OUT" ,0
handle1 db: ,0,0,0,0
handle2 db: ,0,0,0,0
address:
db: ,0,0,0,0,0,0



.



Relevant Pages

  • Re: NASM HelloWorld - DOS
    ... mov eax, 0900h ... ; int 20h ... cmp ah, 01h ... jne NotMoveUp ...
    (alt.lang.asm)
  • concatain and change bytes
    ... mov si,0080h ... int 21h ... cmp al,0Dh; avoid LF & CR ... nofile: int 20h ...
    (alt.lang.asm)
  • Re: All is right !
    ... mov esi,0082h; I see, you assume a space before the parameters ... cmp al,3ah ... is it an Hexa letter? ... mov dx,offset hexa jmp short display_it int 20h ...
    (alt.lang.asm)
  • Re: CSpinButtonCtrl, CTabCtrl transparent oder im Edelstahllook ?
    ... einen Transparent Blit, kann mit der GDI nur über umwegen erreichen, ... TransparentBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, ... mov edi, CDraw.m_pTmp ...
    (microsoft.public.de.vc)
  • Re: Assembler for Dummies
    ... mov ah, 9; select print function. ... same as INT 20h ... Jim Carlock wrote: ... >> mov dx, offset text ...
    (alt.lang.asm)