I am learning and I am a beginner in assembly language programming and we are currently learning about string printing and manipulating display memory. I'd like give the background before talking about the problem. We are making programs for the iapx88 (intel 8088) processor architecture, we are using the nasm assembler and the afd debugger. I use 32-bit Windows 7 Ultimate. My problem is that I can't execute any of the string printing programs in the command prompt, even though the code runs correctly in the debugger. The attached images will help explain the problem better. Our instructor told us to run a full-screen dos program (like the editor) or to run the .com file of the program in the afd before executing the program in Dos. Neither of those tips has helped me. Here's one of the string printing programs which we've written:
; program in assembly to display 'hello world' on screen
[org 0x0100]
push cs
pop ds
jmp start
message: db 'hello world' ; string to be printed
length: dw 11 ; length of the string
; subroutine to clear the screen
clrscr: push es
push ax
push di
mov ax, 0xb800
mov es, ax ; point es to video base
mov di, 0 ; point di to top left column
nextloc: mov word [es:di], 0x0720 ; clear next char on screen
add di, 2 ; move to next screen location
cmp di, 4000 ; has the whole screen cleared
jne nextloc ; if no clear next position
pop di
pop ax
pop es
ret
; subroutine to print a string at top left of screen
; takes address of string and its length as parameters
printstr: push bp
mov bp, sp
push es
push ax
push cx
push si
push di
mov ax, 0xb800
mov es, ax ; point es to video base
mov di, 0 ; point di to top left column
mov si, [bp+6] ; point si to string
mov cx, [bp+4] ; load length of string in cx
mov ah, 0x07 ; normal attribute fixed in al
nextchar: mov al, [si] ; load next char of string
mov [es:di], ax ; show this char on screen
add di, 2 ; move to next screen location
add si, 1 ; move to next char in string
loop nextchar ; repeat the operation cx times
pop di
pop si
pop cx
pop ax
pop es
pop bp
ret 4
start: call clrscr ; call the subroutine
mov ax, message
push ax ; push address of message
push word [length] ; push message length
call printstr ; call the printsr subroutine
mov ax, 0x4c00 ; terminate program
int 0x21
This is how we have been told to make the .com file of the program:
nasm hello.asm -o hello.com -l hello.lst
I keep all the program files in the same folder 'Assembly' with the nasm assembler in my D: drive. And here's what happens when I try to execute the program in CMD: First I type the name of the program: (https://i.sstatic.net/ELiaF.png) After pressing 'Enter': (https://i.sstatic.net/bcX1H.png)
I hope I have explained my problem well enough. I have tried to google the solution of this problem but I couldn't find one. If you guys could help me and tell me what I am doing wrong with my code, I would be very thankful to you. Thanks.