flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > DOS > print ax value eg

Author
Thread Post new topic Reply to topic
kerr



Joined: 24 Feb 2016
Posts: 119
print ax value eg

Code:

format mz
entry code:start

segment datas
                buff dd 0
                strs db "0123456789ABCDEF"
                string db " >>> is eax value$"
segment code
                start:
                        mov ax,datas
                        mov ds,ax
                        push ax                                 ;save data
                        xchg ah,al                                      ;swaps
                        call printf                                     ;call print
                        pop ax                                  ;pop data
                        call printf
                        call print
                        mov ax,4c00h
                        int 21h

printf:
                        xor ah,ah                                       ;zero setting 
                        xor bx,bx
                        mov bl,16
                        div bl                                          ;In addition to the 10 
                        mov bl,al
                        mov byte[buff],ah                       ;save buff
                        mov dl,[strs+bx]                        ;seach string array
                        mov ah,2
                        int 21h
                        mov bl,byte[buff]
                        mov dl,[strs+bx]
                        mov ah,2
                        int 21h
                        ret
print:
                        lea dx,[string]
                        mov ah,9
                        int 21h
                        ret





Quote:


D:\try>debug n39.exe
-g
0BA1 >>> is eax value
Program terminated normally



okey bingo end![/code]

_________________
I hope we will be good friends.
Post 24 Aug 2016, 06:41
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2122
Location: Usono (aka, USA)
There's no reason to need "div" by any power of 2 (e.g. 16), you can use a shift instead.

Anyways, this kind of exercise is always interesting, but of course it's been done before: https://board.flatassembler.net/topic.php?t=7109
Post 26 Aug 2016, 01:33
View user's profile Send private message Visit poster's website Reply with quote
kerr



Joined: 24 Feb 2016
Posts: 119

rugxulo wrote:
There's no reason to need "div" by any power of 2 (e.g. 16), you can use a shift instead.

Anyways, this kind of exercise is always interesting, but of course it's been done before: https://board.flatassembler.net/topic.php?t=7109

|


yes! you speak good.

_________________
I hope we will be good friends.
Post 14 Sep 2016, 17:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.