flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
rugxulo 18 Feb 2007, 21:40
I assume you're using FASMW? In that case, use the Win32 console version (FASM.EXE, approx. 77k) in a CMD.EXE window (Start -> Run -> cmd.exe -> cd /d c:\fasm && fasm c:\projects\jake.asm ).
|
|||
![]() |
|
Jakevfr 18 Feb 2007, 22:50
Why does this refuse to work?
Code: org 256 jmp Main get db 0 write: push ax bx dx mov ah, 2h mov bx, 0 .loop: mov al, [si+bx] or al, al jz .done mov dl, al int 21h inc bl jmp .loop .done: mov bx, 0 call endl pop dx bx ax ret endl: push ax dx mov ah, 2 mov dl, 0Dh int 33 mov dl, 0Ah int 33 pop dx ax ret read: push ax bx dx .input: mov ah, 8 int 21h cmp al, 13 je .complete .continue: mov ah, 2 mov dl, al int 21h mov [get+bx], al inc bl jmp .input .complete: mov [get+bx], 0 mov ax, get call endl pop dx bx ax ret Main: call read mov si, ax call write int 32 It says it attempted an illegal opperation when run. (or won't print) |
|||
![]() |
|
vid 19 Feb 2007, 01:50
Jakefvr: maybe you are forgetting to initialize BX in "read"?
|
|||
![]() |
|
Jakevfr 19 Feb 2007, 03:32
It still doesn't work, it works just fine if I do one without the other, but together they just refuse to work
![]() |
|||
![]() |
|
vid 19 Feb 2007, 10:36
Jakevfr:
Code: mov si, ax
call write what is value of ax supposed to be? |
|||
![]() |
|
Jakevfr 19 Feb 2007, 16:20
The string entered in read.
EDIT: Well I changed it so that it wouldn't pop AX off of the stack, but it still won't work :[ Here's the code now: Code: org 256 jmp Main get db 0 write: push ax bx dx mov ah, 2h mov bx, 0 .loop: mov al, [si+bx] or al, al jz .done mov dl, al int 21h inc bl jmp .loop .done: mov bx, 0 call endl pop dx bx ax ret endl: push ax dx mov ah, 2 mov dl, 0Dh int 33 mov dl, 0Ah int 33 pop dx ax ret read: push bx dx mov bx, 0 .input: mov ah, 8 int 21h cmp al, 13 je .complete .continue: mov ah, 2 mov dl, al int 21h mov [get+bx], al inc bl jmp .input .complete: mov [get+bx], 0 mov ax, get call endl pop dx bx ret Main: call read mov si, ax call write int 32 |
|||
![]() |
|
vid 19 Feb 2007, 16:37
1. "get" buffer should be larger than just one byte
2. what is "read" supposed to return in AX? |
|||
![]() |
|
Jakevfr 19 Feb 2007, 17:07
It is supposed to return the buffer get. So when the user inputs something what they inputed is placed into get, and then placed in ax.
|
|||
![]() |
|
vid 19 Feb 2007, 19:10
so then the problem is 1)
"get db 0" declares one byte. You need more bytes, otherwise you will overwrite following things, in your case code of "write" procedure. |
|||
![]() |
|
Jakevfr 19 Feb 2007, 20:09
Thank you. The reason I didn't see that until you basically pointed it out to me is because this is what I get looked like before I began the functions smaller.
Code: get db 100 dup (?) Looking back at earlier posts I see I changed that. Thanks again vid |
|||
![]() |
|
vid 19 Feb 2007, 21:53
Jakefvr: you are welcome.
There is one more challenge: don't allow "read" to overflow buffer. Accept at most so many chars, that buffer won't overfow |
|||
![]() |
|
Jakevfr 19 Feb 2007, 22:27
Alright, I'll do that.
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.