感悟网 导航

用子程序结构编写如下程序:从键盘输入一个二位十进制的月份数(01~12),然后显示出相应的英文缩写名。 汇编程序:从键盘输入两个十进制数然后把这两个数相加,并将结果...

作者&投稿:雷鸦 (若有异议请与网页底部的电邮联系)
从键盘输入一个二位十进制的月份数(01-12),然后显示出相应英文缩写名。用汇编语言实现,最好有流程图~

自己做了一个C程序,从C转汇编,希望对你有用:
#include
#include

void main()
{
char mon[12][4];

sprintf(mon[0],"%s", "Jan\0");
sprintf(mon[1],"%s", "Feb\0");
sprintf(mon[2],"%s", "Mar\0");
sprintf(mon[3],"%s", "Apr\0");
sprintf(mon[4],"%s", "May\0");
sprintf(mon[5],"%s", "Jun\0");
sprintf(mon[6],"%s", "Jul\0");
sprintf(mon[7],"%s", "Aug\0");
sprintf(mon[8],"%s", "Sep\0");
sprintf(mon[9],"%s", "Oct\0");
sprintf(mon[10],"%s", "Nov\0");
sprintf(mon[11],"%s", "Dec\0");

int a = getchar()-48;
int b = getchar()-48;
a = a*10 + b;
if(a<=12)
{
printf(mon[a-1]);
}
}

汇编:
push ebp
mov ebp,esp
sub esp,114h
push ebx
push esi
push edi
lea edi,[ebp-114h]
mov ecx,45h
mov eax,0CCCCCCCCh
rep stos dword ptr es:[edi]
mov eax,dword ptr [___security_cookie (417000h)]
xor eax,ebp
mov dword ptr [ebp-4],eax

