Re: All is right !
- From: "almas" <almes@xxxxxxxxxx>
- Date: Thu, 17 Apr 2008 20:52:19 +0200
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@xxxxxxxx> a écrit dans le message de news:
fu7a8m$lgs$1@xxxxxxxxxxxxxxxxxxxxxxxx
Hello almas,
Note : if i have to replace [Ctrl - C] ascii 003 ; some programs refuseit.
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
.
- Follow-Ups:
- Re: All is right !
- From: Wolfgang Kern
- Re: All is right !
- References:
- All is right !
- From: almas
- Re: All is right !
- From: almas
- Re: All is right !
- From: Wolfgang Kern
- Re: All is right !
- From: almas
- Re: All is right !
- From: Wolfgang Kern
- All is right !
- Prev by Date: Re: All is right !
- Next by Date: powerpc sync and eieio instructions
- Previous by thread: Re: All is right !
- Next by thread: Re: All is right !
- Index(es):
Relevant Pages
|