Friday, 1 April 2011

Instructions For Program Flow Control

with instruction for program flow control, microcontroller can to jump or branch to the address of memory program to take another action. Each action is consisting of a set of microcontroller instructions. This branching instructions are partitioned in to two categories, unconditional and conditional jump.

Instructions for Unconditional Jump

This instruction is happened without any condition that must be met. There are four instructions for unconditional jump in MCS 51 family assembly language, i.e SJMP, AJMP, LJMP and JMP.

Instructions for Conditional Jump

This instruction is happened if satisfy a certain condition. There are about eight instructions for conditional jump in MCS 51 family assembly language, i.e JZ, JNZ, JC, JNC, JB, JNB, CJNE, and DJNZ.


source:

http://trensains.com/interruption.htm


Instruction For Data Processing

Commonly, data processing instruction are grouped in to two categories: instructions for logical operation and arithmetic.Instructions for arithmetic consist of addition, subtraction, increment, decrement, multiplication, division and decimal adjustment. instructions for logical operation consists of AND, OR, EX-OR, complement, clear, rotation and swap.

Almost of these instructions are using register A (accumulator) at every operation (for multiplication and division are using accumulator . Such instructions add, subb, mul and div. Where as inc and dec can be hold in every register.

Addition and subtraction operation.

Example code for this operation is shown below.

org 00h

mov a, #20 ;putting 20 in to accumulator

add a, #8 ;adding accumulator by 8. The result is stored in accumulator (acc=28)

; this is an example for immediate addressing mode

mov 70h, #4 ;putting 4 in to register that has address 70h

add a, 70h ;adding accumulator by the contents of register that has address 70h (acc=32)

; this is an example for direct addressing mode

mov 78h, #9 ;putting 9 in to register that has address 78h

mov r0, #78h ;putting 78h in to register r0

add a, @r0 ;adding acc by the contents of the register that its address is stored in r0 (acc=41)

mov a, #100 ;putting 100 in to accumulator

subb a, #8 ;subtraction acc by 8 (acc=92)

....

....

Increment and decrement operation.

org 00h

mov a, #10 ;putting 10 in to accumulator

inc a ;adding accumulator by 1

dec a ;subtracting accumulator by 1

mov r0, #9 ;putting 9 in to register r0

inc r0 ;adding register r0 by 1

dec r0 ;subtracting register r0 by 1

.....

.....

Multiplication and division operation.

org 00h

mov a, #10 ;putting 10 in to accumulator

mov b, #2 ;putting 2 in to register B

mul ab ;multiply content of accumulator by the content of B,

;The result is stored in A (low byte) and high byte is stored in B

mov a, #20 ;putting 20 in to accumulator

mov b, #4 ;putting 4 in to register B

div ab ;dividing the content of accumulator by the content of B

; the result is stored in A, where as the reminder is stored in B

...

...

Decimal adjustment

org 00h

mov a, #10h ;putting 10h in to accumulator (acc=10h)

da a ;adjusting the content of accumulator in to decimal number (acc=80bcd)

...

...

org 00h

mov a, #0FFh ;putting FFh in to accumulator

anl a, #0F ;force high nible low (acc=00001111b)

mov a, #10101010b ;putting 10101010 in to accumulator

orl a, #0F0h ;force high nible high (acc=11111010b)

cpl a ; complement the content of accumulator (acc=00000101b)

clr a ; clear the content of accumulator (acc=00000000b)

...

...


source : http://trensains.com/data_processing.htm

Instruction for Data Transfer

The general instruction for transferring data is MOV instruction. This instructions is used for byte and bit oriented that are grouped in to several category, such as immediate addressing mode, direct addressing mode, register indirect addressing mode and stack data transfer.

Another word to describe immediate addressing mode is immediate constant addressing, that refers to the source data is a constant. The example of this mode is describe below :

org 00h

mov a, #10h

mov a, #11111010b

mov r0, #28

...

...

The beginning code is org 00h, has means that the origin of the code is occupy at 00h.

mov a, #10h is putting 10 h in to the accumulator

mov a, #11111010b is putting 11111010b in to the accumulator

mov a, #28 is putting 28 in to the accumulator

This mode refers to specifying an internal data registers by its address. The example of this mode is describe below :

org 8000h

mov a, 70h

mov r0, #11111010b

mov 70h, r0

...

...

The beginning code is org 8000h, has means that the origin of the code is occupy at 8000h.

mov a, 70h is copying contents of register that has address 70h to the accumulator

mov r0, #11111010b is putting 11111010b in to the register r0

mov 70h, r0 is copying contents of r0 (11111010b) to the register that has address 70h

In this mode, the address of the source is not given explicitly but include in the target register. The example of this mode is describe below :

org 00h

mov r0, #70h

mov @r0, #28h

...

...

The beginning code is org 00h, has means that the origin of the code is occupy at 00h.

mov r0, #70h is putting 70 h in to regisrtor r0

mov @r0, #28h is putting 28h in to the address that saved in register r0


source : http://trensains.com/data_transfer.htm

Assembly Language For AT89C51

A microcontroller reads data from its ports, then executes that data with appropriate instruction that be saved on its memory. Finally, a microcontroller emits the result of processed data to its ports (depends on the program).

All of microcontroller operation is appropriate to that code. The data code is interpreted as an instruction that be stored by microprocessor in a register, called the program counter.

The code is hex intel formatted. The program can be write as assembly language then compiled to hex file by assembler such as ASEM 51.

  • Instructions for Data Transfer
  • Instructions for Data Processing
  • Instructions for Program Flow Control
  • Interruptions Handling
  • Code Compiling


Instructions for Data Transfer

This instructions is used for data transfer from one register to another, include its ports.


Instructions for Data Processing

This instructions is used for data processing in specific register, such as arithmetic operation and logical operation.


Instructions for Program Flow Control

This instructions is used for controlling program flow, such as unconditional and conditional jump to another address.


Interruptions Handling

This instructions is used for interruption handling, such as timer, external and serial communication interrupt.

Induktor

Secara fisik, induktor adalah berupa lilitan dari kawat penghantar (yang memiliki isolasi), baik berinti besi atau udara. Induktor memiliki dua bentuk yaitu belitan dengan inti yang lurus (dikenal dengan solenoid) dan belitan dengan inti melingkar (dikenal sebagai toroid). Gambar berikut adalah penjelasan tentang induktor (solenoid).

Prinsip Kerja Solenoid.

Garis-garis warna biru adalah merupakan garis gaya medan magnet. Dari gambar dapat dilihat bahwa garis gaya medan magnet paling banyak (kuat) terdapat di tengah solenoid. Di luar itu, garis gaya magnetnya adalah lemah. Untuk menghitung besarnya induktansi solenoid, maka dapat menggunakan persamaan berikut:

dengan L adalah nilai induktasi (satuan Henry), µ adalah nilai permeabilitas inti, N adalah banyaknya belitan, A adalah luas dari penampang melintang induktor (meter persegi), sedangkan l adalah panjang toroid (meter).

Penjelasan toroid diperlihatkan pada gambar berikut:

Prinsip Kerja Toroid

Untuk menghitung besarnya induktansi toroid, maka dapat menggunakan persamaan berikut:

dengan L adalah nilai induktasi (satuan Henry), µ adalah nilai permeabilitas inti, N adalah banyaknya belitan, A adalah luas dari penampang melintang induktor (meter persegi), sedangkan r adalah jari-jari toroid (meter).


source : http://trensains.com/induktor.htm