Jump to content

Assembly String Input

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
JMC31337

JMC31337

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
A simple string input/output using NASM. I decided to post this simple yet effective ASM code. Comments have been added
========================================
SIMPLE ASM (String Input)
[BITS 16] ;16 BIT MODE
[ORG 100h] ; START .COM FILE 100h
[SECTION .text] ;CODE

mov dx,msg                                 ;move "msg" --> data register
mov ah,9h                                   ;call display 
int 21h                                       ;DO IT!!

mov ah,0Ah                               ;call keyboard buffered input
mov dx,buffer               ;move buffer of 5 chars to data register
int 21h                                           ;DO IT!!!

mov ah,9h                                      ;call display
mov dx,crlf                        ;move carriage return+line feed
int 21h                                                   ;DO IT!!!

mov ah,9h                                          ;call display
mov dx,buffer+2           ;mov buffer + 2 offset index --> data register 
int 21h                                              ;DO IT!!!

mov ax,4C00h                                 ;call EXIT 
int 21h                                        ;DO IT!!!

[SECTION .data]                             ;SIMPLE DATA
msg db "Enter Password:",'$'
buffer db 5                                ;SETUP Buffer of 5 chars - NULL
db 0 
times 5 db 0 ;0 out buffer
db '$'                                                    ;estb NULL
crlf 10,13,"$"                            ;10/13 = carriage return line feed
===============================
CODED BY: JMC31337

Edited by WingedPanther, 12 February 2009 - 06:39 PM.
add cod

"Your Life Is Your Crime, It's Punishment Time"

#2
Brandon W

Brandon W

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,828 posts
Wow, I don't think I want to learn Assembly just yet. Maybe not ever, it looks so complex. Also, may I suggest using the [code] tags?

Also are the ";" the comments?
jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation

Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!


#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I may not have added to code tags correctly. ASM is one of those things that is not that bad once you learn it, but it's non-trivial. One of these things I'll be picking up one I get back into Knuth's books again.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
I just did something very similar using the ARM architecture earlier today. Except I only read/output a character.

#5
JMC31337

JMC31337

    Learning Programmer

  • Members
  • PipPipPip
  • 32 posts
yea ASM is def complicated...but once you get the basics of what the BIOS/DOS does you start to see patterns.. i.e... int 21h calls whatever Interrupt... but from i can see is its the proper utilization of segment registers... for instance when to use DX and AX CX .... if you want a good book on getting started i recommend Assembly Language Programming for DOS and Linux... if i have time i'll show stack usage with push n pop calls...
"Your Life Is Your Crime, It's Punishment Time"