用子程序结构编写如下程序:从键盘输入一个二位十进制的月份数(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,不需要再通过数组或者逆序函数来实现。
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语句应该比较简单