Assembly Language: Chapter III register (Memory access)

Source: Internet
Author: User

3.1 Storage of in-memory words

The registers in the CPU are 16 bits, which can be used to store a word in high and low bytes, but each memory unit is 8 bits and only one byte is stored.

So memory uses 2 contiguous memory units to store a word's high and low bytes

For example: 20000 value (4e20h) in address 0 of the memory unit value is 20H, the memory cell value in Address 1 is 4EH

Two memory units storing a font data is called a word unit ,

The starting address of the word cell is n, which is called the N address word unit , which represents the low byte of a word in the memory unit of address N, high byte memory unit in address n+1

  Any contiguous 2 memory units can be composed of one word unit

3.2 ds and "Address"

The CS register is used to store the segment address of the memory unit where the next instruction is located. Assigning CS in jmp 1000:0

The DS register is typically used to store the segment address of the memory unit to be accessed:

If we want to put the contents of the Memory unit 10000H (1000:0) into Al:

MOV bx,1000h will be accessed by the memory unit segment address in BX

MOV DS,BX the BX into the DS segment register

MOV al,[0] Place the contents of the memory unit represented by [0] in AL

[0]: Represents a memory unit, the segment address is a value in the DS, the offset address is 0, so at this time "0" represents the contents of the 1000:0 memory unit

Note: MOV ds,1000h is not possible, the segment register is not directly assignable, can only be escaped from other registers to the segment register

Instead: Writes Al to 10000H

MOV bx,1000h

MOV ds,bx

mov [0],al

3.3-word transfer

MOV instruction two bits of the same number of parameters,

When MOV interacts with the memory in the register, the number of bytes in the register determines whether a single memory unit or a word unit is transferred.

MOV ax,[0] combines the word cell data of that address into a 16-bit incoming AX register, which transmits a word

Problem:

  

MOV ax,1000h ax=1000h

MOV Ds,ax ds=1000h

MOV ax,[0] ax=1123h

MOV bx,[2] bx=6622h

MOV cx,[1] cx=2211h

Add bx,[1] bx=8833h

Add cx,[2] cx=8833h

3.4 MOV,ADD,SUV directive

MOV register, data data can only be transferred to register, cannot be transferred to segment register

Register, Segment register, memory unit in the MOV command position can be changed freely

MOV registers, data

MOV registers, registers

MOV register, Memory unit

MOV memory Unit, register

MOV memory unit, Segment register

MOV segment register, memory unit

MOV segment register, register

MOV register, Segment register

  

Add,sub can only operate on data, registers, memory units, and cannot be used for segment registers

3.5 Data segment: A contiguous memory unit that holds data forms a data segment

Optionally manipulate data in the data segment as needed

such as 123b0h-123b9h is a data segment with a length of 10.

1. Accumulate the first 3 memory units

MOV BX,123BH

MOV ds,bx

Add al,[0]

Add al,[1]

Add al,[2]

2. Accumulate the first 3 font data

Add ax,[0]

Add ax,[2]

Add ax,[4]

Detection Point 3.1

1) in debug with ' d 0:0 1f ' to see the memory, the results are as follows

0000:0000 F0 (EF) e2-00 80 80 12 66 20 22 60

0000:0010 E6 D6 CC 2E 3C 3b-ab BA 00 00 26 06 66 88

The following program executes before Ax=0,bx=0 writes out the following command after executing the values in the relevant register

MOX ax,1 Ax=1

MOV Ds,ax Ds=1

mov ax,[0000] ax=(16+0=10h) = 2662H

mov bx,[0001] bx=(16+1=11h) =e626h

mov ax,bx ax=e626h

mov ax,[0000] ax=2662H

mov bx,[0002] bx=(16+2=12h) =d6e6h

Add ax,bx ax=fd48h

Add ax,[0004] ax=2c14h 12c14

mov ax,0 ax=0

mov al,[0002] ax=00e6h

mov bx,0 bx=0

mov bl,[000c] bx=0026H

Add AL,BL ax=000CH

Assembly Language: Chapter III register (Memory access)

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.