Like this:

“Typically a modern assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities. The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications.”

Types of assembler:

There are two types of assemblers based on how many passes through the source are needed to produce the executable program.

One-pass assemblers go through the source code once and assume that all symbols will be defined before any instruction that references them.

Two-pass assemblers create a table with all symbols and their values in the first pass, then use the table in a second pass to generate code. The assembler must at least be able to determine the length of each instruction on the first pass so that the addresses of symbols can be calculated.

The advantage of the two-pass assembler is that symbols can be defined anywhere in program source code, allowing programs to be defined in more logical and meaningful ways, making two-pass assembler programs easier to read and maintain.

Starting now to make an assembler one first has to define an input and output form. That is what assembler takes as input and what kind of output it will provide. In here I’m trying to make an assembler based on book “System Programming and Operating System by D M Dhamdhere” so I’m assuming following input form:

start 101

read n

mover breg,one

movem breg,term

again: mult breg,term

add creg,one

movem creg,term

comp creg,four

bc le,again

div breg,two

movem breg,result

print result

stop

n ds 2

result ds 1

one dc ‘1’

term ds 1

two dc ‘2’

four dc ‘4

end

And output form:

101) 90113

102) 42116

103) 52117

104) 32117

105) 13116

106) 53117

107) 63119

108) 72104

109) 82118

110) 52115

111) 100115

112) 0 000

113)

115)

116)00 0 001

117)

118)00 0 001

119)00 0 001

120)

At first declare fix structures that contains default information to be used.

In above code I have declared all required struct that holds default information used in our program. The first one is “directive” which holds predefined directives and its code. Second one “mnemtab” holds mnemonics, its opcode and its length. Third one “regtab” is used for holding register name and its code. Fourth one “dclcode” are used for declaration statements and its code. The final one “compcode” are used for comparison symbols and its code. Beside this create some more structure that we will be used to store information as it process the input file:

In above 4 structs the first one is used as buffer that will store information about the line that will be processed at the time. Second one is used as symbol table. This will store all symbol and its relevant addresses in it. The third one “littab” is used to store literals and its relevant address. Now create some getter, setter and update methods for above declared structs. First for getting directive code based on directive:

Update symbol to add new symbol entry in it. This function will also check for duplicate declaration of symbol. If duplicate declaration found then shows warning as “Multiple declaration of [symbolName]”.

Up to now I have declared data structure kind thing for the assembler and now let’s start building processing of assembler. At first one need to parse the input file to get desired information for this I have used following method which tokenize file line by line & store each token into buffer.

Now that data is parsed from file let’s start processing on this data. In pass-1 assemblers create a table with all symbols and their values. Also the assembler at least be able to determine the length of each instruction on the first pass so that the addresses of symbols can be calculated. I have created following method for Pass – 1 of assembler.

LightBox.jar--- Jar that helps you providing light box like effect in your desktop application built in swing.

You may have seen light box effects on a website but very rarely have seen light box effect in a desktop application specifically in applications that are built in java swing. This jar helps you put light box like effect into your swing application. So now you can also give same light box effect as on your website to your desktop application made in swing.

Light box effect

It’s very simple and easy to use this jar. You just have to create a instance of LightBoxclass and then call createLightBoxEffect() method on it with desired parameters and have a light box effect in your frame with a JPanel as popup.

This jar contains following 4 classes:

LightBox.java

Main class that helps in providing light box like effect using JFrame and JPanel.

If light box is modal then this listener will be added to light box so that all mouse clicks and other mouse events comes in this class and not get passed to underlying components. This is the simplest way I thought about making light box effect modal.

LightBoxException.java

Exception class for Light box effect jar.

Following is the description of constructor and methods of the class used to provide light box effect in this jar:

Constructors:

public LightBox()

Creates new LightBox instance. By default the lightbox effect is modal.

public LightBox(boolean modal)

Create new LightBox instance. If modal then all components under light box effect will be not able to generate any event until light box panel is closed.