如何添加一个循环来打印For his a jolly good fellow 3x?以下是标题要求:您必须只调用printf()函数一次,以输出"For he's a jolly good fellow!"字符串,并且必须使用带有跳转指令的循环来输出字符串三次
global _main
extern _printf
extern _ExitProcess@4
section .bss
name: resb 100
position1: resz 1
position2: resz 1
position3: resz 1
section .data
jolly: db "For he's is a jolly good fellow!", 0ah, 0
deny: db 'Which nobody can deny!', 0ah, 0
section .text
_main:
push jolly ; push the jolly string and call printf
call _printf
add esp, 4 ; restore the stack pointer
push deny ; push the deny string and call printf
call _printf
add esp, 4 ; restore the stack pointer
xor ecx,ecx ; set the exit code to 0
call _ExitProcess@4
```
找到一个有效的Hello,world示例,并学习如何从中制作一个可执行程序。
然后随意修改它以打印其他问候语。
代替NASM或MASM,你可能也喜欢€ASM,它使创建Windows程序变得容易:euroasm Jolly.asm
将产生最终的可执行文件Jolly.exe
。
EuroAssembler源代码Jolly.asm
看起来像这样:
Jolly PROGRAM Format=PE,Width=32,Entry=_main
INCLUDE winapi.htm ; Fetch macros StdOutput and TerminateProgram.
[.data]
jolly: db "For he's is a jolly good fellow!", 0ah, 0
deny: db 'Which nobody can deny!', 0ah, 0
[.text]
_main: MOV EBX,3 ; How many times the loop repeats.
print: StdOutput jolly ; Write ASCIIZ string using a macro 'StdOutput'.
DEC EBX ; Consult the loop counter.
JNZ print ; Loop to print again while EBX>0.
StdOutput deny ; Write the other ASCIIZ string.
TerminateProgram ; Invoke ExitProcess using a macro.
ENDPROGRAM
你问了同样的问题,你如何使一个循环在x86汇编语言重复一行文本3次?四天前,请不要重复同样的问题。