當前位置:首頁 » 編程語言 » c語言轉匯編

c語言轉匯編

發布時間: 2022-04-23 20:38:22

『壹』 c語言轉換成匯編語言

如下即可:

ORG 0000H
LJMP START
ORG 0003H
LJMP X0_INT
ORG 0013H
LJMP X1_INT
ORG 0030H
START:
SETB IT0
SETB IT1
SETB EX0
SETB EX1
SETB EA
;----------------------
MOV A, #0FEH
LOOP:
MOV P1, A
CALL DELAY
RL A
SJMP LOOP
;----------------------
X0_INT:
PUSH ACC
PUSH PSW
SETB RS0
MOV A, #0F0H
MOV R2, #6
X0_1:
MOV P1, A
CALL DELAY
CPL A
DJNZ R2, X0_1
POP PSW
POP ACC
RETI
;----------------------
X1_INT:
PUSH ACC
PUSH PSW
SETB RS1
MOV A, #0AAH
MOV R2, #6
X1_1:
MOV P1, A
CALL DELAY
CPL A
DJNZ R2, X1_1
POP PSW
POP ACC
RETI
;----------------------
DELAY:
MOV R5, #3
DJNZ R7, $
DJNZ R6, $ - 2
DJNZ R5, $ - 4
RET
;----------------------
END

『貳』 C語言怎樣轉換成匯編語言

keilc裡面,如果單片機c語言編譯完成後,可以進入debug模擬模式,那麼打開disassembly
windows窗口,就可以看到c及對應的匯編。

『叄』 如何將C語言代碼轉換為對應的匯編代碼

VC6.0下有兩種方法:
(1)增加參數/FA:Project->Setting...,C/C++選項卡中的Project Options中增加參數/FA,編譯後debug目錄中將會增加對應源文件的匯編文件(*.asm)。
(2)如果想查看C語句對應的匯編代碼的話,可以這樣:F11單步調試,在debug工具欄中選擇「disassembly」即可。每行C代碼下面就是對應的匯編代碼。
如果debug工具欄不見了,可在VC上方空白菜單處右鍵,選擇「debug」即可彈出debug工具欄。

例如:
C代碼程序:
int main()
{
int a = 3;
int b = 4;
int c = a + b;
printf("c=%d/n", c);

return 0;
}

對應的匯編代碼程序(部分)如下:
5: int a = 3;
00401028 mov dword ptr [ebp-4],3
6: int b = 4;
0040102F mov dword ptr [ebp-8],4
7: int c = a + b;
00401036 mov eax,dword ptr [ebp-4]
00401039 add eax,dword ptr [ebp-8]
0040103C mov dword ptr [ebp-0Ch],eax

gcc下編譯加參數-S,如gcc a.c -S,編譯後會自動生成匯編文件a.asm。

『肆』 C語言轉匯編問題

當然可以
不過c語言生成的程序,局部變數段地址在ss裡面,全局變數段地址在ds裡面。
讀寫數據需要確定數據的段地址和偏移地址。

對於段地址。 若int a=500是局部變數,那麼寫入的時候需要保存段寄存器裡面的值是ss。是全部變數則保證段寄存器裡面的值是ds。
對於偏移地址,c語言可以用&a這樣的方式獲得。

全局變數的寫法大致是如下代碼
mov bx, &a
mov wrod ptr ds:[bx], 500

『伍』 實踐,C語言是怎麼變成匯編的

c語言未必會經歷匯編語言這一環節,准確的說,c語言經歷編譯器(必須),鏈接器(某種程度上非必須)的處理,成為可執行代碼(一般是二進制代碼)。
而匯編也許是目前多數編譯器提供的中間環節(vc,vs都提供在調試運行下使用反匯編的功能),因為對於匯編語言來說,進一步編譯成機器語言的難度很低,只需查找有限的匯編指令對應的編碼,如MOV,ADD等,具體編碼與機器有關。
而你說的c語言變成匯編這一過程,正是編譯器的核心工作,也是最為困難的。需要對你的程序(本質上是一個超長的字元串)做分割,詞法分析,語法分析,最後翻譯成匯編。

『陸』 怎麼把c語言轉換成匯編語言

理論上來說C語言改成匯編是完全可以的,當然實際上還是有一定難度。

1、完全手工根據C語言的流程和目的,改編成匯編語言,這樣做工作量很大

2、利用模擬軟體,在模擬環境下,是有相應的匯編代碼的,這樣做工作量相對較小,但可讀性較差。

『柒』 怎麼把C語言轉換成匯編

	.file	"Untitled1.c"
