當前位置:首頁 » 編程語言 » c語言和匯編例題
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言和匯編例題

發布時間: 2022-05-29 14:22:28

c語言基礎問題,匯編語言,請看下題應該選擇什麼

廠商值的是硬體和軟體的出品商,比如Windows是微軟的,還比如主板上的BIOS是指硬體上的。所以確實是提前編譯好的。這里你只需要去用就行
這個題目比較刁鑽。這個引號內的匯編很迷惑人。程序運行難道不是編譯嗎?這個時候如果我不看題的話。也會選D的

㈡ 單片機。分別使用c語言和匯編語言編寫一個程序

#include<reg52.h>

unsignedcharaa_at_0x30;

voidmain()
{
IE=0x81;
IT0=1;
aa=0;
while(1);
}

X0_INT()interrupt0
{
aa++;
aa%=100;
}

//====================

ORG0000H
LJMPSTART
INC30H
MOVA,#100
CJNEA,30H,EXIT
MOV30H,#0
EXIT:
RETI

START:
MOVIE,#81H
SETBIT0
MOV30H,#0
SJMP$
END


上面兩個程序,均經過試驗,可以滿足題目要求。

㈢ [懸賞]求解C語言匯編題目

1、程序流程圖分析與改寫

因為參考程序流程圖中存在兩個if分支交叉的情況,這種程序流程無法直接用循環結構實現,所以需要對程序流程圖進行改寫。

在改寫之前需要對整個流程圖進行分析。

moose@debian:~/p_project/2015xxxx_網路知道/c_cam$./a.out
r0=45.000000,phi=0.000000,s=0.000000,ds=0.375000,a=0.151973,amax=0.151973,x=45.705578,y=-8.000000,X=36.347839,Y=-9.637916,xc=0.000000,yc=0.000000
r0=45.000000,phi=1.000000,s=0.000171,ds=0.000514,a=0.151973,amax=0.151973,x=17.963154,y=34.137642,X=14.285400,Y=25.378410,xc=0.000000,yc=0.000000
...
r0=45.000000,phi=119.000000,s=0.020388,ds=-44.188843,a=0.849510,amax=0.849510,x=45.426483,y=-24.410582,X=36.129913,Y=-22.455133,xc=0.000000,yc=0.000000
r0=45.000000,phi=120.000000,s=0.020559,ds=-44.563328,a=0.849509,amax=0.849510,x=32.584461,y=20.035658,X=25.916046,Y=13.269401,xc=0.000000,yc=0.000000
r0=45.000000,phi=121.000000,s=45.000000,ds=0.000000,a=0.087970,amax=0.849510,x=-12.404583,y=90.987427,X=-11.110419,Y=81.575989,xc=0.000000,yc=0.000000
...
r0=45.000000,phi=180.000000,s=45.000000,ds=0.000000,a=0.087970,amax=0.849510,x=-47.874447,y=-67.881332,X=-42.879730,Y=-59.800316,xc=0.000000,yc=0.000000
r0=45.000000,phi=181.000000,s=44.999592,ds=30.035320,a=0.237949,amax=0.849510,x=39.310745,y=-87.747360,X=35.209457,Y=-79.178261,xc=0.000000,yc=0.000000
r0=45.000000,phi=182.000000,s=44.999187,ds=30.534101,a=0.237950,amax=0.849510,x=90.353180,y=-26.939114,X=80.926598,Y=-25.760328,xc=0.000000,yc=0.000000
...
r0=45.000000,phi=360.000000,s=0.000000,ds=0.000000,a=0.173278,amax=0.849510,x=-20.637590,y=46.097324,X=-16.412260,Y=37.588707,xc=0.000000,yc=0.000000

㈣ c語言基礎知識問題:1.每一條匯編語言都有一條機器指令與之對應。2.一條機器指令對應一條匯編語言語句

1是錯的。匯編語言的指令中,有一些屬於偽指令,比如段定義指令:
dseg segment
再比如
a db '1234'
b equ $-a ;計算a的位元組長度。這個也不屬於機器指令

㈤ c語言和匯編語言混合編程,鍵盤輸入4個十進制數,用匯編語言計算這四

codesegment
assumecs:code
org100h
start:
pushcs
popds
pushcs
popes
callinputnum
movcx,num
movax,0
leasi,array
@1:
addax,[si]
incsi
incsi
loop@1
movbx,num
divBL
xorah,ah
calldispnum
movah,4ch
int21h


;鍵盤輸入數值數組子程序(數組名為array,元素個數存放在num中)
inputnumprocnear
;輸入的數據以一個空格分隔,以回車符結束輸入
leadi,array;將數組第一個元素的有效地址置入DI
movwordptr[num],0
stin:
movax,0
pushax
again1:
movah,1
int21h
movbyteptr[char],al
cmpal,13
jeline0
cmpal,''
jeline0
subal,30h
movah,0
movsi,ax
popax
movcl,10
movch,0
mulcx
addax,si
pushax
jmpagain1
line0:
popax
movwordptr[di],ax
incwordptr[num]
cmpbyteptr[char],13
jestinend
incdi
incdi
jmpstin
stinend:
ret
arraydw100p(0)
numdw0
chardb?
inputnumendp

