Author Topic: beginner program example?  (Read 22230 times)

hops33n

  • Guest
beginner program example?
« on: December 08, 2007, 10:23:52 PM »
I just started nasm yesterday using xp. I understand alittle, but wanted some help to get a jump start.  I will be visiting the websites and further readings in the coming days that Ive seen posted on the forums.  

But I figured I would cheat and see if some one could write me a simple program and describe each step.  I figured this would be a good starting program.  Something to do with a loop and key presses and screen output. What I was thinking, is have the program wait for a key press, then display what key was pressed, loop until esc was pressed.

I guess it would look like:

--------------------
Press one key or Esc:
Value:"key pressed" ; not sure if this would be the actual letter or number or the code representation
Press one key or Esc:
Value:"key pressed" ; I guess compare the register and exit or show key
--------------------

Heres the little I know although it could be wrong:

Org 100h
;display message
mov ah, 9
mov dx, msg
int 21h
;user presses key
;something like this?
;mov ah, 10h
;mov al, 0
;int 16h
;compare value ie cmp or jmp?
;if Esc key pressed exit
;if not, show key or value and loop display message

msg db 'Press one key or Esc',0Dh,0Ah,'$'

Thanks in advance, maybe I'll get good enough sometime to help others out.

nobody

  • Guest
Re: beginner program example?
« Reply #1 on: December 09, 2007, 12:17:51 AM »
> I just started nasm yesterday using xp.

COOL :-D

> Org 100h
> ;display message
> mov ah, 9
> mov dx, msg
> int 21h

This is DOS code, not XP code :-D

> ;compare value ie cmp or jmp?

Use CMP and followed by conditional jump (JE or JNE). ;-)

http://sourceforge.net/forum/forum.php?thread_id=1809963&forum_id=167168