flat assembler
Message board for the users of flat assembler.

Index > DOS > print random number [bad sample code]

Author
Thread Post new topic Reply to topic
dreamer85



Joined: 24 Dec 2009
Posts: 3
dreamer85 24 Dec 2009, 15:15
it doesnt work i know im way off but im new to coding assembly, so here's the code.. however it shows no error :/

Code:
org 100h

mov al, 2ch ;get system time
mov bl, dh  ;dh = seconds
int 21h
mov ah, 2   ;print _
mov dl, bl   ;output
int 21h
mov ax,4C00h
int 21h       


erm the idea is to get the seconds from 0..99
Post 24 Dec 2009, 15:15
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 24 Dec 2009, 15:58
Code:
org 100h

;DOS 1+ - GET SYSTEM TIME
;
;AH = 2Ch
;
;Return:
;CH = hour CL = minute DH = second DL = 1/100 seconds
mov ah, 2ch ; You was setting AL instead of AH here, so you was calling an unspecified function here
int 21h

;DOS 1+ - WRITE CHARACTER TO STANDARD OUTPUT

;AH = 02h
;DL = character to write
; BUT, we have to convert the number to ASCII first
mov al, dl
mov ah, 0
mov cl, 10
div cl

mov dh, ah
mov dl, al
add dl, '0'
mov ah, 2
int 21h

mov dl, dh
add dl, '0'
mov ah, 2
int $21

;KEYBOARD - GET KEYSTROKE
;
;AH = 00h
;
;Return:
;AH = BIOS scan code AL = ASCII character
xor ax, ax
int $16  ; Just halting execution until some key is pressed.

mov ax,4C00h
int 21h    
Post 24 Dec 2009, 15:58
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 24 Dec 2009, 16:10
LocoDelAssembly wrote:
; You was setting AL instead of AH here, so you was calling an unspecified function here
Pretty well specified: ah contains 0FFh if second command line argument has invalid drive letter, zero otherwise. Unless dreamer85 supplied two parameters, second with invalid drive letter, first DOS call was... ah==0 -- terminate program. Wink
Post 24 Dec 2009, 16:10
View user's profile Send private message Reply with quote
dreamer85



Joined: 24 Dec 2009
Posts: 3
dreamer85 24 Dec 2009, 16:16
jeez i have such a long way to go Sad just when i think i got the hang of something it turns out i've made a complete mess!

thx guys.
Post 24 Dec 2009, 16:16
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 25 Dec 2009, 13:07
dreamer85 wrote:
erm the idea is to get the seconds from 0..99


Timing code (32-bit DOS) : http://board.flatassembler.net/topic.php?t=8670
Post 25 Dec 2009, 13:07
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.