;顯示十進制整型數值子程序
dispnumprocnear
;將要顯示的數據放入AX中
movdx,0
movbx,10
divbx
movbyteptr[y+6],dl;保存個位
movdx,0
divbx
movbyteptr[y+5],dl;保存十位
movdx,0
divbx
movbyteptr[y+4],dl;保存百位
movdx,0
divbx
movbyteptr[y+3],dl;保存千位
movbyteptr[y+2],al;保存萬位

moval,byteptr[y+2]
addal,30h;萬位轉ASC2
movbyteptr[y+2],al

moval,byteptr[y+3]
addal,30h;千位轉ASC2
movbyteptr[y+3],al

moval,byteptr[y+4]
addal,30h;百位轉ASC2
movbyteptr[y+4],al

moval,byteptr[y+5]
addal,30h;十位轉ASC2
movbyteptr[y+5],al

moval,byteptr[y+6]
addal,30h;個位轉ASC2
movbyteptr[y+6],al

movdi,1
disp1:
incdi
cmpdi,6
jedispexit
cmpbyteptr[y+di],'0'
jnedispexit
movbyteptr[y+di],''
jmpdisp1
dispexit:
movah,9
leadx,y
int21h
ret
ydb10,13,0,0,0,0,0,'$'
dispnumendp

code ends
endstart

請在未來匯編環境中調試運行。

㈥ c語言編程題

#include <stdio.h>

#include <math.h>

int main()

{

double x,y;

scanf("%lf",&x);

if(x<=-2)

y=-pow(exp(1),2*x+1)+3;

else if(x<=3)

y=2*x-1;

else

y=2*log10(3*x+5)-11;

printf("%lf ",y);

return 0;

}

㈦ 初學編程,大家幫忙看下這道c語言題怎麼做萬分感謝

先給你第一題的,網路知道的這個編輯器真的不適合粘貼代碼

#include<stdio.h>

#include<string.h>

#define MAX_ARRAY_SIZE 1024

#define MAX_MAP_SIZE 10


/* 輸入數組,連續輸入,如:aedabcdaeas */

int inputArray(char *buff) {

int len = 0;

/* 使用fgets來防止緩沖區溢出 */

if (NULL == fgets(buff, MAX_ARRAY_SIZE, stdin)) {

return 0;

}

len = strlen(buff);

/* fgets 返回的數據可能是換行符結尾的,也可能不是,對換行符結尾的進行處理 */

if (buff[len - 1] == ' ') {

buff[len - 1] = '';

len -= 1;

}

return len;

}

int processArray(int len, char *chars, char *map) {

/* 保存反向映射便於查找 */

int tmap[128];

int maplen = 0;

int i = 0;

char *p = chars;

memset(tmap, -1, sizeof(int) * 128);

for (i = 0; i < len; i++) {


if (*p > 'z' || *p < 'a') {

return -*p;

}

if (tmap[*p] == -1) {

if (maplen >= MAX_MAP_SIZE) {

return -1;

}

tmap[*p] = maplen;

map[maplen] = *p;

maplen += 1;

}

*p = '0' + tmap[*p];

p++;

}

return maplen;

}

int main() {

/* 用於輸入的字元數組 */

char buff[MAX_ARRAY_SIZE];

/* 用於保存轉換規則的數組 */

char map[MAX_MAP_SIZE];

/* 保存字元數組長度 */

int len = 0;

int maplen = 0;

int i = 0;


len = inputArray(buff);


if (len <= 0) {

puts("Cancelled");

} else if (len < 10) {

puts("Not enough 10 chars");

} else {


maplen = processArray(len, buff, map);

if (maplen >= 0) {

puts("轉換結果:");

for (i = 0; i < len; i++) {

printf("%c ", buff[i]);

}

puts("");

puts("映射規則:");

for (i = 0; i < maplen; i++) {

printf("%c -> %d ", map[i], i);

}

puts("");

} else if (maplen == -1) {

puts("Different Chars count is OverLimit of 10");

} else if (maplen <= -2) {

printf("Unexpected char %c ", -maplen);

}

}

return 0;

}

執行結果:

㈧ C語言及匯編編程各一題

//段地址在DS中,自己設置。
MOV AX,[30H]
CMP AX,3CH
JA ABOVE
JE EQUAL
MOV [31H],0
JMP DONE

ABOVE: MOV[31H],BYTE PTR 2
JMP DONE

EQUAL: MOV[31H],BYTE PTR 1
DONE:

//第2題
#include<stdio.h>
void main()
{
int T0,T1;
cout<<"輸入華氏溫度:";
cin>>T0;
T1=5*(T0-12)/9;
cout<<"攝氏溫度:"<<T1<<endl;
}

㈨ C語言+匯編 難題 大牛請進

1、有效地址EA就是相對於一個基準地址的偏移,就是偏移地址。不過你的題目有問題,沒明白意思。
立即定址就是直接把立即數存到寄存器;
直接定址就是直接給出偏移地址,把偏移地址中存的數存進目的寄存器;
BX可以用於基址變址(就是在基地址上再加一點變化,產生相對偏移)
寄存器定址就是把直接定址中直接給出的地址先存入一個寄存器,再利用這個寄存器來給出。
2、確定91是10進制嗎?假設是16進制數:1001 0001
+1011 1010
------------
舍 1)0100 1011
則有溢出 OF=1
結果非0,全零標志ZF=0
有進位,進位借位標志CF=1
最高位是0,符號0,SF=0
低4位向高4位無進、借位,故
半進位、借位標志AF=0(亦稱為輔助進位標志)

如果題目中是10進制的數的話,該會自己推了吧!