assembly notes

The data in the assembly source program cannot start with a letter, so generally add a 0 in front, eg: mov ax,0ffffh

;---------------------------------------------------------------------------------------------------------

Registers: (14) AX, BX, CX, DX, SP, BP, SI, DI, IP, FLAG, CS, DS, SS, ES

General purpose registers:

AX, BX, CX, DX are called data registers: (can be split)

AX (Accumulator): Accumulation register, also known as accumulator;

BX (Base): base address register;

CX (Count): counter register;

DX (Data): data register;

SP and BP are also known as pointer registers:

SP (Stack Pointer): stack pointer register;

BP (Base Pointer): base pointer register;

Note: bp: base address register (stack pointer), generally used in the function to save the top base address of the sp when entering the function

Its purpose is a bit special, it is used in conjunction with the stack pointer SP, as SP calibration,

Only useful when looking for data on the stack and using individual addressing modes

SP, BP are generally used in conjunction with segment register SS to determine the address of a unit in the stack register,

SP is used to indicate the offset address of the top of the stack, and BP can be used as a base address in the stack area to determine the operand address in the stack.

Each time the subfunction is called, the system saves these two pointers at the beginning and restores the values ​​of sp and bp at the end of the function. as follows

On function entry:

push bp // save the bp pointer

mov bp,sp // Pass the sp pointer to bp, and bp points to the base address of sp.

// At this time, if the function has parameters, [bp + 2*4] is the first parameter of the sub-function,

   [bp+3*4] is the second parameter of the sub-function, and so on, how many parameters are [bp+(n-1)*4].

.....

.....

At the end of the function:

mov sp,bp // return the original sp pointer to sp

pop bp // Restore the original bp value.

ret // exit the subfunction

SI and DI are also known as index registers:

SI (Source Index): source index register;

DI (Destination Index): destination index register;

Control register:

IP (Instruction Pointer): instruction pointer register;

FLAG: flag register;

Flag flag name and foreign language full name = 1 = 0

CF Carry Flag/Carry Flag CY/Carry/Carry         NC/No Carry/No Carry

PF parity flag/Parity Flag PE/Parity Even/even         PO/Parity Odd/odd

AF Auxiliary Carry Flag/Auxiliary Carry Flag         AC/Auxiliary Carry/Carry         NA/No Auxiliary Carry/No Carry

ZF Zero Flag/Zero Flag ZR/Zero/Equal to zeroNZ/Not Zero/Not equal to zero

SF sign flag/Sign Flag NG/Negative/negative PL/Positive/non-negative

TF trace flag/Trace Flag

IF Interrupt Flag/Interrupt Flag EI/Enable Interrupt/Enable                 DI/Disable Interrupt/Disable

DF Direction Flag/Direction Flag DN/Down/Decrease UP/Increase

OF overflow flag/Overflow Flag OV/Overflow/Overflow         NV/Not Overflow/Not overflow

15    14    13    12    11    10    09    08    07    06    05    04    03    02    01    00

                                OF    DF    IF    TF    SF    ZF             AF           PF            CF

pushf pushes FLAG onto the stack

popf puts the data on the stack into the FLAG

segment register:

CS (Code Segment): code segment register;

DS (Data Segment): data segment register;

SS (Stack Segment): stack segment register;

ES (Extra Segment): Additional segment register;

Addressing:

bx,bp,si,di can all appear alone

In [...] these 4 registers can appear singly or only in four combinations: bx and si, bx and di, bp and si, bp and di

bx is the data base address register. By default, the ds segment register is used. It can be used in conjunction with the ds or es segment register explicitly.

bp is the stack base register. By default, the ss segment register is used, and it can also be used in explicit combination with the ds and es segment registers.

si and di are the source and destination index registers respectively. By default, the ds and es segment registers are used respectively, and they can be explicitly used in conjunction with the ds and es segment registers.


;-----------------------------------------------------------------------------------------------------------

Safe space 0:0200-0:0300

;-----------------------------------------------------------------------------------------------------------

80X25 color character mode display buffer structure:

      In the memory address structure, B8000H~BFFFFH has a total space of 32KB, which is the display buffer of 80x25 color character mode.

     Write data to this address space and the write will appear on the display immediately.

      In 80x25 color mode, the display can display 25 lines of 80 characters, and each character can have 256 attributes.

      In 80x25 mode, the content of one screen has a total of 4000 characters in the display buffer. Each character occupies one word, the upper 8 bits are the ASCII code of the character, and the lower 8 bits are the attributes of the character

           Character attribute meaning: 

               7        6    5    4        3        2    1    0

               BL      R   G    B         I        R    G    B

             flicker background highlight foreground 

           RGB,R:red、G:green、B:blue

            The flickering effect can only be seen under full screen DOS


Unit 0040:17 stores the keyboard status byte, recording the status of the control and toggle keys:

0 right shift set to 1 means pressing the right shift key

1 left shift set to 1 means press the left shift key

2 Ctrl is set to 1 to indicate that the Ctrl key is pressed

3 Alt is set to 1 to indicate that the Alt key is pressed

4 ScrollLock set to 1 means press ScrollLock indicator light

5 NumLock is set to 1 to indicate that the number input on the keypad is a number

6 CapsLock is set to 1 to enter uppercase letters

7 Insert is set to 1 to indicate that it is in the deletion state


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325981908&siteId=291194637