string - How to move around a matriz in Assembly language using SI and DI as pointers? -


i'm trying create simple text editor i'm not sure how save user input strings. how move , control positions within each string? also, how control when go next string using si? far have :

matriz:  mov si, 0 mov si, offset direc    ; directions   mov di, 0 mov di, offset fila1    ; [si+0] 1st row mov word ptr[si], di add si, 2  mov di, offset fila2    ; [si+2] 2nd row mov word ptr[si], di add si, 2  mov di, offset fila3    ; [si+4] 3rd row mov word ptr[si], di add si, 2  mov di, offset fila4    ; [si+6] 4th row mov word ptr[si], di add si, 2  mov di, offset fila5    ; [si+8] 5th row mov word ptr[si], di add si, 2  ret 

...........................

write: mov cx, 1 cycle:             mov ah, 2h          ; character output         int 10h             ; display character in dl             mov ah, 1h          ; keyboard input         int 21h             ; read character al          cmp al, 27          ; esc         je fin                    cmp al, 0            je compararspecialkeys          mov byte ptr [di], al         mov cl, dl          ; not lose value of posx         mov dl, al          ; able print         mov ah, 2h          ; character output         int 10h             ; display character in dl          mov dl, cl         inc dl              ; move position         mov posx, dl        ; update posx         cmp posx, 38        ; border limit         je nextline  inc di loop cycle jmp start  ret 

nextline: mov dl, 1 mov posx, dl    ;update posx inc dh mov posy, dh    ;update posy add si, 2 call write 

posx db 1 dup(1)    ; dl = posx -> controls column posy db 1 dup(1)    ; dh = posy -> controls row xlimit dw 38        ; number of columns ylimit dw 24        ; number of rows     direc db 36 dup(42) ; 42 ascii space fila1 db 36 dup(42) fila2 db 36 dup(42) fila3 db 36 dup(42) fila4 db 36 dup(42) fila5 db 36 dup(42) 

.loop:     mov ah, 7     int 21h     cmp al, 27  ; esc     je finish   ; call fin      mov ah, 0     int 16h     ; special keys     call comparar      jmp .loop 

this part of code better in loop, want read multiple inputs, not one. also, comparar requires ret @ end of operations.

moveup:     mov dl, posx    ;actualizar coordinates     mov dh, posy     dec dh      ; posy --      mov posy, dh     jmp prntcrs     ; print cursor 

i'm not sure whether shouldn't

moveup:     mov dl, byte [posx]    ;actualizar coordinates     mov dh, byte [posy]     dec dh                 ; posy --      mov byte[posy], dh     jmp prntcrs            ; print cursor 

with posx , posy declared

posx: db 0 posy: db 0 

to store values.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -