Hello,
I need to write a simple counting program using MASM but as a true newbie, I'm not sure where to begin.
Assembly language is not like anything I used before (C++.. etc)
Thanks
Nyjc,
Ps. Please forgive me if this is not the correct forum for this question...
I need to write a simple counting program using MASM but as a true newbie, I'm not sure where to begin.
Assembly language is not like anything I used before (C++.. etc)
Thanks
Nyjc,
Ps. Please forgive me if this is not the correct forum for this question...
Write a raw Win32 API version in C, then insert "invoke" before the API functions and remove all the brackets - you are 80% there. :) Post what you got going...
Write a raw Win32 API version in C, then insert "invoke" before the API functions and remove all the brackets - you are 80% there. :) Post what you got going...
Thanks... basically what I need to do is write a small program, which contains a loop increasing the numbers starting at 0.
so, O + 1 etc.
Thank you again
what I need to do is write a small program, which contains a loop increasing the numbers starting at 0.
Homework 8)
http://webster.cs.ucr.edu/AoA/DOS/AoADosIndex.html
Do a TextSearch on Addition and Looping - then start reading!
Come back for hints
Okay... thank you.
I read all the related documents... BTW great site...
I still have some questions...
basically, I know how to initiate the program, up until the point where I write mov ax, @data
I then try to write the following
mov ax, 0 ;moving the number 0 into ax.
mov ??? ; I want to display the zero here...
inc ax; this should increment by one (Is this correct...) What next...
Again thank you
I read all the related documents... BTW great site...
I still have some questions...
basically, I know how to initiate the program, up until the point where I write mov ax, @data
I then try to write the following
mov ax, 0 ;moving the number 0 into ax.
mov ??? ; I want to display the zero here...
inc ax; this should increment by one (Is this correct...) What next...
Again thank you
To loop you have to JMP, but you don't want to loop forever. So, you need an exit condition maybe?
Assuming you are programing in DOS, then displaying the number requires a BIOS function - which is accessed through an INT.
Assuming you are programing in DOS, then displaying the number requires a BIOS function - which is accessed through an INT.
Hi nyjcr,
Here is a counter demo. The PrintDec routine is coded by MichaelW from masmforum.
Here is a counter demo. The PrintDec routine is coded by MichaelW from masmforum.
.model small,stdcall
PrintDec PROTO :WORD
.stack
.code
start:
xor cx,cx ; set cx to 0
@@:
inc cx ; increment cx
push cx ; preserve cx as it's used by PrintDec
invoke PrintDec,cx
mov ah,2
mov dl,13
int 21h ; put CR+LF
mov ah,2
mov dl,10
int 21h
pop cx
cmp cx,10 ; Is cx equal to 10 ?
jne @b ; If not jump back to process cx
mov ah,04Ch
int 21h
PrintDec PROC numb:WORD
mov ax,numb
;
; Init divisor.
mov bx,10
; Zero digit counter.
mov cx,0
@@:
; Zero MSW of dividend.
mov dx,0
; Divide value by 10.
div bx
; Push remainder.
push dx
; Increment digit count.
inc cx
; Repeat if quotient > 0.
or ax,ax
jnz @B
@@:
; Pop digit off stack.
pop dx
; Convert to ascii.
add dl,30h
; Display.
mov ah,2
int 21h
; Repeat CX times.
loop @B
ret
PrintDec ENDP
END start