From: Wolfgang Kern on

Hello almas,

> Note : if i have to replace [Ctrl - C] ascii 003 ; some programs refuse
it.
> Same for ascii [ ALT 10 ] or alt 6

Yes, a few codes are covered by the DOS-prompt itself, so an ALT-10
will just do what it says: "LF" and ALT 7 may just beep once.

> Sure i can do a XOR 20h on each bytes of a file ; byte 0 become 20h
> and i can move the Space...
> then i do again XOR 20h.... and not modified bytes have again same value.

wouldn't it be enough to filter off all non-numeric/hex characters ?
ie: make a question-mark or whatsoever out of it

> The idea is to type with numbers and letters
> Example i type "50", the program write " P "
> If i type "A8" the programm write " � "

Yes, even I'd treat non-printatble chararcters in a special way, some
may be interpreted as CRSR-position, KEY-buffer- or screen-commands
depending on the options of the print-function. I think you use the
'display all' option for INT21h anyway yet.

> I can type 00 ; 01 ;02 ... 0E,0F 10,11,12.....and so long...FE FF
> I just obtain One byte 0 to 0FFh

> The byte falls at the location hexa... i catch it.
> The next operation : find the byte a hexa_address and remove it.

> With this part of programm i can choose the byte i will remove.
> Before it, i had to build 256 tools... for each bytes.
>
> I am sorry, but do not understand you want to do.
>
> after
> cmp al,41h jb error
> cmp al,46h jb error *** "ja" error
> sub al,7 ; i can obtain 3Ah to 40h ( do" :" to " @ ") why ?

It will result in 3A..3F !! followed by the sub 30h => "0A...0F"

I meant the two lines above within my comments :)
lodsb
cmp al,30h
jb not_a_Number ;
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
;*** I'd replace the two lines above with sub al,07
;*** a JMP costs more than one *SUB* and the code become shorter too
sub al,07 ;will be executed ONLY IF AL = 41..46h (become 3A..
chiffre_d: ;else it goes here AL = 30..39h
sub al,30h ; "0" > 00h "9" become 09h
shl al,4 ;move it four bits = MUL by 16
mov ah,al ;save high nibble value in AH ie:yet (without using bx)
;AH= x0h (x = 0..F)
lodsb ... ;code for the LOW-nibble goes here
;AL =0xh (x = 0..F)
or AL,AH ;combine the two (same as ADD AL,AH here)
;the final value is now in AL
;mov AH,0 ;not required at all
mov offset hex_string, AL
; if you use AX here the value of AH would go to
; offset "hex-string+1" (little endians in here ...)
; but isn't there a zero anyway ?


> I do xor bx,bx so bx=0000
> I have to save value of AX, so i put it into bx
> then, i must have Ah=0 al =...? come from the lodsbyte

Why do you need AH=0 ? as a string-terminator for a single byte ?
I'd write just the gotten byte into the hexa-string, and
keep the anyway defined zero in there if you really need it.

> Yes : the character "d" and "u" make *together* the byte "DU"
> So, i do "letter d" becomes "d *16" d = 0 to F

Mmh, after multiply by 16 (= shift left 4):d = 00..F0

> and i do d*16 + u U can also have value 0 to 0Fh

Yes, you can ADD 'or' OR this two, because both values are only
four bits in size and at the proper bit-position already.
your byte:
76543210 ;bit position
0000xxxx ;low nibble in AL
+yyyy0000 ;high nibble as saved in AH (or elsewhere)
--------
yyyyxxxx ;regardless of ADD or OR here.

> Right : for the low size ; cx, is not usefull
> ... may be it could be or ah,bl

either
OR AL,.. ;any-byte-reg where you saved the high nibble
or
ADD AL,.. ;
MOV offset ... ,AL ;you got only one byte to alter the display :)

> At the end, i just use one "$" for flag end of text.
> the most important is text terminate by $

Yes, for int21h-text,
while int10h-text let you choose your own end mark/size.

__
wolfgang



From: almas on
Guten Tag Wolfgang.
Hi everybody

I try the solution, it just cost 70 bytes. I choose a very small size of
file.

mov si,0082h ; Sure, i must respect the syntax
lodsb
cmp al,3Ah ; what if one typed any of !"+-*().. or an ALT-num<30 ?
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,07
jmp short high_size

chiffre_d: ; can be 0 to 9 but no think else
sub al,30h ; "0" > 00h "9" become 09h

high_size:
SHL AL,4 ; (= *16 and clears low 4 bits also) (00,01..0Fh becomes
00,10..F0h)

