汇编hello world(不打不知道,一打吓一跳

The first program in IBM(hello world)

反思

  1. D S DS DS一定要弄好
  2. 字符串以美元符号结尾
S1      SEGMENT STACK
        DW      40H DUP(?)
TOP     LABEL WORD
S1      ENDS
S2      SEGMENT
        hello DB 'Hello World$'    ;rember to add '$'
        CRLF    DB 0DH,0AH,24H
S2      ENDS
S3      SEGMENT
        ASSUME   CS:S3, DS:S2, SS:S1
P4      PROC    FAR
        MOV AX, S1
        MOV SS, AX
        LEA SP, TOP
        MOV AX, S2
        MOV DS, AX
        LEA DX, CRLF
        MOV AH, 9H
        INT 21H
        LEA DX, hello
        MOV AH, 9H
        INT 21H
        MOV AH,4CH
        INT 21H
S3      ENDS
END     P4


The second program in IBM(对于一个数,之后以2进制输出)

S1 SEGMENT STACK
   DW 30H DUP(?)
TOP LABEL WORD
S1 ENDS
S2 SEGMENT
        V3 DW 27452
S2 ENDS
S5 SEGMENT
   ASSUME CS:S5, DS:S2, SS:S1
P6 PROC FAR
    MOV AX,S1
    MOV SS,AX
    MOV SP, OFFSET TOP
    MOV AX, S2
    MOV DS,AX
    MOV CX, 16
    MOV BX, V3
    XOR DX, DX
L7: ROL BX,1
    MOV DL,1
    AND DL,BL
    ADD DL,30H
    MOV AH, 2
    INT 21H
    LOOP L7
    MOV AH,4CH
    INT 21H
    P6 ENDP
    S5 ENDS
    END     P6



第3个程序(求平均数)

S1      SEGMENT STACK
        DW      40H DUP(?)
TOP     LABEL   WORD
S1      ENDS
S2      SEGMENT
LIST    DW      10,10000,7
        DW      21020,-30,3213
        DW      389,213,5435
AVER    DW      ?
S2      ENDS
S3      SEGMENT
        ASSUME  CS:S3, DS:S2, SS:S1
MAIN    PROC    FAR
        MOV     AX, S1
        MOV     SS, AX
        MOV     AX, S2
        MOV     DS, AX
        LEA     SI, LIST

        MOV     CX, [SI]
        ADD     SI, 2
        XOR     BX, BX
        MOV     BP, BX
L4:     MOV     AX, [SI]
        CWD     ;this is expand the digit of the half res digits
        ADD     BP, AX
        ADC     BX, DX
        ADD     SI, 2
        LOOP L4
        MOV     DX, BX
        MOV     AX, BP
        IDIV    [LIST]
        MOV     [AVER], AX ; the lowbit put consult
        MOV     DX, AX
        ; BINARY OUTPUT in decimal
        MOV     AH, 4CH
        INT     21H
S3      ENDS
        END     MAIN

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值