12.07.2015 Views

EEE 410 – Microprocessors I - faraday

EEE 410 – Microprocessors I - faraday

EEE 410 – Microprocessors I - faraday

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

INTRODUCTION TO ASSEMBLY PROGRAMMINGMachine Language:‣ Programs consist of 0s and 1s are called machine language.‣ Assembly Languages provided mnemonics for machine code instructions.‣ Mnemonics refer to codes and abbreviations to make it easier for the users to remember.Low / High level languages:‣ Assembly Language is a low-level language. Deals directly with the internal structure of CPU.Assembler translates Assembly language program into machine code.‣ In high-level languages, Pascal, Basic, C; the programmer does not have to be concerned with internaldetails of the CPU. Compilers translate the program into machine code.Assembly Language programming:‣ Assembly Language program consists of series of lines of Assembly language instructions.‣ Instruction consists of a mnemonic and two operands.MOV instructionMOV destination, source; copy source operand to destinationmnemonicoperandsExample: (8-bit )MOV CL,55HMOV DL,CLMOV BH,DLMOV AH,BHExample: (16-bit)MOV CX,468FHMOV AX,CXMOV BX,AXMOV DX,BXMOV DI,AXMOV SI,DIMOV DS,SIMOV BP,DS;move 55H into register CL;move/copy the contents of CL into DL (now DL=CL=55H);move/copy the contents of DL into BH (now DL=BH=55H);move/copy the contents of BH into AH (now AH=BH=55H);move 468FH into CX (now CH =46 , CL=8F);move/copy the contents of CX into AX (now AX=CX=468FH);now BX=AX=468FH;now DX=BX=468FH;now DI=AX=468FH;now SI=DI=468FH;now DS=SI=468FH;now BP=DS=468FH‣ Data can be moved among all registers except the flag register. There are other ways to load the flagregisters. To be studied later.‣ Source and destination registers have to match in size.‣ Data can be moved among all registers (except flag reg.) but data can be moved directly intononsegment registers only. You can’t move data segment registers directly.Examples:MOV BX,14AFH ;move 14AFH into BX (legal)MOV SI,2345H ;move 2345H into SI (legal)MOV DI,2233H ;move 2233H into DI (legal)MOV CS,2A3FH ;move 2A3FH into CS (illegal)MOV DS,CS ;move the content of CS into DS (legal)MOV FR,BX ;move the content of BX into FR (illegal)MOV DS,14AFH ;move 14AFH into DS (illegal)


‣ Important points:• Values cannot be loaded directly into (CS,DS,SS and ES)MOV AX,1234H ; load 1234H into AXMOV SS,AX ;load the value in AX into SS• Sizes of the values:MOV BX,2H; BX=0002H, BL:02H, BH:00HMOV AL,123H ; illegal (larger than 1 byte)MOV AX,3AFF21H ; illegal (larger than 2 bytes)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!