home *** CD-ROM | disk | FTP | other *** search
- CODE SEGMENT
- ASSUME CS:CODE, DS:NOTHING
-
- ; Parameter (+2 wegen push bp)
-
- AnzahlBytes EQU BYTE PTR SS:[BP+6]
- Num EQU DWORD PTR SS:[BP+8]
-
- ; Adresse des Funktionsergebnisses (+2 wegen push bp)
-
- ErgebnisPtr EQU DWORD PTR SS:[BP+12]
-
- HexStr PROC FAR
- PUBLIC HexStr
-
- push bp
- mov bp,sp ; Zeiger auf Stack
- les di,ErgebnisPtr ; Adresse des Ergebnisses
- mov dx,ds ; DS von Turbo in DX speichern
- lds si,Num ; Adresse der Zahl
- mov al,AnzahlBytes ; Wieviele Bytes?
- xor ah,ah ; Umwandlung in Wort
- mov cx,ax ; Anzahl der Bytes in CX
- add si,ax ; Beim höchsten Byte anfangen
- dec si
- shl ax,1 ; Wieviel Ziffer? (2 pro Byte)
- cld ; Anzahl der Bytes in
- stosb ; im String speichern
- HexSchleife:
- std ; Von vorn nach hinten
- lodsb ; Nächstes Byte
- mov ah,al ; Zwischenspeichern
- shr al,1 ; Oberstes Nibble isolieren
- shr al,1
- shr al,1
- shr al,1
- add al,90h ; Hex-Umwandlung mit
- daa ; ADD und DAA
- adc al,40h
- daa ; Nibble umgewandelt
- cld
- stosb ; ASCII-Zeichen speichern
- mov al,ah ; Anderes Nibble umwandeln
- and al,0Fh
- add al,90h
- daa
- adc al,40h
- daa
- stosb
- loop HexSchleife ; weitermachen
- mov ds,dx ; DS von Turbo wieder herstellen
- pop bp
- ret 6 ; Parameter mit 6 Bytes
-
- HexStr ENDP
- CODE ENDS
- END
-