I have included this chapter for those of you who want to learn the main features of the SB-Assembler fast. This chapter presents the most important features of the SB-Assembler. Details about all features can be found in the separate chapters of this online user guide.
As an example I'll use a 8051 program in this quick start chapter that demonstrates the most important features of the SB-Assembler.
This example program doesn't excel in usefulness, which never was my intention anyway.
The task of the program is to repeatedly cycle an imaginary output port low for a short while and high for a little longer.
The program can be typed in with any text editor (not a word processor). Use the one which you are most familiar with on your platform. Save the file somewhere, where it can be found later. You can use any file name you like, e.g. test.asm .
If you're a Linux, Unix or MAC user, open a terminal and change to the directory containing your test file and type the command sbasm test .
If you're runnning on Microsoft system open a DOS box, change to the directory containing your test file and type the command sbasm test .
The program will be ready in a fraction of a second and a new file will be created in the current directory with the name test.hex . This new file contains the generated code in Intel Hex format.
The listing will be sent to the screen this time. However it is also possible to send the listing to a file by using the .LF directive.
.CR 8051 Select the 8051 Cross-Overlay .TF test.hex,INT Send code in Intel Hex format to ; this file .OR $0000 Program starts at this address STACK .EQ $70 Begin of stack SP .EQ $81 SFR register for stack pointer P1 .EQ $90 SFR register for port P1 DELAY .EQ 100 Delay loop count START MOV SP,#STACK Initialize stack MOV P1,#%1111.1111 Initialize port .LOOP CLR P1.3 Make bit 3 of P1 low CALL SHORT Take a short delay SETB P1.3 Make bit 3 of P1 high CALL LONG Take a long delay JMP .LOOP Repeat for ever SHORT MOV R0,#DELAY Prepare delay counter .LOOP NOP Do nothing for a while DJNZ R0,.LOOP Repeat 100 times RET LONG MOV R0,#DELAY*2 Prepare delay counter .LOOP NOP Do nothing for a while DJNZ R0,.LOOP Repeat 200 times RET
Some of you may notice a few peculiarities if you're already familiar with other assemblers.
Others don't know what the fuss is all about.
And still others don't have the faintest clue of what is happening here.
Don't worry, I'll try to explain everything shown above. I won't explain the basics of programming in assembly language though. Many good books are available on that subject already.
You may also find a hands-on training in programming microprocessors for beginners at our Sitcom project, which Izabella Malcolm and I have written way back. There we've tried to explain the basics of micro processor programming. Unfortunately we had to discontinue the work on these sites.
Finally a little note on the 8051 Cross Overlay:
Special Function Registers (SFR registers) of the 8051 processor are not pre-defined!
Therefore all used SFRs should be declared using normal .EQ directives.
You may create an include file containing all declarations of the SFR registers available to your specific processor if you want.
This makes the SB-Assembler flexible because other 8051 members may have SFR registers not found on the basic version of the processor.
I have included 2 files in the download package declaring the SFR registers of the standard 8051 and 8052 processors.
That's not all!
The SB-Assembler offers many more features than listed in this small example.
All features are documented in detail in other chapters.
Someone with some experience in assembly language programming should be able to continue from here without great difficulties.