xchg ax,bx ; i just use 1 byte sure "mov bl,al" do the same.
lodsb
cmp al,3Ah
jb chiffre_u ; U like Unit

cmp al,41h ; for Unit, i have not to Rotate On Left
jb error ; so it just need One Sub al, [a value]
cmp al,46h
ja error
sub al,37h
jmp short low_size
chiffre_u: ; > *** same as mentioned above ...
sub al,30h
low_size:
add ax,bx ; it use 2 bytes ; but OR AL,BL is more logic.
; you have lower nibble (4 bits) in AL now
; and higher nibble shifted (*16) and saved in BL.
; Two hex-characters wont ever produce more than one byte.
; It will work if you add AX,BX, but I'd use OR AL,BL
; or does your DOS support Unicode ? :) ... then mov AH,0 would do it.
mov offset hexa,ax
; *** why two characters ? (the 2nd will be zero):"?" or so...
; mov dx,offset hexa jmp short display_it int 20h ; when this be executed ?

error:
mov dx,offset txt ; i display the "how o use" and the result in same
time
mov ah,9
int 21h
ret ; just cost 1 byte, int 20h also works
txt db: "Asci2Hex" ,9 ; Yes no $ here !
hexa db: 32,10,36 ; Ascii "10" go line below "36" terminate display
text

Best regards



"Wolfgang Kern" <nowhere(a)never.at> a �crit dans le message de news:
fu7a8m$lgs$1(a)newsreader2.utanet.at...
>
> Hello almas,
>
>> Note : if i have to replace [Ctrl - C] ascii 003 ; some programs refuse
> it.
>> Same for ascii [ ALT 10 ] or alt 6
>
> Yes, a few codes are covered by the DOS-prompt itself, so an ALT-10
> will just do what it says: "LF" and ALT 7 may just beep once.
>
>> Sure i can do a XOR 20h on each bytes of a file ; byte 0 become 20h
>> and i can move the Space...
>> then i do again XOR 20h.... and not modified bytes have again same value.
>
> wouldn't it be enough to filter off all non-numeric/hex characters ?
> ie: make a question-mark or whatsoever out of it
>
>> The idea is to type with numbers and letters
>> Example i type "50", the program write " P "
>> If i type "A8" the programm write " � "
>
> Yes, even I'd treat non-printatble chararcters in a special way, some
> may be interpreted as CRSR-position, KEY-buffer- or screen-commands
> depending on the options of the print-function. I think you use the
> 'display all' option for INT21h anyway yet.
>
>> I can type 00 ; 01 ;02 ... 0E,0F 10,11,12.....and so long...FE FF
>> I just obtain One byte 0 to 0FFh
>
>> The byte falls at the location hexa... i catch it.
>> The next operation : find the byte a hexa_address and remove it.
>
>> With this part of programm i can choose the byte i will remove.
>> Before it, i had to build 256 tools... for each bytes.
>>
>> I am sorry, but do not understand you want to do.
>>
>> after
>> cmp al,41h jb error
>> cmp al,46h jb error *** "ja" error
>> sub al,7 ; i can obtain 3Ah to 40h ( do" :" to " @ ") why ?
>
> It will result in 3A..3F !! followed by the sub 30h => "0A...0F"
>
> I meant the two lines above within my comments :)
> lodsb
> cmp al,30h
> jb not_a_Number ;
> 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
> ;*** I'd replace the two lines above with sub al,07
> ;*** a JMP costs more than one *SUB* and the code become shorter too
> sub al,07 ;will be executed ONLY IF AL = 41..46h (become 3A..
> chiffre_d: ;else it goes here AL = 30..39h
> sub al,30h ; "0" > 00h "9" become 09h
> shl al,4 ;move it four bits = MUL by 16
> mov ah,al ;save high nibble value in AH ie:yet (without using bx)
> ;AH= x0h (x = 0..F)
> lodsb ... ;code for the LOW-nibble goes here
> ;AL =0xh (x = 0..F)
> or AL,AH ;combine the two (same as ADD AL,AH here)
> ;the final value is now in AL
> ;mov AH,0 ;not required at all
> mov offset hex_string, AL
> ; if you use AX here the value of AH would go to
> ; offset "hex-string+1" (little endians in here ...)
> ; but isn't there a zero anyway ?
>
>
>> I do xor bx,bx so bx=0000
>> I have to save value of AX, so i put it into bx
>> then, i must have Ah=0 al =...? come from the lodsbyte
>
> Why do you need AH=0 ? as a string-terminator for a single byte ?
> I'd write just the gotten byte into the hexa-string, and
> keep the anyway defined zero in there if you really need it.
>
>> Yes : the character "d" and "u" make *together* the byte "DU"
>> So, i do "letter d" becomes "d *16" d = 0 to F
>
> Mmh, after multiply by 16 (= shift left 4):d = 00..F0
>
>> and i do d*16 + u U can also have value 0 to 0Fh
>
> Yes, you can ADD 'or' OR this two, because both values are only
> four bits in size and at the proper bit-position already.
> your byte:
> 76543210 ;bit position
> 0000xxxx ;low nibble in AL
> +yyyy0000 ;high nibble as saved in AH (or elsewhere)
> --------
> yyyyxxxx ;regardless of ADD or OR here.
>
>> Right : for the low size ; cx, is not usefull
>> ... may be it could be or ah,bl
>
> either
> OR AL,.. ;any-byte-reg where you saved the high nibble
> or
> ADD AL,.. ;
> MOV offset ... ,AL ;you got only one byte to alter the display :)
>
>> At the end, i just use one "$" for flag end of text.
>> the most important is text terminate by $
>
> Yes, for int21h-text,
> while int10h-text let you choose your own end mark/size.
>
> __
> wolfgang
>
>
>


