 |
|
Home:
General Discussions:
General Questions:
Re: [mhx] Math...:
Edit Log
|
|

yapp
User
Feb 27, 2002, 6:51 AM
Views: 3829
|
No, it doesn't sum one number up several times. That would be really too slow. Oh boy...   for our first semester, I created this (we needed to try out some basic 8085)
; Calculates (5 + (8 * 15)) * 2 ; Keeps track of overflow errors, ; and a "times 0" is trapped aswell. mvi d,8H ; D = 8 mvi e,EH ; E = 14 push d ; D en E op stack call Multiply ; Do a Multiply!! call Add5 ; Add 5 call Times2 ; Times 2 hlt ; End of program ; A is now EA, so 234 ;=============================== ; Subroutines ; Gets two bytes from the stack, ; and leaves the result in the acc MULTIPLY: ; Subroutine Multiplies: A=B*C mvi a,0 pop h ; POP Program Counter pop b cmp c jnz DoMulti push h ret DoMulti: add b ; A = A + B jc Overflow ; Is Overflow? dcr c jnz DoMulti push h ; Push back Program Counter ret ; Adds 5 to the acc and tests for overflow ADD5: adi 5H ; A = A + 5 jc Overflow ; Is Overflow? RET ; Multiplies A with 2, and tests for overflow TIMES2: add a ; A = A + A (A*2) jc Overflow ; Is Overflow? RET ; Fake some overflow message, ; set all registers to FF and break,halt OVERFLOW: mvi a,FFH mvi b,FFH mvi c,FFH mvi d,FFH mvi E,FFH mvi H,FFH mvi L,FFH ;BREAK HLT Yet Another Perl Programmer _________________________________ ~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~ More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads!
(This post was edited by yapp on Feb 27, 2002, 6:52 AM)
|
|
|
Edit Log:
|
|
Post edited by yapp
(User) on Feb 27, 2002, 6:52 AM
|
|
Post edited by yapp
(User) on Feb 27, 2002, 6:52 AM
|
|
Post edited by yapp
(User) on Feb 27, 2002, 6:52 AM
|
|
Post edited by yapp
(User) on Feb 27, 2002, 6:52 AM
|
|
|  |