Assembly language--register (Memory access DS data segment register, SS stack segment register)

Source: Internet
Author: User

Storage of words in memory

The main meaning of this passage is: a word =2b=16bit,the CPU is a two memory units stored in a word (if the 0 address to store the font data, is to get its high-byte 0+1 bit and low byte 0 bits data, the data is read by the high address bit to the low address bit)

Questions:

(1) What is the byte-type data stored in the 0 address unit? # 20H
(2) What is the font data stored in the 0 address word cell? # 4e20h
(3) What is the byte-type data stored in the 2 address word cell? # 12H
(4) What is the font data stored in the 2 address unit? # 0012H
(5) What is the font data stored in the 1 address word cell? # 12aEH

Conclusion: As I said above, the font data is the data of it and its next address unit (the data is read from the high address bit to the low address bit)

Data Segment Register DS and offset [address]

Usage is similar to CS and IP, and is the value of the segment register Value *16+ offset

To the DS data segment register Value

Because the CPU segment registers are shy, they cannot be assigned directly (the CS Code register is in jmp Cs:ip), so the segment registers are assigned in the following way

MOV ax,1234h    # assigns AX register to 1234Hmov ds,ax    # Indirect assignment via AX register
Transmission of Word
mov ax,[1]    # [] is offset meaning to assign 12341 memory location Glyph data to AX Register mov al,[1]    # assigns byte-shaped data from 12341 memory locations to Al (Low) Register mov  [1],ax # to assign    AX register glyph data to a value of 12341 memory location mov [1],al    # assigns the byte-shape data of the Al register to the 12341 memory location
Question 1:

In memory, for example, write out the following instruction after the execution of the value in the Register AX,BX,CX?

parsing:

Question 2:

In memory, for example, write out the following instruction after the execution of the value in the Register AX,BX,CX?

parsing:

NB's move instructions
MOV General register, data # MOV Ax,1234hmov General Register, Register # mov Bx,ax/mov bx,ds (the value of the segment register is assigned to the General Register) MOV segment register, register # mov Ds,ax (because you cannot assign a value to a segment register directly, so Register as intermediary) MOV memory unit, registers # MOV [0],ax (To assign values in the AX register to ds*16+0 this internal memory element) MOV memory Unit, register # MOV ax,[0] (the value assigned to the AX register in the unit ds*16+0)
sub,add Directive

Data segment

What we're doing here is actually a data segment, specifically how to manipulate the data segment

Operation of the accumulated 123b0h~123bah memory unit

Summary:

(1) When the word is stored in memory, to be stored with two contiguous memory units , the lower byte of the word is stored in the low address unit, the high byte is stored in the higher address unit.
(2) with the MOV instruction to access the memory unit, you can only give the unit offset address in the MOV instruction, at this time, the segment address by default in the DS register.
(3)[address] represents a memory unit that is offset to address.
(4) When transferring font data between memory and registers, the high address unit corresponds to a high 8-bit register, a low address cell, and a low 8-bit register.
(5) MOV, add, sub is an instruction with two Operation objects. JMP is an instruction that has an action object.

(2) In memory, case 3.6 shows

Initial value of each register: cs=2000h,ip=0,ds=1000h,ax=0,bx=0;

① writes out the sequence of instructions executed by the CPU (written out with assembly instructions).

② writes the values of CS, IP, and related registers after each instruction is executed by the CPU.

③ again: Is there a difference between the data and the program? How can I determine what data is in memory and what is a program?

Answer: I thought that the value of CP will change after jmp, in fact it is the inside of JMP Cp:ip

Instruction sequence

Cs

Ip

Ds

Ax

Bx

Initial value

2000h

0

0

0

0

1

MOV ax,6622h

2000h

3h

0

6622h

0

2

JMP 0ff0:0100

ff0h

100h

0

6622h

0

3

MOV ax,2000h

ff0h

103h

0

2000h

0

4

MOV Ds,ax

ff0h

105h

2000h

2000h

0

5

MOV Ax,[8]

ff0h

108h

2000h

c389h

0

6

MOV ax,[2]

ff0h

10bh

2000h

ea66h

0

Assembly language--register (Memory access DS data segment register, SS stack segment register)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.