flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
me239 19 Jul 2011, 06:27
Hey guys, I was wondering if anyone had any routines for accepting input from the cli that converts the number entered into a WORD value.
|
|||
![]() |
|
AsmGuru62 19 Jul 2011, 11:09
Get the text from user using INT 21H (AH=0Ah).
Then convert received text into a number using following pseudo-code: Code: RESULT=0 repeat until no more digits left within input text AL = load next digit SUB AL,'0' RESULT = 10*RESULT + AL end repeat Here http://www.codexxi.com/MyTools.html#atFASMW I have some code like this in a sample project for IDE. Look in PROJECTS folder - IntCalc sub-folder. |
|||
![]() |
|
me239 20 Jul 2011, 00:55
AsmGuru62 wrote: Get the text from user using INT 21H (AH=0Ah). Code: mov word[num], 0 mov si, msg mov cx, 5 @@: lodsb mov ah, 0 xchg ax, bx mov ax, [num] mov dx, 10 mul dx add ax, bx mov word[num], ax loop @b mov ax, [num] int 20h num dw 0 msg db '1234', 0 |
|||
![]() |
|
me239 20 Jul 2011, 03:10
LocoDelAssembly wrote: You forgot to subtract '0' (4 Code: org 100h start: mov word[num], 0 mov si, msg @@: lodsb cmp al, 0 jz @f mov ah, 0 sub al, 30h xchg ax, bx mov ax, [num] mov dx, 10 mul dx add ax, bx mov word[num], ax jmp @b @@: mov ax, [num] num dw 0 msg db '1234', 0 |
|||
![]() |
|
bitshifter 20 Jul 2011, 03:53
I hope something more goes here ...
Code: mov ax, [num] ... num dw 0 |
|||
![]() |
|
me239 20 Jul 2011, 04:20
bitshifter wrote: I hope something more goes here ... actually it's a RET |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.