English 中文(简体)
Bug in my NAM Program
原标题:Bug in my NASM program

因此,Im将作此限定,说Im new to NRM, and I mread the 。 教学。

我把32比特80x86作为我的指令集(我认为......)在北纬度地区汇编成册。

我的方案的目的是从中宣读的插图中删除任何不必要的空间。 因此,护堤一开始的所有空间,以及一字之间任何双重或更大的空间。

我的方案几乎是用一个单一、无证件的特征完成的,这种特征对我都造成了影响。 如果我有两张拖车空间和一个拖车空间的字眼,我的节目将吃第二字的单一拖车空间。 但是,通常只出现两条空间一线的一审。

Here s my make file:

mstrebl  : asm_io.inc  asm_io.o driver.o mstrebl.o
    gcc -o mstrebl -m32 asm_io.o driver.o mstrebl.o

driver.o : driver.c
    gcc -c driver.c -m32

mstrebl.o: mstrebl.asm
    nasm -f elf32 mstrebl.asm

这是一项称为ASM-的C方案。 教学课程

int main()
{
  int ret_status;
  ret_status = asm_main();
  return ret_status;
}

这里是我的阿盟档案。

%include "asm_io.inc"

LF  equ 0Ah

segment .data

name_prompt    DB   Please enter a string to be trimmed:  ,0
out_msg        DB   The trimmed string is:  ,0

segment .bss

in_name    resb  80

segment .text
        global  asm_main
asm_main:
        enter   0,0            ; setup routine
        pusha
restart:

    mov  eax, name_prompt  ; print prompt
    call print_string
    mov  ebx, in_name
                       ;for counting the number of digits
rd_loop:

    call read_char         ; read in the string
    mov  [ebx], al
        inc  ebx
    cmp  al, LF
        jne  rd_loop

    dec  ebx               ; put in null terminator
    mov  byte [ebx], 0
        call print_nl          ; print output msg
        mov  eax, out_msg
    call print_string
        mov  ebx, in_name      ; EBX := address of in_name   

    push in_name
    call strebl             ;this pushes the string onto EAX, destroying old data.

    call print_string 
    add esp, 4

Finished:

        call print_nl
        call print_nl

        popa
        mov     eax, 0         ; return back to C
        leave                     
        ret

; subprogram get_int
; Parameters (in order pushed on stack)
;
;Address of the first character in a string (at [ebp + 8])
; Notes:
; There are no data shifts on the stack, only for the address
; of the array, as such, esp is not changed or shifted.
;
; Note, this destroys the contents of EAX.
; Note, this destroys the contents of CL.


;SUDO CODE!
;j = first address of the string
;if(*char ==   )
;   return *char
;while((*char + i) ==    )
;   i += 1 
; 
;
;while((*char + i !=    ))
;{
;   if((*char + i) ==   )
;       return *char
;
;   (*char + j) = (*char + i)
;   j += 1;
;}
;
;jump to original while

segment .data

temp   db 0

segment .text
 strebl:
    push EBP
    mov  EBP, ESP
    mov  EAX, [EBP + 8] ; I
    mov  EBP, [EAX]     ; J

 First_while:

    cmp byte [EAX], 0
    je  End_strebl
    cmp byte[EAX],     ;or 32 if i need to change it
    jne Second_While

    inc EAX ; i
    jmp First_while

 Second_While:

    cmp byte [EAX], 0
    je  End_strebl    

    cmp byte[EAX],    
    je  Second_While_helper

    ;*EBX = *EAX
    mov ECX, [EAX]
    mov [EBX], ECX

    inc EAX ; increment I and J at the same time 
    inc EBX

    jmp Second_While

Second_While_helper:

    inc EAX
    inc EBX

helper_loop:

    cmp byte[EAX],    
    jne Second_While

    inc EAX

    jmp helper_loop

End_strebl:
    cmp EAX, EBX
    jz  done_strebl
    mov byte[EBX],    

done_strebl:

    mov EAX, [ESP + 8]
    pop EBP
    ret
最佳回答

500台内部服务器Error在上述评论中指出了我的错误。

问题回答

暂无回答




相关问题
How can I do a CPU cache flush in x86 Windows?

I am interested in forcing a CPU cache flush in Windows (for benchmarking reasons, I want to emulate starting with no data in CPU cache), preferably a basic C implementation or Win32 call. Is there a ...

What are the names of the new X86_64 processors registers?

Where can I find the names of the new registers for assembly on this architecture? I am referring to registers in X86 like EAX, ESP, EBX, etc. But I d like them in 64bit. I don t think they are the ...

How do I disassemble raw 16-bit x86 machine code?

I d like to disassemble the MBR (first 512 bytes) of a bootable x86 disk that I have. I have copied the MBR to a file using dd if=/dev/my-device of=mbr bs=512 count=1 Any suggestions for a Linux ...

32bit application access to 64bit registry

I have an OS Shell written in 32bit that is replacing the Explorer.exe of a Vista machine. I run a utility which is also written in 32bit, which allows to switch between the Explorer shell and My ...

Left Shift Overflow on 68k/x86?

I heard that the Motorola 68000 and Intel x86 architectures handle overflow from left shifting differently. Specifically the 68k LSL vs. the Intel SAL/SHL assembly instructions. Does anyone know the ...

Translate a FOR to assembler

I need to translate what is commented within the method, to assembler. I have a roughly idea, but can t. Anyone can help me please? Is for an Intel x32 architecture: int secuencia ( int n, ...

热门标签