print_hex:
pusha

mov ah, 0x0e
mov bl , 0x0000   		;counter 1
mov bh , 0x0000  		;counter 2
mov cl , 0x0000  		;help var    



while1: 			;while
cmp bl, 0x04			;is bl = 4?
je end				;bl = 4 ->jump to end

;{
   mov cl, 0x0000              	;reset help var, so there is no number from the last turn
   while2: 			;while
   cmp bh, 0x04 		;is bh = 4?
   je endwhile2			;bh = 4 ->jump to endwhile2

   ;{
      shl cl, 1			;shift value to left to optain the leftmost bit
      shl dx,1			;shift the help var to left (this is a help tast to get the outputtet bits bitwise)
      jc  one                   ;Jump to task 'one' if there was a one
      jnc zero			;Or Jump to task 'zero' if there was a zero
   
          one:
            ;{
		
		add cl, 0x01	;0001 is added to help var so the bit can entry the var 
                inc bh		;counter2 ++
                jmp while2	;jump back to while head
            ;}

          zero:
            ;{
		
		add cl, 0x00	;0000 is added to help var so the bit can entry the var
                inc bh		;counter2 ++
                jmp while2	;continue with while2
            ;}

   ;}
  endwhile2:			;end of while2
  cmp cl, 0x09			;compare cl (0000 xxxx <- x stands for variable entry) to 9
  jg  greater			;if greater, jump to greater
  jle lowerEqual		;if lower or equal, jupt to lowerEqual

    greater:
      ;{
	mov al, cl		;move the 4 bits to al, ready for output
	add al, 55		;add d55 so there will be a letter from A to F
	int 0x10		;Interrupt for output
	jmp endif		;jump to endif
      ;}
    lowerEqual:
      ;{
	mov al, cl		;mov the 4 bits to al, ready for output
	add al, 48		;add d48 to get a number from 0 to 9
	int 0x10		;Interrupt for output
	jmp endif		;jup to endif
      ;}

  endif:
  mov bh, 0x0000		;reset counter2
  inc bl			;counter1++
  jmp while1			;continue with while1
;}

end:
mov al, 0x0a
int 0x10
mov al, 0x0d
int 0x10
popa
ret
