我的项目Assembly x86的下一步是什么

wkyowqbh  于 2023-01-21  发布在  其他
关注(0)|答案(1)|浏览(106)

我正在尝试修复我的项目的代码,但我有点不知所措。This is the last question I asked about my code
我在这里上传整个代码:

.model small
.stack 100h

.data
indexul db 2 dup (0)
invalid db "Indexul introdus este invalid!",0,'$'
string db 'Introduceti indexul numelui pe care doriti sa-l stergeti:',0,'$'
punct db '.$'
prompt db 'Introduceti un nume:',0,'$'
list db 'Lista cu numele este:',0,'$'
nume dw 50 dup(0)
numes dw 0
numeIndex db 13, 10, 49, 46, 36

numePointer dw 50
menu db "Alege o optiune:",13,10
     db "1. Nume",13,10
     db "2. Lista cu numele",13,10
     db "3. Sterge un nume",13,10
     db "4. Exit",13,10,'$'

.code
start:
    mov al, 0
    ;INITIALIZE DATA SEGMENT.
    mov  ax, @data
    mov  ds, ax
    mov numePointer, offset nume
    call clear_screen
bucla:
    ;Move cursor to the next line
    mov dl, 0dh
    mov ah, 2
    int 21h
    mov dl, 0ah
    int 21h
    ;Display menu
    call display_menu
    mov ah, 1
    int 21h
    cmp al, '1'
    je scrienume
    cmp al, '2'
    je lista
    cmp al, '3'
    je sterge
    cmp al, '4'
    jmp exit
    jmp bucla

    mov dx, offset numePointer

scrienume:
  mov  dx, offset prompt
  mov  ah, 09h
  int  21h
  mov  cx, 5
  mov  si, numePointer
read_char:
  mov  ah, 01h
  int  21h
  mov  [si], al
  inc  si
  loop read_char
  mov  byte ptr [si], '$'
  inc  si
  mov  numePointer, si ; numePointer += 6
  jmp  bucla




lista:
mov  byte ptr [numeIndex + 2], "1"
  mov  dx, offset nume
print_names:
  push dx                        ; (1)
  mov  dx, offset numeIndex
  mov  ah, 09h
  int  21h
  inc  byte ptr [numeIndex + 2]  ; "1" -> "2" -> "3" ...
  pop  dx                        ; (1)

  mov  ah, 09h
  int  21h
  add  dx, 5 + 1
  cmp  dx, numePointer ; check if the current name is the last one
  jb   print_names
  jmp  bucla           ; return to main loop


sterge:
    ; Prompt user for position of name to delete
    mov dx, offset string
    mov ah, 09h
    int 21h
    ; Read position from user
    mov ah, 01h
    int 21h
     sub  al, 49      ; AL=["1","9"] 1-based input -> AL=[0,8] 0-based index
  mov  ah, 6
  mul  ah          ; -> AX = {0,6,12,18,24,30,36,42,48}
  add  ax, offset nume
  cmp  ax, numePointer
  jnb  invalidPosition
  mov  di, ax
  lea  si, [di + 6]
  mov  cx, numePointer
  sub  cx, si
  cld
  rep movsb
  mov  numePointer, di
  dec  numes
  jmp  bucla
  
invalidPosition:
    ; Display error message
    mov dx, offset invalid
    mov ah, 09h
    int 21h
    jmp bucla



exit:
    ;FINISH PROGRAM.
    mov  ax, 4c00h
    int 21h

;---------------------------------------------
display_menu proc
  mov  dx, offset menu
  mov  ah, 9
  int  21h
  ret
display_menu endp

clear_screen proc
  mov  ah, 0
  mov  al, 3
  int  10H
  ret
clear_screen endp
end start

正如我在其他问题中提到的,无论我输入什么索引,它都只删除姓氏。

y3bcpkx1

y3bcpkx11#

;INITIALIZE DATA SEGMENT.
mov  ax, @data
mov  ds, ax

您忘记设置ES段寄存器! movsb指令需要它。
x一个一个一个一个x一个一个二个x
最好用db来定义,并为最多9个名称预留空间,因此9 *(5 + 1):

nume db 54 dup(0)

相关问题