1 / 22

Back to Assembly lang

Back to Assembly lang. name operation operand(s) ;comment. START: MOV CX , 5 ; যা ইচ্ছা লিখ! ‘ ; ’ দিও!. name operation operand(s) ;comment. Okay  letters, digits, ?, ., @, _, $, % Illegal names – If any blanks – aaa aaa If begin with a digit – 2asad

neorah
Download Presentation

Back to Assembly lang

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Back to Assembly lang

  2. name operation operand(s) ;comment START: MOVCX, 5 ;যা ইচ্ছা লিখ! ‘;’ দিও!

  3. name operation operand(s) ;comment • Okay  letters, digits, ?, ., @, _, $, % • Illegalnames – • If any blanks – aaaaaa • If begin with a digit – 2asad • If ‘.’ not first char. – aq.12 • If has illegal char – aa&bb

  4. name operation operand(s) ;comment • For an Instruction: Symbolic operation code [opcode]: Assembler translates these codes into Machine lang opcode.  MOV, ADD, SUB, … • For an Directive: pseudo-operation code – pseudo-op, do not translate  PROC is used to create a procedure

  5. name operation operand(s) ;comment • An instruction may have 0/1/2 operands e.g., NOP ; no operands – does nothing INC AX ; 1 op. – adds 1 to contents of AX ADDdestination, source

  6. 4.2 Program data • Binary – 1011b, 1100B • Decimal – 10111, 10111d, -3419D 1,23 – x • Hex – start with a decimal digit, ends with ‘H’ – 3BA3H, 0FFFFH • Characters – within ‘aa’ or “aa”

  7. Pseudo-ops • DB – define data BYTE • DW – word • DD – doubleword – two consecutive words • DQ – quadword – 4 … • DT – tenbytes – 10…

  8. 4.3 Variables name operation operand(s) ;comment name DB initial value ; -128 ~ 127; or 0-255 e.g., ALPHA DB 4 ; variable ALPHA=4 AA DB ? ; uninitialized byte

  9. 4.3.3 Array EktaArray DB 10H, 20H, 22H Symbol Address Contents EktaArray 200h 10H EktaArray+1 201h 20H EktaArray+2 202h 22H

  10. For DW – 2 bytes Symbol Address Contents EktaArray 200h 10H EktaArray+2 202h 20H EktaArray+4 204h 22H

  11. WORD1 DW 1234H ; low Byte of WORD1 contains 34H ; high Byte of WORD1 contains 12H

  12. 4.5 basic instructions • MOV – move; contents of destination is replaced by the contents of source • XCHG – exchange; swapping Q: exa??

  13. ADD W1, AX ;W1 = W1 + AX ;W1 – changes with added/sum value ;AX – unchanged • SUB AX, DX ;Subtract DX from AX ;New value in AX – AX changes ; DX unchanged

  14. Direct ADD/SUB between memory locations WRONG! • ADD W1, W2 ; wrong as direct memory location Source Destination General Reg. Memory loc. Gen Reg. Yes Yes Memory Loc. Yes NO Constant Yes Yes

  15. INCIncrement • INC destination INC W1 ;e.g., W1=0003 Before W1=0003 After INC, W1=???? 0004

  16. DECDecrement • DEC destination DEC W1 ;e.g., W1=FFFF Before W1=FFFF After INC, W1=???? FFFE

  17. NEGnegate the contents of destination • NEG destination ; reg. / mem. ; replace the contents by it’s two’s complement NEG W1 ;e.g., W1=0002 Before W1=0002 After NEG, W1=???? FFFE

  18. Note: • Both types MUST be the same type e.g., MOV AH, ‘A’ ; what is in AH? ; ‘A’ = 41H MOV AX, ‘A’ ; what is in AX? 41H 0041H

  19. Do!High- to Assembly • B = A • A = 5 – A • A = B – 2 x A

  20. 1. B = A • MOV AX, A • MOV B, AX • A direct mem-to-mem move is illegal

  21. 2. A = 5 - A • MOV AX, 5 • SUB AX, A • MOV A, AX • NEG A • ADD A, 5

  22. 3. A = B – 2xA • MOV AX, B ;AX = B • SUB AX, A ;AX=B-A • SUB AX, A ;AX=B-A – A ; AX = B – 2A • MOV A, AX ; A = AX = B – 2A

More Related