home *** CD-ROM | disk | FTP | other *** search
-
- ; ----------------------------
- ; KONVERT
- ;
- ; Enthält: Assembler-Routinen zur Konvertierung von Werten in Hexstrings
- ;
- ; Besonderheiten: Alle Routinen sind als FAR-Routinen kodiert
- ;
- ; Übersetzen: A86 KONVERT.A86 to KONVERT.OBJ
- ;
- ; ----------------------------
-
- CODE SEGMENT BYTE PUBLIC
- ASSUME CS:CODE
-
- ; ----------------------------
-
- PUBLIC HexByte
-
- PUBLIC HexWord
-
- ; ----------------------------
- ; HexByte
- ;
- ; Funktion: Umwandeln eines Bytes in einen HexString
- ;
- ; Pascal-Deklaration: {$F+} FUNCTION HexByte(zahlb : BYTE):STRING; EXTERNAL; {$F-}
- ;
- ; Eingabe-Parameter: zahlb - Umzuwandelndes Byte
- ;
- ; Ausgabe-Parameter: Als Funktions-Wert wird der HexString zurueckgegeben
- ;
- ; Besonderheiten: Der Funktionswert ist immer 2 Zeichen lang
- ;
-
- zahlb EQU [BP+06h] ; Offsets der Parameter auf dem Stack
- str2 EQU [BP+08h]
-
- HexByte PROC FAR
- push bp
- mov bp,sp
- cld
- les di,str2
- mov b es:[di],02h
- inc di
-
- mov al,zahlb
- call Konvert_AL_TO_AX
- stosw
-
- pop bp
- retf 2 ; Parameter vom Stack und raus
-
- ; ----------------------------
- ; HexWord
- ;
- ; Funktion: Umwandeln eines Wortes in einen HexString
- ;
- ; Pascal-Deklaration: {F+} FUNCTION HexWord(zahlw : WORT):STRING; EXTERNAL; {$F-}
- ;
- ; Eingabe-Paramter: zahlw - umzuwandelndes Wort
- ;
- ; Augabe-Paramter: Als Funktions-Wert wird der HexString zurueckgegeben
- ;
- ; Besonderheiten: Der Funktionswert ist immer 4 Zeichen lang
- ;
-
- zahlw EQU [BP+06] ; Offsets der Parameter auf dem Stack
- str4 EQU [BP+08]
-
- HexWord PROC FAR
- push bp
- mov bp,sp
- cld
- les di,str4
- mov b es:[di],4
- inc di
-
- mov ax,zahlw
- push ax
- mov al,ah
- call Konvert_AL_TO_AX
- stosw
- pop ax
- call Konvert_AL_TO_AX
- stosw
-
- pop bp
- retf 2 ; Parameter vom Stack und raus
-
- ; ---------------------------
- ; Konvert_AL_To_AX
- ;
- ; Funktion: Konvertiert AL in einen Hexstring
- ;
- ; Eingabe: AL = zu konvertierender Wert
- ;
- ; Ausgabe: AL = oberes Nibble als Hexziffer
- ; AH = unteres Nibble als Hexziffer
- ;
- Konvert_AL_TO_AX PROC NEAR
- mov ah,al
- and ah,0F0h
- shr ah,1
- shr ah,1
- shr ah,1
- shr ah,1
- cmp ah,9xD
- jg >l1
- add ah,48xD
- jmp >l2
- l1:
- add ah,55xD
- l2:
- and al,00Fh
- cmp al,9xD
- jg >l1
- add al,48xD
- jmp >l2
- l1:
- add al,55xD
- l2:
- xchg ah,al
- ret
-
- CODE ENDS
- ; ----------------------------
-
-