whats wrong with this [nasm](solved)
Posted: Fri May 20, 2016 5:59 pm
Code: Select all
use16
mov ax, sp
mov [stackpointer], ax
keyloop:
mov ah, 0
int 0x16
cmp al, 0x08
je .bkspc
cmp al, 0x0d
je .ret
call print_al
call cursor_forward
push ax
jmp keyloop
.bkspc:
call cursor_backward
mov al, ' '
call print_al
jmp keyloop
.ret:
call cmdcmp
call scroll_up
jmp keyloop
stackpointer dd 0
cmdstr db 'cls help',0
cmdsame db 1
cmdspcs db 0
cmdcmp:
xor eax, eax
mov ds, ax
mov es, ax
mov esi, [stackpointer]
mov edi, cmdstr
add esi, 1
mov byte [cmdsame], 1
mov byte [cmdspcs], 0
cld
.loop:
cmpsb
add esi, 1
je .loop
cmp byte [edi], 32
je .spc
cmp byte [edi], 0
je .end
mov byte [cmdsame], 0
jmp .loop
.spc:
cmp byte [cmdsame], 1
je .match
mov byte [cmdsame], 1
add byte [cmdspcs], 1
mov esi, [stackpointer]
add esi, 1
jmp .loop
.end:
mov ax, [stackpointer]
mov sp, ax
cmp byte [cmdsame], 1
je .match
ret
.match:
mov ax, [stackpointer]
mov sp, ax
cmp byte [cmdspcs], 0
je .cls
cmp byte [cmdspcs], 1
je .help
ret
.cls:
mov ah, 0x0f
int 0x10
mov ah, 0x00
int 0x10
mov ah, 2
mov bh, 0
mov dh, 0
mov dl, 0
int 0x10
ret
.help:
ret
print_al:
mov ah, 9 ;write char and attr at cursor
mov bh, 0 ;page
mov bl, 0x0f ;color
mov cx, 1 ;write times
int 0x10
ret
cursor_getpos:
mov ah, 3
int 0x10
ret
cursor_forward:
call cursor_getpos
mov ah, 2 ;set cursor pos
cmp dl, 79
je .colmax
add dl, 1
int 0x10
ret
.colmax:
cmp dh, 24
je .rowmax
mov dl, 0
add dh, 1
int 0x10
ret
.rowmax:
mov dl, 0
int 0x10
call scroll_down
ret
cursor_backward:
call cursor_getpos
mov ah, 2 ;set cursor pos
cmp dl, 0
je .colmin
sub dl, 1
int 0x10
ret
.colmin:
cmp dh, 0
je .rowmin
mov dl, 79
sub dh, 1
int 0x10
ret
.rowmin:
mov dl, 79
int 0x10
call scroll_up
ret
scroll_up:
mov ah, 6
mov al, 1
mov bh, 0x0f
mov cx, 0
mov dx, 0x4f4f
int 0x10
ret
scroll_down:
mov ah, 7
mov al, 1
mov bh, 0x0f
mov cx, 0
mov dx, 0x4f4f
int 0x10
ret
13 E8 B3 00 E8 C1 00 50 EB EB E8 E0 00 B0 20 E8
A5 00 EB E1 E8 14 00 E8 F8 00 EB D9 00 00 00 00
63 6C 73 20 68 65 6C 70 00 01 00 66 31 C0 8E D8
8E C0 66 8B 36 2C 8E 66 BF 30 8E 00 00 66 83 C6
01 C6 06 39 8E 01 C6 06 3A 8E 00 FC A6 66 83 C6
01 74 F9 67 80 3F 20 74 0D 67 80 3F 00 74 23 C6
06 39 8E 00 EB E6 80 3E 39 8E 01 74 22 C6 06 39
8E 01 80 06 3A 8E 01 66 8B 36 2C 8E 66 83 C6 01
EB CA A1 2C 8E 89 C4 80 3E 39 8E 01 74 01 C3 A1
2C 8E 89 C4 80 3E 3A 8E 00 74 08 80 3E 3A 8E 01
74 14 C3 B4 0F CD 10 B4 00 CD 10 B4 02 B7 00 B6
00 B2 00 CD 10 C3 C3 B4 09 B7 00 B3 0F B9 01 00
CD 10 C3 B4 03 CD 10 C3 E8 F8 FF B4 02 80 FA 4F
74 06 80 C2 01 CD 10 C3 80 FE 18 74 08 B2 00 80
C6 01 CD 10 C3 B2 00 CD 10 E8 35 00 C3 E8 D3 FF
B4 02 80 FA 00 74 06 80 EA 01 CD 10 C3 80 FE 00
74 08 B2 4F 80 EE 01 CD 10 C3 B2 4F CD 10 E8 01
00 C3 B4 06 B0 01 B7 0F B9 00 00 BA 4F 4F CD 10
C3 B4 07 B0 01 B7 0F B9 00 00 BA 4F 4F CD 10 C3
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I can post what runs this just wasn't sure if it was obvious...