Subject: 8051 disassembler
From: rotaryeng
Date: 8/23/2012, 11:55 AM
To: AAAA Put this in the To box

Never mind I got it working Paul S. Thanks for all your previous help.

The tools available  for the 8051 are stunning. I found no less than five disassemblers.

I complied an example 8051 BASIC program called blink using Mikro 8051 BASIC. I then
downloaded it to the processor using MikRoBASIC IDE. It ran fine. Was easy to do and
it worked as advertised blinking some LEDs.

I then downloaded the hex file back from the processor using the program FLASH.
Mostly zeros. Flash is a free program to program 8051s. It can erase and read
programs already in 8051s as well as upload new program hex files to 8051s. I'll
spare you from uploading the 32K hex file here.


The first free dissembler I tried (DIAS5051) did not work.
I then used free D51 to disassemble the asm code generated by the MikroBASIC.

Here it is.

;
;  D51 V2.6 8051 Disassembly of blink.hex
;  8/24/2012 2:12
;
	org	0
;
X0000:	ljmp	X002e
;
	ljmp	X0000
;
	org	0bh
;
	ljmp	X0000
;
	org	13h
;
	ljmp	X0000
;
	org	1bh
;
	ljmp	X0000
;
	org	23h
;
	ljmp	X0000
;
	org	2bh
;
	ljmp	X0000
;
X002e:	mov	sp,#80h
X0031:	mov	p0,#0
	mov	p1,#0
	mov	p2,#0
	mov	p3,#0
	mov	r5,#6
	mov	r6,#11h
	mov	r7,#0fdh
X0043:	djnz	r7,X0043
	djnz	r6,X0043
	djnz	r5,X0043
	mov	p0,#0ffh
	mov	p1,#0ffh
	mov	p2,#0ffh
	mov	p3,#0ffh
	mov	r5,#6
	mov	r6,#11h
	mov	r7,#0fdh
X005b:	djnz	r7,X005b
	djnz	r6,X005b
	djnz	r5,X005b
	sjmp	X0031
;
X0063:	sjmp	X0063
;
	end
;


Needles to say I am extremely pleased. The 8051 is the 6502 of today.
Like any disassembler the labels have seemingly meaningless assigned numbers. What
did you expect fully commented source code? :)

Here is the BASIC version.
' *
' * Project name:
'     LED_Blinking (Simple 'Hello World' project)
' * Copyright:
'     (c) Mikroelektronika, 2009.
' * Revision History:
'     20080725:
'       - initial release;
' * Description:
'     This is a simple 'Hello World' project. It turns ON/OFF diodes connected to
'     PORT0, PORT1, PORT2 and PORT3.
' * Test configuration:
'     MCU:             AT89S8253
'                      http://www.atmel.com/dyn/resources/prod_documents/doc3286.pdf
'     Dev.Board:       Easy8051B
'                      http://www.mikroe.com/en/tools/easy8051b/
'     Oscillator:      External Clock 10.0000 MHz
'     Ext. Modules:    -
'     SW:              mikroBasic PRO for 8051
'                      http://www.mikroe.com/en/compilers/mikrobasic/8051/
' * NOTES:
'     - Turn ON the PORT LEDs.
'     - On Easy8051B LEDs are activated by logical zero
'       http://www.mikroe.com/pdf/easy8051b_manual.pdf#page=14&zoom=100

program LED_Blinking

main:
  while TRUE
    P0 = 0x00        ' Turn ON diodes on PORT0
    P1 = 0x00        ' Turn ON diodes on PORT1
    P2 = 0x00        ' Turn ON diodes on PORT2
    P3 = 0x00        ' Turn ON diodes on PORT3

    Delay_ms(1000)   ' 1 second delay

    P0 = 0xFF        ' Turn OFF diodes on PORT0
    P1 = 0xFF        ' Turn OFF diodes on PORT1
    P2 = 0xFF        ' Turn OFF diodes on PORT2
    P3 = 0xFF        ' Turn OFF diodes on PORT3
    Delay_ms(1000)   ' 1 second delay
  wend               ' Endless loop
end.

This makes writing new EFI systems a piece of cake.

A matter of a few days.

Paul Lamar

-- The Rotary Engine News Letter. Powered by Linux. ACRE NL web site. http://www.rotaryeng.net You Tube key word PaulLamar2 Copyright 1998-2012 All world wide rights reserved.