小编use*_*074的帖子

在perl中的多个子例程调用中保留变量的值

只想知道在对同一子程序的多次调用中保留变量值的最佳方法是什么.即

$someList  = &someRoutine(100, 200);
$someList2 = &someRoutine(100, 200);

sub someRoutine {
    $someAddition = 0;
    foreach $someSum (@_){
        $someAddition += $someSum;
    }
    return $someAddition
}

print $someList;
print $someList2;
Run Code Online (Sandbox Code Playgroud)

基本上,someList应该打印300,someList2应该打印600.如何使someList2打印600?我希望在多个子程序调用中保留$ someAddition.

perl

2
推荐指数
2
解决办法
728
查看次数

X86 NASM程序集将低级字符串转换为大写字母和大写字母

因为我对汇编很新,所以如果用户在汇编中输入大写字母或反之亦然,我有一些关于如何从小写转换为大写的问题.这是我到目前为止:

section .data
Enter db "Enter: "
Enter_Len equ $-Enter

Output db "Output: "
Output_Len equ $-Output

Thanks db "Thanks!"
Thanks_Len equ $-Thanks

Loop_Iter dd 0 ; Loop counter

section .bss
In_Buffer resb 2
In_Buffer_Len equ $-In_Buffer

section .text
global _start

_start:
    ; Print Enter message
    mov eax, 4 ; sys_write
    mov ebx, 1
    mov ecx, Enter
    mov edx, Enter_Len
    int 80h

    ; Read input
    mov eax, 3 ; sys_read
    mov ebx, 0
    mov ecx, In_Buffer
    mov edx, In_Buffer_Len
    int …
Run Code Online (Sandbox Code Playgroud)

x86 assembly nasm

1
推荐指数
1
解决办法
5315
查看次数

标签 统计

assembly ×1

nasm ×1

perl ×1

x86 ×1