oprezyzer
oprezyzer

Reputation: 101

How do I check if my assembly 8086 program runs well

I want to put numbers from 0 - 9 to memory cells 400h to 409h. So for example at 400h -> 0 (put 0) and at 401h -> 1 (put 1) ..... 409h (put 9). This is my code so far: (I dont know if it works)

 IDEAL
MODEL small
STACK 100h
DATASEG
;----------

;----------
CODESEG
start:
mov ax , @data
mov ds , ax
mov es, ax
;----------
mov si , 400h
mov cx , 10
mov al , 0
agian:
mov [si],al

inc si
inc al
loop agian
;--------
exit: 
 mov ax,4c00h
 int 21h
 END start 

Upvotes: 3

Views: 1434

Answers (2)

Sep Roland
Sep Roland

Reputation: 39306

There's a very simple way to see if your program works. Just write the values in the video memory. That way you'll know if it works.

start:
 mov  ax, 0B800h     ;NEW
 mov  ds, ax
 mov  es, ax
 ;----------
 mov  si, 400h
 mov  cx, 10
 mov  al, 48         ;NEW value 0 -> character 0
agian:
 mov  [si], al
 add  si, 2          ;NEW 1 character occupies 2 bytes in video memory
 inc  al
 loop agian
 mov  ah,00h         ;NEW wait for a keystroke so you can actually see
 int  16h            ;NEW ... the output

If you can invest the time you could learn to use the DOS utility DEBUG.EXE. Amongst other things it allows you to single step your program and view memory .

Upvotes: 2

Cauterite
Cauterite

Reputation: 1694

The easiest way to check if your ASM code is working the way you expect is to run it in a debugger. If you're running on Windows, OllyDbg 2 would be a good candidate — it will show you the current values of the registers, state of the stack, etc., so you can see how they change as you step through your code. You can modify the code from inside OllyDbg too.

You can write breakpoints in your code with the int 3 instruction, or use the debugger to place breakpoints at runtime.

Upvotes: 1

Related Questions