mov esi,esp
push offset string "Jan\0" (415A20h)
push offset string "%s" (415820h)
lea eax,[ebp-38h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Feb\0" (415810h)
push offset string "%s" (415820h)
lea eax,[ebp-34h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Mar\0" (415A18h)
push offset string "%s" (415820h)
lea eax,[ebp-30h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "May" (415808h)
push offset string "%s" (415820h)
lea eax,[ebp-2Ch]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "May\0" (415A10h)
push offset string "%s" (415820h)
lea eax,[ebp-28h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Jul" (4157B0h)
push offset string "%s" (415820h)
lea eax,[ebp-24h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Jul\0" (415A08h)
push offset string "%s" (415820h)
lea eax,[ebp-20h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Aug\0" (4157A8h)
push offset string "%s" (415820h)
lea eax,[ebp-1Ch]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Sep\0" (415A00h)
push offset string "%s" (415820h)
lea eax,[ebp-18h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Nov" (4157A0h)
push offset string "%s" (415820h)
lea eax,[ebp-14h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Nov\0" (4158B4h)
push offset string "%s" (415820h)
lea eax,[ebp-10h]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
push offset string "Dec\0" (415874h)
push offset string "%s" (415820h)
lea eax,[ebp-0Ch]
push eax
call dword ptr [__imp__sprintf (4182C8h)]
add esp,0Ch
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

mov esi,esp
call dword ptr [__imp__getchar (4182BCh)]
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)
sub eax,30h
mov dword ptr [ebp-44h],eax

mov esi,esp
call dword ptr [__imp__getchar (4182BCh)]
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)
sub eax,30h
mov dword ptr [ebp-50h],eax

mov eax,dword ptr [ebp-44h]
imul eax,eax,0Ah
add eax,dword ptr [ebp-50h]
mov dword ptr [ebp-44h],eax

cmp dword ptr [ebp-44h],0Ch
jg main+1FEh (4137BEh)


mov eax,dword ptr [ebp-44h]
lea ecx,[ebp+eax*4-3Ch]
mov esi,esp
push ecx
call dword ptr [__imp__printf (4182C4h)]
add esp,4
cmp esi,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)

xor eax,eax
push edx
mov ecx,ebp
push eax
lea edx,[ (4137F0h)]
call @ILT+130(@_RTC_CheckStackVars@8) (411087h)
pop eax
pop edx
pop edi
pop esi
pop ebx
mov ecx,dword ptr [ebp-4]
xor ecx,ebp
call @ILT+25(@__security_check_cookie@4) (41101Eh)
add esp,114h
cmp ebp,esp
call @ILT+310(__RTC_CheckEsp) (41113Bh)
mov esp,ebp
pop ebp
ret
nop

data segment
num1 db 0;3 dup(?)
num2 db 0;3 dup(?)
data ends
code segment 'code'
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov si,offset num1
输入一组数
mov ah,01h
int 21h
sub al,'0';;
mov dl,al
mov cl,3
shl al,cl
shl dl,1
add al,dl
mov [si],al
mov ah,01h
int 21h
sub al,'0'
add [si],al
mov ah,01h
int 21h
mov bx,offset num2
再输入一组数
mov ah,01h
int 21h
sub al,'0'
mov dl,al
mov cl,3
shl al,cl
shl dl,1
add al,dl
mov [bx],al
mov ah,01h
int 21h
sub al,'0'
add [bx],al
mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h
把两组数求和
mov al,[bx]
add al,[si];al=sum
xor ah,ah
mov cl,100
div cl
mov bx,ax
test al,al
jz @f
add al,'0'
mov dl,al
mov ah,02h
int 21h
@@:
mov al,bh
xor ah,ah
mov cl,10
div cl
mov bx,ax
add al,'0'
mov dl,al
mov ah,02h
int 21h
add bh,'0'
mov dl,bh
mov ah,02h
int 21h
mov ah,4ch
int 21h
code ends
end start
input example:
12 34
or
02 08

扩展资料:十进制转二进制代码:
void dectobin( int n ){
int result=0,k=1,i,temp;
temp = n;
while(temp){
i = temp%2;
result = k * i + result;
k = k*10;
temp = temp/2;
}
printf("%d
", result);
}
算法分析:
在实现模2取余后需要逆序输出,这个地方通过不断乘以10来实现后一位比前一位的位数多10,不需要再通过数组或者逆序函数来实现。

Public Class Form1
Dim mon() As String =
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error GoTo Handerr
TextBox2.Text = mon(Val(TextBox1.Text))
Exit Sub
Handerr:
MsgBox(mon(0))
End Sub
End Class
..........................黑龙江省巴彦县兴隆镇 张志晨 ..........................................

使用switch语句应该比较简单

《...通过键盘输入完成对角线的元素赋值为1通过子程序》
答:我编写的matlab代码如下:x=input('please input n :');M=diag(0*[1:x]+1,0)保存后,运行即可,很好用的。请问你会用Matlab吗?

《单片微型计算机原理与接口技术》
答:本书是以51单片机为样机的单片微型计算机原理与接口技术教程,是单片机C51程序设计的基础篇。 全书由原理及接口两部分组成,共10章。介绍51单片微型计算机硬件结构、汇编语言程序设计方法、输入/输出接口应用、可编程定时/计数器设计、串行接H应用、单片机系统扩展、可编程接口芯片、单片机人机接口技术和模数技术,以达到学习...

《什么是子程序,如何使用子程序呢???》
答:子程序(subroutine)是一个概括性的术语,任何高级程序所调用的程序,都被称为子程序。它经常被使用在汇编语言层级上。子程序的主体(body)是一个代码区块,当它被调用时就会进入运行。一般程序设计语言包含两种基本的抽象:过程抽象和数据抽象。过程抽象有时也称控制抽象。子程序是最主要过程抽象机制。面...

《使用循环给数组赋30个数值,赋值的规律是从第三个值开始,数组元素等于...》
答:C语言提供了一些处理字符串的标准函数,用以完成一些常见的操作。对以下几个函数要掌握其功能和调用形式。(1)gets(字符数组名)此函数功能是从键盘输入一串字符,回车后送到字符数组中,注意定义数组时数组长度要足够大。(2)puts(字符数组名)此函数功能是将字符数组的内容输出到屏幕上。(3)strcat(字符数组名1,字符...

《什么叫结构化程序设计》
答:问题一:什么叫结构化程序设计?它的主要内容是什么? 结构化程序设计的思路是:自顶向下、逐步求精;其程序结构是按功能划分为若干个基本模块;各模块之间的关系尽可能简单,在功能上相对独立;每一模块内部均是由顺序、选择和循环三种基本结构组成;其模块化实现的具体方法是使用子程序。结构化程序设计由于采用了模块分解与...

《数控编程中什么叫子程序》
答:在计算机科学中,子程序(英语:Subroutine, procedure, function, routine, method, subprogram, callable unit),是一个大型程序中的某部份代码,由一个或多个语句块组成。它负责完成某项特定任务,而且相较于其他代码,具备相对的独立性。一般会有输入参数并有返回值,提供对过程的封装和细节的隐藏。这...

《子程序子程序的应用》
答:在加工过程中,如果存在重复的走刀轨迹,特别是在特定区域或各层面频繁出现,采用子程序编写程序更为便捷。通常,通过使用增量值来确定刀具的切入深度,使得子程序能够准确地处理这些重复路径,减少代码冗余。对于复杂的零件加工,往往包含多个独立的工序,这些工序之间可能需要进行适当的调整。为了优化程序结构和...

《子程序的解释子程序的解释是什么》
答:结构是:子(独体结构)程(左右结构)序(半包围结构)。子程序的具体解释是什么呢,我们通过以下几个方面为您介绍:关于子程序的成语鹭序_行杂乱无序关于子...4、应用有限元法,编制子程序,研究了重力坝应力和应变分布规律。5、针对梯形螺纹加工较繁琐的特点,利用参数编程,将梯形螺纹的加工程序编写成相应的子程序。点...

《C 语言程序设计》
答:既然如此庞大复杂的0S都可以用c语言编写,从狭义而言,还有什么系统软件和应用软件不能用c语言编写呢?由此可以肯定的说,c语言是一门十分优秀而又重要的语言。c语言程序设计是过程性程序设计语言,它的发展贯穿了计算机发展的历程,它蕴含了程序设计的基本思想,囊括了程序设计的基本概念,所以它是理工科高等院校的一门基础...

《编写程序》
答:它是计算机的设计者通过计算机的硬件结构赋予计算机的操作功能。机器语言具有灵活、直接执行和速度快等特点。 用机器语言编写程序,编程人员要首先熟记所用计算机的全部指令代码和代码的涵义。手编程序时,程序员得自己处理每条指令和每一数据的存储分配和输入输出,还得记住编程过程中每步所使用的工作单元处在何种状态。这...

   

返回顶部
本页内容来自于网友发表,若有相关事宜请照下面的电邮联系
感悟网