assm study

2 Computer Organization

2.1 Memory

The basic unit of memory is byte.
8086
four 16bit general purpose registers:AX BX CX DX,can be decomposed into two 8bit registers
two 16bit index registers:SI DI ,can not be decomposed into two 8bit registers
two 16bit stack registers:SP BP
four 16bit segment registers:CS DS SS ES
one instruction register:IP
one FLAGS register:FLAGS,stores the important information about the result of a prevous instruction

Netwide Assembler (NASM)

instruction operands:register,memory,immediate,implied

Basic instructions

mov It moves data from one location to another
mov dest,src
The data specified by src is copied to dest,both operands may not be memory operands

mov eax, 3 ; store 3 into EAX register(3 is a immediate operands)  
mov bx, ax ; stroe the value of AX into BX register  

The ADD

add eax, 4   ; eax = eax + 4 
add al, ah   ; al = al + ah  

The SUB

sub bx, 4    ; bx = bx - 4  
sub ebx, edi ; ebx = ebx - edi

The INC and DEC

inc   ecx    ; ecx++
dec   dl     ; dl--  

Directives

generally used to either instruct the assembler to do something or inform the assembler of something

  • define constants
  • define memory to store data into
  • group memory into segments
  • conditionally include source code
  • include other files
    NASM code has many of the same preprocessor as C,and the preprocessor directives start with a % instead of a # as in C

The equ direactive

symbol equ value 

define a constant used in assembly programe

The %define direactive

define constant macros just as C,like #define

%define SIZE 100
   mov eax, SIZE  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值