| Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| Unsigned | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
Range of 32 bit unsigned - 0 to 232 - 1 or 0 to 4,294,967,295
(i.e. 000000000000000000000000000000002 to
111111111111111111111111111111112)
Range of n bit unsigned - 0 to 2n-1
0011 = 3 0101 = 5 3 3 0011 3 1011 = -3 1101 = -5 -5 +(-5) +1101 +(-5) -2 -2 10000 0
0011 = 3 0101 = 5 3 3 0011 3 1100 = -3 1010 = -5 -5 +(-5) +1010 +(-5) -2 -2 1101 -2
0011 = 3 0101 = 5 3 3 0011 3 1's 1100 = -3 1010 = -5 -5 +(-5) +1011 +(-5) +1 +1 -2 -2 1110 -2 2's 1101 1011
Range of 32 bit two's complement -232-1 to 232-1
or -2,147,483,648 to 2,147,483,647
(i.e. 100000000000000000000000000000002 to
011111111111111111111111111111112)
Range of n bit two's complement -2n-1 to 2n-1-1
| Decimal | Signed
Magnitude |
One's
Complement |
Two's
Complement |
| 0 | 0000 | 0000 | 0000 |
| 1 | 0001 | 0001 | 0001 |
| 2 | 0010 | 0010 | 0010 |
| 3 | 0011 | 0011 | 0011 |
| 4 | 0100 | 0100 | 0100 |
| 5 | 0101 | 0101 | 0101 |
| 6 | 0110 | 0110 | 0110 |
| 7 | 0111 | 0111 | 0111 |
| -0 | 1000 | 1111 | None |
| -1 | 1001 | 1110 | 1111 |
| -2 | 1010 | 1101 | 1110 |
| -3 | 1011 | 1100 | 1101 |
| -4 | 1100 | 1011 | 1100 |
| -5 | 1101 | 1010 | 1011 |
| -6 | 1110 | 1001 | 1010 |
| -7 | 1111 | 1000 | 1001 |
| -8 | None | None | 1000 |
Using the Appendix E, page A-115, the character A is in row 4 and column 1 so is code 4116. Character M is in row D16 and column 4 so is code D416.
|
![]() |
Data Segment Offset Contents
Offset Memory 0000 0F 00 1B 43 41 42 43 44
0000 X Dw 15 0008 45 01 00 02 00 03 00 09
0002 Y Db 27 0010 09 09 09 09 78 56 34 12
0003 C Db 'C'
0004 Name Db 'ABCDE'
0009 Z Dw 1, 2, 3
000F A Db 5 dup(9)
0014 N Dd 12345678h
0018
|
Max equ 100 in Assembler is equivalent to C++: #define Max 100
|
AX
|
Mov eAx, 1234h Address Stack Before Push Stack After Push Push eAx 0008 0000 0000 eAx = 1234 eSP-> 0006 0000 0000 0004 0000 0000 0002 0000 eSP-> 1234 |
Mov eAx, 1234h Address Stack Before Push Stack After Pop Pop eAx 0008 0000 eSP-> 0000 0006 0000 0000 eAX = 5678 eSP-> 0004 5678 5678 0002 0000 0000
Mov eDx, 1234h Address Stack Before Stack After Push Mov eBx, 5678h eSP-> 000C 0000 0000 Push eDx 0008 0000 1234 Push eBx 0004 0000 eSP-> 5678 0000 0000 0000 Address Stack Before Stack After Pop
000C 0000 eSP-> 0000
Pop eDx 0008 1234 1234
Pop eBx eSP-> 0004 5678 5678
0000 0000 0000
eDX = 5678
eBX = 1234
|
- eAX, eBX, eCX, eDX 32-bit general purpose registers (can be operands in most instructions, Add, Mov, Xchg, etc.)
- AX, BX, CX, DX - 16-bit general purpose registers (can be operands in most instructions, Add, Mov, Xchg, etc.).
- AH, AL, BH, BL, CH, CL, DH, DL - The corresponding high and low 8-bits of the AX, BX, CX, DX registers.
- eSP - 32-bit stack pointer.
- eIP - Instruction pointer 32-bit, points to the next instruction to be fetched.

| CS
Code Segment (Algorithm) |
ES
Extra Segment |
| DS
Data Segment |
SS
Stack Segment |
To understand how segmented memory addressing works consider when a
memory variable is accessed by the instruction, Mov X, 74h. Assume
physical
memory, the location of X in the segment, and the Ds register are defined
as below. Remember that the DS register points to the start of the
Data
Segment where X is located. The offset of X is the distance
of the location of X from the start of the segment.
|
|
|
| Physical Address X = Ds*10h + offset X = 1230h*10h + 0048h = 12300h + 0048h = 12348h |
Physical Address of fetch = Cs*10h + Ip
Physical Address Push or Pop = Ss*10h + Sp
Data Segment Variable definitions Data Ends Code Segment Assume CS:Code, DS:Data, SS: Sseg ;; Associate CS with Code ;; DS with Data, SS with Sseg Proc1 Proc Far Algorithm Proc1 Endp Proc2 Proc Far Algorithm Proc2 Endp Code Ends Sseg Segment STACK Db 254 dup(?) Sseg Ends End Proc2 ;; First instruction executed ;; is Proc2 |
0000 DATA Segment ;;Data Segment 0000 0064 R DW 100 ;; R = 23 0002 0008 S DW 8 ;; S = 8 0004 0001 T DW 1 ;; T = 1 0006 0000 U DW ? ;; U is uninitialized 0008 DATA Ends ;; End of segment DATA 0000 ALGORITHM Segment ;;Algorithm Segment Assume Cs:ALGORITHM, Ds:DATA, Ss:SSeg 0000 HW1 Proc Far ;; Procedure HW1 0000 BB ---- R Mov Bx, Seg DATA ;; Initialize DS register 0003 8E DB Mov Ds, Bx ;; to address of data segment |
Assume DS:Sseg, SS:Data
but the initialized Ss segment register would be used by stack operations Push and Pop. Note that the Assume does not initialize the segment registers so the Mov DS, Bx is needed to initialize DS to some known value.