汇编实验二

实验1

  1. 写一个完整的8086汇编语言程序,满足一下要求:
  1. 数据段申请一个存储数据的字长数据(一个长度为word的变量),该数据存储的值20。
  2. 数据段申请一个存储数据的字长数据(一个长度为word的变量),该数据的值从键盘输入。
  3. 将上述两个值自加1后显示在屏幕上。

(代码清单,注意添加注释,养成良好习惯)

;Program:
;Author:
;Date:

.386
.MODEL FLAT

ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

INCLUDE io.h            ; header file for input/output

cr      EQU     0dh     ; carriage return character
Lf      EQU     0ah     ; line feed

.STACK  4096            ; reserve 4096-byte stack

.DATA                   ; reserve storage for data

number1 DWORD 20
number2 DWORD ?
prompt1 byte "Please enter a ASCII of a data:",0
prompt2 byte cr,lf,"The value of number1:",0
prompt3 byte cr,lf,"The value of number2:",0
string byte 20 dup (?)
str1 byte 20 dup (?)
str2 byte 20 dup (?)

.CODE

                        ; start of main program code
_start:
        output prompt1
    input string,20
    atod string
    mov number2,eax

    mov ebx,number1
    inc ebx
    dtoa str1,ebx

    mov ecx,number2
    inc ecx
    dtoa str2,ecx

    output prompt2
    output str1
    output prompt3
    output str2


        INVOKE  ExitProcess, 0  ; exit with return code 0
PUBLIC _start                   ; make entry point public

END                             ; end of source code

实验2

  1. 写一个完整的8086汇编语言程序,求解表达式-3x-y+1的值,结果显示在屏幕上。

    ;Program:
    ;Author:
    ;Date:

    .386
    .MODEL FLAT

    ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

    INCLUDE io.h

    cr          EQU    0dh   ; carriage return character
    LF          EQU    0ah   ; linefeed character

    .STACK  4096             ; reserve 4096-byte stack

    .DATA  ; reserve storage for data
    Prompt1        BYTE     "                 -3x-y+1                ",cr,Lf,Lf
                BYTE       "Enter  x:  ",0
    Prompt2        BYTE     "Enter  y:  ",0
    Value        BYTE     20 DUP (?)
    Prompt3        BYTE       cr,Lf,"The result is "
    Result      BYTE       6 DUP (?)
                BYTE       cr,Lf,0

    .CODE      ; start of main program code
    _start:
                output    Prompt1
                input    Value,16
                atoi    Value
                mov        dx,ax        ;x
                imul    dx,3        ;3x

                output  Prompt2
                input    Value,16
                atoi    Value
                add        dx,ax        ;3x+y
                neg        dx            ;-(3x+y)
                add        dx,1        ;-3x-y+1

                itoa    result,dx
                output  Prompt3

                INVOKE ExitProcess, 0   ; exit with return code 0

    PUBLIC _start                       ; make entry point public
    END                                 ; end of source code

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值