Z80 – Hexadezimalumrechnung
Umrechnung von Dezimal in Hexadezimal von 4 Bit (Nibble) bis 32 Bit (DWord). Die Routine sieht eine Ausgabe auf einem Ausgabekanal vor. Die Ausgabe ist nicht Teil der Routine
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
;************************************************************************** ; Ein Byte Hexadezimal auf dem Bildschirm ausgeben ; ; Eingabe: A = Byte ; Ausgabe: Hexadezimale Ausgabe an Cursorposition ;************************************************************************** prthex_byte: push af ; Save the contents of the registers push bc ld b, a rrca rrca rrca rrca call prthex_nibble ; Print high nibble ld a, b call prthex_nibble ; Print low nibble pop bc ; Restore original register contents pop af ret ;************************************************************************** ; Ein Nibble Hexadezimal auf dem Bildschirm ausgeben ; ; Eingabe: A = Nibble (die unteren 4 Bit) ; Ausgabe: Hexadezimale Ausgabe an Cursorposition ;************************************************************************** prthex_nibble: push af ; Der Inhalt von A bleibt erhalten -> Stack and 0fh ; Nur für den Fall.... add a,'0' ; Wenn es 0 ist, sind wir fertig. cp 03ah ; Ergebnis > "9"? jr c, _prthex_nibb_1 add a,'A' - '0' - 0ah ; "A" - "F" beachten _prthex_nibb_1: call printchar ; Das Nibble ausgeben (Die Ausgaberoutine muss separat erstellt werden) pop af ; und Register A wiederherstellen ret ; Fertig ;************************************************************************** ; Ein 16bit Wort Hexadezimal auf dem Bildschirm ausgeben ; ; Eingabe: HL = 16 Bit-Wort ; Ausgabe: Hexadezimale Ausgabe an Cursorposition ;************************************************************************** prthex_word: push hl ; HL auf den Stack push af ; A (und F) auf den Stack ld a, h ; Highbyte nach A call prthex_byte ; Byte ausgeben ld a, l ; Lowbyte nach A call prthex_byte ; Byte ausgeben pop af ; AF wiederherstellen pop hl ; HL wiederherstellen ret ; Fertig ;************************************************************************** ; Ein 32bit Wort Hexadezimal auf dem Bildschirm ausgeben ; ; Eingabe: BC = 16 Bit-Wort, DE 16 Bit Wort ; Ausgabe: Hexadezimale Ausgabe an Cursorposition ;************************************************************************** prthex_dword: push hl ; HL auf den stack push bc ; BC auf den Stack pop hl ; BC nach HL call prthex_word ; 16 Bit ausgeben push de ; DE auf den Stack pop hl ; DE nach HL call prthex_word ; 16 Bit ausgeben pop hl ret |