Presentation is loading. Please wait.

Presentation is loading. Please wait.

Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003.

Similar presentations


Presentation on theme: "Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003."— Presentation transcript:

1 Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003

2 Number Systems Review  Binary System  Hexadecimal System  Conversion from between different number systems  Complements

3 Binary System  Place values consist of powers of 2  0 or 1  Easy to implement in hardware

4 Number Base Conversions  Integer Decimal to Binary  Divide by 2, remainders  Fraction Decimal to Binary -> Multiply by 2, integers  Binary to Decimal  Multiply each digit by its place value in decimal, then add

5 Octal and Hexadecimal Numbers  Octal – base 8 – groups of 3 bits  Hexadecimal – base 16 – groups of 4 bits  Used as another way of representing binary numbers; simpler and easier

6 Complements  Diminished Radix Complement (r n - 1) – N (r - 1)’s complement  Radix Complement r n – N r’s complement

7 Signed Binary Numbers  Signed-magnitude (leftmost bit is sign bit 0-positive 1-negative)  Signed-1’s-complement  Signed-2’s-complement  Addition and subtraction with Signed- 2’s complement is the easiest to implement in hardware

8 Arithmetic Addition/Subtraction  Convert subtraction operation to addition  Represent the addends in 2’s complement form  Discard the carry-out  If the sum is negative, it is already in 2’s complement form

9 Bit Groupings  Byte – 8 bits  Word – 2 bytes  Doubleword – 4 bytes  Quadword – 8 bytes  Paragraph – 16 bytes

10 Boundaries  Word – Every 2 nd byte 0H, 2H, 4H, 6H, 8H  Doubleword – Every 4 th byte 0H, 4H, 8H, CH  Quadword – Every 8 th byte 0H, 8H, 10H  Paragraph – Every 16 th byte 0H, 10H, 20H

11 Big Endian and Little Endian  Determines the byte order in multi- byte data  Big Endian “big-end-first” Most significant byte has lowest address  Little Endian “little-end-first” Least significant byte has lowest address

12 Big Endian  Example: The word 0x1234 is stored in memory as 12 34 The doubleword 0x12345678 is stored in memory as 12 34 56 78

13 Little Endian  Example: The word 0x1234 is stored in memory as 34 12 The doubleword 0x12345678 is stored in memory as 78 56 34 12

14 Endian-ness and Strings  Strings sequences of bytes byte ordering is not affected by the “endian-ness” of a system  For example “CAT” is stored in memory as 43 41 54 00  Assuming character strings are terminated by the null character 00

15 8086 Registers  16-bit registers AX – Accumulator (AH/AL – 8 bits) BX – Base Register (BH/BL – 8 bits) CX – Count Register (CH/CL – 8 bits) DX – Data Register (DH/DL – 8 bits)

16 8086 Registers  SP – Stack Pointer  BP – Base Pointer  SI – Source Index  DI – Destination Index

17 8086 Registers  CS – Code Segment  DS – Data Segment  SS – Stack Segment  ES – Extra Segment  IP – Instruction Pointer

18 8086 Flags Register  The flags register contains the following flags Overflow – OV/NV Direction – DN/UP Interrupt – EI/DI Sign – NG/PL Zero – ZR/NZ Auxiliary Carry – AC/NA Parity – PE/PO Carry – CY/NC

19 Introduction to DEBUG  Debug is a debugger that comes with DOS  16-bit  basic assembler

20 Debug Commands  assemble A [address]  compare C range address  dump D [range]  enter E address [list]  fill F range list

21 Debug Commands  go G [=address] [addresses]  hex H value1 value2  input I port  load L [address] [drive] [firstsector] [number]  move M range address

22 Debug Commands  name N [pathname] [arglist]  output O port byte  proceed P [=address] [number]  quit Q  register R [register]  search S range list  trace T [=address] [value]  unassemble U [range]  write W [address] [drive] [firstsector] [number]

23 First Assembly Program  Enter the following commands in DEBUG A 100  mov dx, 010b  mov ah, 09  int 21  mov ah, 4c  int 21 e 10b 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 24 rcx  19 n prog.com w

24 First Assembly Program  Printing a string  Printing a character  Returning to DOS

25 Printing a string mov dx, mov ah, 9 int 21

26 Printing a character mov dl, mov ah, 2 int 21

27 Returning to DOS mov ah, 4c int 21

28 Programming Exercise #1  Create a program using DEBUG that will display a null-terminated string  Due on the next meeting  Assignment: Why do we have to start the code at offset 0100H? (Hint: This has something to do with.COM programs)


Download ppt "Preliminary to Assembly Language Programming CE 140 A1/A2 28 June 2003."

Similar presentations


Ads by Google