Download presentation
Presentation is loading. Please wait.
Published byClaribel Gibson Modified over 8 years ago
1
First Foray into Programming (the hard way)
2
A reminder from last lesson: A machine code instruction has two parts: Op-code Operand An instruction set is a list of all the Op- Codes, such as: Load Add Store
3
Machine Code Machine code is a series of 1s and 0s We can easily encode our instruction – each instruction has a binary representation. Op-Code (4 bit)Machine Operation 0000Load from memory 0001Load operand value 0100Add from memory 0101Add operand value 1000Store into memory
4
Representing a full instruction One instruction is 16 bits (how many bytes?) long. This is our word size. The first 4 bits are the op-code, the rest is the operand. QUESTION - How many memory locations can be addressed?
5
Machine Code vs Assembly 0001 0000 0001 0111 0100 0000 0000 0010 1000 0000 0100 0010 vs Load #23 Add 2 Store 65 This is a 1-to-1 mapping
6
Questions Using a 2 byte word with a 4-bit op-code, write the following in machine code: Load 76 Add #43 Add 90 Store 12 Load #45 Write the following in assembly language: 1000 0010 1111 1010 0101 1000 0010 1100 0001 0010 1000 0111
7
Hexadecimal Hex is the base-16 number system, the 16 digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Sometimes A-F are in lower case A3 = 10*16^2 + 3*16 = 10*256 + 3*16 = 2560 + 48 = 2608 6D = 6*16^2 + 13*16 = 6*256 + 13*16 = 1536 + 208 = 1744
8
Hexadecimal (2) Each 4-bit binary number can be represented by one hex digit. Write the following in hex: 1000 0010 1111 1010 0101 1000 0010 1100 0001 0010 1000 0111 Load 76 Add #43 Add 90
9
Homework Create a program that does something involving all 5 op codes. Write this in assembly using a 2-byte word. Convert this into machine code in denary Finally, write this in hexadecimal.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.