From: Wolfgang Kern on

almas wrote:

> Guten Tag Wolfgang.
:) Bon Jour! or similar, my French is restricted to doing it :)
> Hi everybody

> I try the solution, it just cost 70 bytes. I choose a very small size of
> file.

If code size is your main concern you can make CALLs out of the
two identical parts in the conversion:
But you know that DOS files always occupy a whole cluster on disk and
that the PSP is 256 bytes large, beside the environment copy anyway.
I limit my modular code to disk sector bounds (multiple of 512 bytes).

ie: also just 32(26)+22(18)+13(8) = 71(52) code-bytes, the figures
in brackets mean without the out-commented functionality.
_____________________
mov esi,0082h ; I see, you assume a space before the parameters
;cmp byte [esi-2],0 ; a few buyes more, but perhaps useful
;jz error ;if commandline is empty
lodsw ;get both bytes at once
call convert ;modify AL set carry/NC on error/GOOD
jc error
shl al,4
exch al,ah ;save first and use second yet
call convert ;call the same again
jc error
or al,ah
mov offset hexa,AL
jmp short display_quit

convert:
; cmp al,30h ;I'd put this in
; jc oh_no ;jc == jb
cmp al,3ah
jc num
cmp al,41h
jc oh_no
cmp al,46h
cmc ;invert the carry-bit (error if NoCarry >46h)
jc oh_no
sub al,07h
num:
sub al,30h
oh_no:
ret ;the last SUB will always result in NoCarry
;while any error got a set Carry-flag now.
error:
; mov dx,errtxt
; jmp short error_quit
display_quit:
mov dx,txt
error_quit:
mov AH,09
int 21h
ret ;it will work, even I'd always use:
; mov ax,4c00h ;because DOS will restore its stack and
; int21h ;segment-registers on termination then.
txt:
hexa:
errtxt: ...
______________________________

> mov si,0082h ; Sure, i must respect the syntax
> lodsb
> cmp al,3Ah ; what if one typed any of !"+-*().. or an ALT-num<30 ?
> 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,07
*** remove this line: > jmp short high_size
> chiffre_d: ; can be 0 to 9 but no think else

( It can be anything else if you input characters with code
below 30h ie: !"#$%^&()*+,-./ 20..2Fh)

> sub al,30h ; "0" > 00h "9" become 09h

*** and this label become obsolete then: > high_size:
> SHL AL,4 ; (= *16 and clears low 4 bits also) (00,01..0Fh becomes
> 00,10..F0h)

> xchg ax,bx ; i just use 1 byte sure "mov bl,al" do the same.

I see, it's OK if you prefer short code.

> lodsb
> cmp al,3Ah
> jb chiffre_u ; U like Unit
> cmp al,41h ; for Unit, i have not to Rotate On Left
> jb error ; so it just need One Sub al, [a value]
> cmp al,46h
> ja error
*** sub al,07h ; the difference of "41h-3Ah" = 7
chiffre_u: ; > *** same as mentioned above ...
sub al,30h ; if it was 41..46 then we sub 7 'and' sub 30h (sub 37h)
***; > low_size:
> add ax,bx ; it use 2 bytes ; but OR AL,BL is more logic.
> ; you have lower nibble (4 bits) in AL now
> ; and higher nibble shifted (*16) and saved in BL.
> ; Two hex-characters wont ever produce more than one byte.
> ; It will work if you add AX,BX, but I'd use OR AL,BL
> ; or does your DOS support Unicode ? :) ... then mov AH,0 would do it.
> mov offset hexa,ax
> ; *** why two characters ? (the 2nd will be zero):"?" or so...
> ; mov dx,offset hexa jmp short display_it int 20h

