paul_met
Established Member
Greetings. Maybe someone has an algorithm for converting from HEX to BIN (for SH2 asm)?
For example:
	
	
	
		
Binary value must be written in HEX format.
---------------------------------------------
This is my version of the code. Perhaps someone will have a smaller code.
	
	
	
		
				
			For example:
		Code:
	
	AD (hex)= 10101101 (bin)---------------------------------------------
This is my version of the code. Perhaps someone will have a smaller code.
		Code:
	
	00  MOV #0xXX, R6 (number of convertible bytes)
02  MOV #0x00, R5 (jump offset #1)
04  MOV.B @R0 +, R1 (reading curent byte)
06  SHAR R1
08  MOVT R2 (get low bit)
0A  SHAR R1
0C  MOVT R3 (get high bit)
0E  SHLL2 R3
10  SHLL2 R3
12  BRAF R5 + 0x16 (jump to next step)
14  OR R3, R2
16  MOV R2, R4 (get fourth byte)
18  BRA 0x06 (repeat conversion)
1A  MOV #0x06, R5 (jump offset #2)
1C  SHLL8 R2
1E  OR R2, R4 (get third byte)
20  BRA 0x06 (repeat conversion)
22  MOV #0x0E, R5 (jump offset #3)
24  SHLL16 R2
26  OR R2, R4 (get second byte)
28  BRA 0x06 (repeat conversion)
2A  MOV #0x16, R5 (jump offset #4)
2C  SHLL8 R2
2E  SHLL16 R2
30  OR R2, R4 (get first byte)
32  DT R6  (cycle identificator)
34  MOV.L R4, @R7 (writing 4 bytes)
36  BF/S + 0x02 (return at beginning)
38  ADD #0x04, R7 (writing step)
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
	 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		