1 / 149

Chapter 5

Chapter 5. Assembly Language. The Level-ISA3 language is machine language, sequences of 1’s and 0’s sometimes abbreviated to hexadecimal (last chapter). Two types of bit patterns. Instructions Mnemonics for opcodes Letters for addressing modes Data

castillo
Download Presentation

Chapter 5

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. Chapter 5 Assembly Language

  2. The Level-ISA3 language is machine language, sequences of 1’s and 0’s sometimes abbreviated to hexadecimal (last chapter)

  3. Two types of bit patterns • Instructions • Mnemonics for opcodes • Letters for addressing modes • Data • Pseudo-ops, also called dot commands

  4. Two types of bit patterns • Instructions • Mnemonics for opcodes • Letters for addressing modes • Data • Pseudo-ops, also called dot commands

  5. Example • machine language instruction C0009A • 1100-0000 0000-0000 1001-1010 • 1100-raaa load register accumulator(r=0) • Immediate addressing(aaa=000) • This instruction is written in the Pep/9 assembly language as • LDWA 0x009A,i • LDWA, (mnemonicload word accumulator) • 0x hexadecimal constant • i, addressing mode

  6. Figure 5.1

  7. QUESTION • Convert following machine language instructions to assembly language • 1100 0011 0000 0000 1001 1010    • 1100 0110 0000 0000 1001 1010    • 1100 1011 0000 0000 1001 1010    • 1100 1110 0000 0000 1001 1010    LDWA 0x009A,s LDWA 0x009A,sx LDWX 0x009A,s

  8. ANSWER • 1100 0011 0000 0000 1001 1010   LDWA 0x009A,s • 1100 0110 0000 0000 1001 1010   LDWA 0x009A,sx • 1100 1011 0000 0000 1001 1010   LDWX 0x009A,s • 1100 1110 0000 0000 1001 1010   LDWX 0x009A,sx

  9. Figure 5.2  40 instructions of the Pep/9 instruction set at Level Asmb5  instruction is unary (U)

  10. Figure 5.2 (continued)

  11. Figure 5.2 (continued)

  12. Figure 5.2 (continued)

  13. The unimplemented opcode instructions • NOPn Unary no-operation trap • NOP Non-unary no-operation trap • DECI Decimal input trap • DECO Decimal output trap • HEXO Hexadecimal output trap • STRO String output trap • These new instructions are available to the assembly language programmer at Level Asmb5, but they are not part of the instruction set at Level ISA3. The operating system at Level OS4 provides them with its trap handler.

  14. Two types of bit patterns • Instructions • Mnemonics for opcodes • Letters for addressing modes • Data • Pseudo-ops, also called dot commands

  15. Pseudo-operations(pseudo-ops/dot commands ) • Assembly language statements. • Do not have opcodes and do not correspond to any of the 40 instructions in the Pep/9 instruction set. • .ADDRSS The address of a symbol • .ALIGN Padding to align at a memory boundary • .ASCII A string of ASCII bytes • .BLOCK A block of zero bytes • .BURN Initiate ROM burn • .BYTE A byte value • .END The sentinel for the assembler • .EQUATE Equate a symbol to a constant value • .WORD A word value All the pseudo-ops except .BURN, .END, and .EQUATE insert data bits into the machine language program.

  16. Question • Convert the following machine language instructions into assembly language, assuming that they were not generated by pseudo-ops: • (a) 9AEF2A • (b) 03 • (c) D7003D

  17. Answer • (a) 9AEF2A • 1001-1010-1110-1111-0010-1010 • r=1 = x  ORX • aaa = 010  addressing mode = indirect  n • Operand –specifier = EF2A • ANSWER: ORX 0xEF2A,n

  18. Answer • (b) 03 • 0000 - 0011 • ANSWER: MOVSPA

  19. Answer • (c) D7003D • 1101-0111-0000-00000-0011-1101 • r=0 = A  LDBA • aaa = 111  addressing mode = sfx • Operand –specifier = 003D • ANSWER: LDBA 0x003D,sfx

  20. Question • Convert the following assembly language instructions into hexadecimal machine language: • (a) ASLA • (b) DECI 0x000F,s • (c) BRNE 0x01E6,i

  21. Answer • (a)ASLA • ASLA  r = A  0 • 0000 -1010 • ANSWER: 0A

  22. Answer • (b) DECI 0x000F,s • s  addressing mode = 011 • 0011 – 0011 – 0000 – 0000 – 0000 - 1111 • ANSWER: 33 00 0F

  23. Answer • (c) BRNE 0x01E6,i • i addressiong mode = 0 • 0001-1010-0000-0001-1110-0110 • ANSWER: 1A 01 E6

  24. QUESTION • Convert following program into assembly in Pep/9 Memory address

  25. ANSWER The .ASCII and .END Pseudo-ops Comment

  26. run • Build menu: assemble  load execute

  27. Buildassemble Object code Assembler Listing

  28. BuildLoad  BuildExecute

  29. Run source hi.pep Assemble, Load, Execute — are combined in the single option called Run Source

  30. Step through

  31. The .ASCII pseudo-op • The backslash prefix • To include a double quote in your string, you must prefix it with a backslash \. • E.g."She said, \"Hello\"." • To include a backslash, prefix it with a backslash. • E.g. "My bash is \\." • You can put a newline character in your string by prefixing the letter n with a backslashand put a tab character by prefixing the letter t with a backslash. • E.g"\nThis sentence will output on a new line."

  32. QUESTION • Write an assembly language program that prints your first name on the screen. Use the .ASCII pseudo-op to store the characters at the bottom of your program. Use the LDBA instruction with direct addressing to output the characters from the string. The name you print must contain more than two letters.

  33. ANSWER

  34. Figure 5.4 ASSEMBLER

  35. Figure 5.5

  36. .BLOCK pseudo-op • generates the next byte of 0’s for storage • The assembler interprets any number not prefixed with 0x as a decimal integer (e.g. 1 here). • E.g. .BLOCK 1

  37. QUESTION • Convert following program from machine code to assembly

  38. Figure 5.6 ANSWER BLOCK Pseudo-op Assembler generates the next byte of 0’s for storage

  39. The .WORD and .BYTE Pseudo-ops • .WORD • Like the .BLOCK command • Two differences: • it always generates one word (two bytes) of code, not an arbitrary number of bytes. • the programmer can specify the content of the word.

  40. The dot command .WORD 5 • means “Generate one word with a value of 5 (dec).” • The dot command .WORD 0x0030 • means “Generate one word with a value of 0030 (hex).”

  41.  .BYTE command : • works like the .WORD command • except that it generates a byte value instead of a word value. • In this program, you could replace .WORD 0x0030 with .BYTE 0x00 .BYTE 0x30 and generate the same machine language.

More Related