> error:
> mov dx,offset txt ; i display the "how o use" and the result in same
> time
> mov ah,9
> int 21h
> ret ; just cost 1 byte, int 20h also works

Yes, as long it's a DOS-.com file and you don't alter the stack.

> txt db: "Asci2Hex" ,9 ; Yes no $ here !
> hexa db: 32,10,36 ; Ascii "10" go line below "36" terminate
display > text

Right, but if you like any next line to start left-most, then
you should insert a CR as well: hexa: db 32,10,13,36

__
wolfgang




From: Wolfgang Kern on

I posted a bug with this:

> _____________________
> mov esi,0082h ; I see, you assume a space before the parameters
> ;cmp byte [esi-2],0 ; a few buyes more, but perhaps useful
> ;jz error ;if commandline is empty
> lodsw ;get both bytes at once
> call convert ;modify AL set carry/NC on error/GOOD
> jc error
> shl al,4
> exch al,ah ;save first and use second yet
> call convert ;call the same again
> jc error
> or al,ah
> mov offset hexa,AL
> jmp short display_quit
>
> convert:
> ; cmp al,30h ;I'd put this in
> ; jc oh_no ;jc == jb
> cmp al,3ah
> jc num
> cmp al,41h
> jc oh_no
***
> cmp al,46h *** make this CMP AL,47h (error if >=)
because 46h shall not be an error.
***
> cmc ;invert the carry-bit (error if NoCarry >46h)
> jc oh_no
> sub al,07h
> num:
> sub al,30h
> oh_no:
> ret ;the last SUB will always result in NoCarry
> ;while any error got a set Carry-flag now.
> error:
> ; mov dx,errtxt
> ; jmp short error_quit
> display_quit:
> mov dx,txt
> error_quit:
> mov AH,09
> int 21h
> ret ;it will work, even I'd always use:
> ; mov ax,4c00h ;because DOS will restore its stack and
> ; int21h ;segment-registers on termination then.
> txt:
> hexa:
> errtxt: ...
> ______________________________

__
wolfgang



From: almas on
Guten Tag / Bonjour / Good morning ( or afternoon )
Danke sh�n Wolfgang.

I know : a file use 1 cluster or more.
The file will be just a part of a larger one. so may be i have to care
about the size.
In fact, i prefer a small size.
I will try the solution with a call.

Best regards
Almas


"Wolfgang Kern" <nowhere(a)never.at> a �crit dans le message de news:
fuccus$183$1(a)newsreader2.utanet.at...
>
> I posted a bug with this:
>
>> _____________________
>> mov esi,0082h ; I see, you assume a space before the parameters
>> ;cmp byte [esi-2],0 ; a few buyes more, but perhaps useful
>> ;jz error ;if commandline is empty
>> lodsw ;get both bytes at once
>> call convert ;modify AL set carry/NC on error/GOOD
>> jc error
>> shl al,4
>> exch al,ah ;save first and use second yet
>> call convert ;call the same again
>> jc error
>> or al,ah
>> mov offset hexa,AL
>> jmp short display_quit
>>
>> convert:
>> ; cmp al,30h ;I'd put this in
>> ; jc oh_no ;jc == jb
>> cmp al,3ah
>> jc num
>> cmp al,41h
>> jc oh_no
> ***
>> cmp al,46h *** make this CMP AL,47h (error if >=)
> because 46h shall not be an error.
> ***
>> cmc ;invert the carry-bit (error if NoCarry >46h)
>> jc oh_no
>> sub al,07h
>> num:
>> sub al,30h
>> oh_no:
>> ret ;the last SUB will always result in NoCarry
>> ;while any error got a set Carry-flag now.
>> error:
>> ; mov dx,errtxt
>> ; jmp short error_quit
>> display_quit:
>> mov dx,txt
>> error_quit:
>> mov AH,09
>> int 21h
>> ret ;it will work, even I'd always use:
>> ; mov ax,4c00h ;because DOS will restore its stack and
>> ; int21h ;segment-registers on termination then.
>> txt:
>> hexa:
>> errtxt: ...
>> ______________________________
>
> __
> wolfgang
>
>
>