1 Replies - 370 Views - Last Post: 10 June 2017 - 10:32 PM

#1 sapir  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-June 17

print a star every five seconds using port 70h and 71h

Posted 10 June 2017 - 08:01 AM

Hi everybody, I'm new in assembly 8086.
I tried to print a star every 5 seconds but i didn't succeed.
here is my code:

.model small

.data  
star db '*'

.code
start:

mov ax,@data ;initialization
mov ds, ax
mov cl, 0h; save the last time we printed
mov bx,1; using as flag for the first time 

pulse:
cli 
mov al 0h ;seconds 
in al, 070h
out al, 071h ;al=current second(time)
sti

cmp bx,01h
jz initial

sub al,05h; current time-5
cmp cl,al;
jz print
jmp pulse


initial:
dec bx
 
print:
mov dl,star; 
mov ah, 2h
int 21h
mov cl,al; update the last time printed
jmp pulse

end start
:code:

my idea was to print a star in the beginning, save this time in the register cl and then to check in any pulse in 5 seconds were past, by subtracting 5 from the new time and compare it to last one.
the problem is that it prints only in the first time and then it stopped printing.
any idea??
thanks a lot!

This post has been edited by modi123_1: 10 June 2017 - 08:20 PM
Reason for edit:: In the future, please use the [code] tag button in the editor..


Is This A Good Question/Topic? 0
  • +

Replies To: print a star every five seconds using port 70h and 71h

#2 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2130
  • View blog
  • Posts: 4,196
  • Joined: 30-May 10

Re: print a star every five seconds using port 70h and 71h

Posted 10 June 2017 - 10:32 PM

http://wiki.osdev.or...Real-Time_Clock
If you want to read the seconds value from the RTC, then you need this
mov al, 0h ;seconds 
out 070h, al
in al, 071h ;al=current second(time)



You also need to note (from the same page) that RTC values can be in BCD.
You might also need to consider this as well.
https://en.wikipedia...ntel_BCD_opcode
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1