在我们的帖子中经常还有一些代码段,如何在帖子里正确设置代码段?请看下面攻略。
如果要建内联代码,用反单引号 包起来。
要创建代码块,每行用4个空格的缩进,
或者在代码块的上面和下面加三个反单引号 。
范例:
.text .global connect connect: mov r3, #2 ; s->sin_family = AF_INET strh r3, [sp] ldr r3, =server_port ; s->sin_port = server_port ldr r3, [r3] strh r3, [sp, #2] ldr r3, =server_addr ; s->sin_addr = server_addr ldr r3, [r3] str r3, [sp, #4] mov r3, #0 ; bzero(&s->sin_zero) str r3, [sp, #8] str r3, [sp, #12] mov r1, sp ; const struct sockaddr *addr = sp ldr r7, =connect_call ldr r7, [r7] swi #0 add sp, sp, #16 pop {r0} ; pop sockfd pop {r7} pop {fp, ip, lr} mov sp, ip bx lr .data socket_call: .long 281 connect_call: .long 283 /* all addresses are network byte-order (big-endian) */ server_addr: .long 0x0100007f ; localhost server_port: .hword 0x0b1a AVR Assembler