.text
.globl _factor
.def _factor; .scl 2; .type 32; .endef
_factor:
pushl %ebp
movl %esp,%ebp
pushl %edi
pushl %esi
pushl %ebx
subl $28,%esp
cmpl $1,8(%ebp)
jne L2
movl $1,%eax
movl $0,%edx
jmp L3
L2:
movl 8(%ebp),%eax
subl $1,%eax
movl %eax,(%esp)
call _factor
movl 8(%ebp),%ecx
movl %ecx,%ebx
sarl $31,%ebx
movl %edx,%edi
imull %ecx,%edi
movl %ebx,%esi
imull %eax,%esi
addl %edi,%esi
mull %ecx
leal (%esi,%edx),%ecx
movl %ecx,%edx
L3:
addl $28,%esp
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
.globl _get_numerator
.def _get_numerator; .scl 2; .type 32; .endef
_get_numerator:
pushl %ebp
movl %esp,%ebp
subl $40,%esp
movl 8(%ebp),%eax
movl %eax,-16(%ebp)
movl 12(%ebp),%eax
movl %eax,-12(%ebp)
fildl 16(%ebp)
fstpl 8(%esp)
fldl -16(%ebp)
fstpl (%esp)
call _pow
leave
ret
.globl _get_denominator
.def _get_denominator; .scl 2; .type 32; .endef
_get_denominator:
pushl %ebp
movl %esp,%ebp
subl $24,%esp
movl 8(%ebp),%eax
movl %eax,(%esp)
call _factor
movl %eax,-16(%ebp)
movl %edx,-12(%ebp)
fildq -16(%ebp)
leave
ret
.globl _get_symbol
.def _get_symbol; .scl 2; .type 32; .endef
_get_symbol:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
andl $1,%eax
testl %eax,%eax
jne L9
movl $1,%eax
jmp L10
L9:
movl $-1,%eax
L10:
popl %ebp
ret
.def ___main; .scl 2; .type 32; .endef
.section.rdata,"dr"
LC2:
.ascii"pleaseinputthex:"
LC3:
.ascii"%lf"
LC6:
.ascii"sin(%lf)=%lf12"
.text
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
pushl %ebp
movl %esp,%ebp
andl $-16,%esp
subl $96,%esp
call ___main
fldz
fstpl 80(%esp)
fldz
fstpl 72(%esp)
movl $LC2,(%esp)
call _puts
leal 56(%esp),%eax
movl %eax,4(%esp)
movl $LC3,(%esp)
call _scanf
fldl 56(%esp)
fldl LC4
fmulp %st,%st(1)
fldl LC5
fdivrp %st,%st(1)
fstpl 64(%esp)
movl $0,92(%esp)
jmp L12
L13:
fldl 80(%esp)
fstpl 72(%esp)
movl 92(%esp),%eax
addl %eax,%eax
addl $1,%eax
movl %eax,8(%esp)
fldl 64(%esp)
fstpl (%esp)
call _get_numerator
fstpl 32(%esp)
movl 92(%esp),%eax
addl %eax,%eax
addl $1,%eax
movl %eax,(%esp)
call _get_denominator
fdivrl 32(%esp)
fstpl 32(%esp)
movl 92(%esp),%eax
movl %eax,(%esp)
call _get_symbol
movl %eax,44(%esp)
fildl 44(%esp)
fmull 32(%esp)
fldl 80(%esp)
faddp %st,%st(1)
fstpl 80(%esp)
addl $1,92(%esp)
L12:
cmpl $3,92(%esp)
jle L13
fldl 56(%esp)
fldl 80(%esp)
fstpl 12(%esp)
fstpl 4(%esp)
movl $LC6,(%esp)
call _printf
movl $0,%eax
leave
ret
.section.rdata,"dr"
.align8
LC4:
.long -266631570
.long 1075388921
.align8
LC5:
.long 0
.long 1081507840
.ident "GCC:(tdm-2)4.8.1"
.def _pow; .scl 2; .type 32; .endef
.def _puts; .scl 2; .type 32; .endef
.def _scanf; .scl 2; .type 32; .endef
.def _printf; .scl 2; .type 32; .endef

『捌』 C語言轉換成匯編語言

win-tc
可以將C代碼編譯為匯編代碼。
在「運行」,「編譯配置」里選取中編譯目標為匯編文件。
另外,將其它語言編譯為匯編代碼不叫「
反匯編
」。

『玖』 C語言怎麼轉換匯編程

在單片機中,C語言轉換成匯編語言有一個小竅門,這要藉助於KEILC這個編譯軟體,步驟如下:

1、運行KEIL,建立工程,導入C語言。

熱點內容
羅技g502高級腳本 發布:2025-05-17 17:30:45 瀏覽:217
python解析post請求 發布:2025-05-17 17:27:19 瀏覽:696
社保測算密碼是什麼 發布:2025-05-17 17:25:09 瀏覽:157
phpini修改路徑 發布:2025-05-17 17:19:06 瀏覽:280
mac搭建php開發環境 發布:2025-05-17 17:18:22 瀏覽:782
佟大為關悅上超級訪問 發布:2025-05-17 17:09:50 瀏覽:310
閃迪存儲卡高速 發布:2025-05-17 17:09:14 瀏覽:470
ios文件加密插件 發布:2025-05-17 17:05:48 瀏覽:797
androidbutton自定義 發布:2025-05-17 16:58:34 瀏覽:169
android應用生命周期 發布:2025-05-17 16:53:16 瀏覽:779