Category : Assembly Language Source Code
Archive   : ZAD.ZIP
Filename : LAB2.ASM

 
Output of file : LAB2.ASM contained in archive : ZAD.ZIP
INIT1 .ORG 1800H
MVI A, 00H
STA 1B00H ;STORES ADDRESS IN MEMORY
LXI H, 1A00H ;POINT TO 1ST INPUT
MVI D, FE ;INIT MIN
MVI E, 00 ;INIT MAX
LOOP1 MOV A, M ;GET INPUT
CPI FF ;CHECK FOR END OF LIST
JZ CLOSE ;IF DONE, CLEAN UP
SHLD 1000H ;SWITCH OUT COUNTER AND POINTER
LHLD 1B00H ;LOAD COUNTER ADDRESS
INR M ;INCREMENT COUNTER
LHLD 1000H ;RETURN POINTER
MAX CMP E ;COMPARE TO MAX
JNC MIN ;IF NOT MAX GOTO NEXT THING
MOV E, A
MIN CMP D ;COMPARE TO MIN
JC SUM ;IF NOT NEW MIN, JUMP TO NEXT THING
MOV D, A
SUM ORA A
JZ INCPTR ;IF A IS ZERO, INCREMENT POINTER & BEGIN AGAIN
INX B ;INCREMENT SUM
DCR A ;DECREMENT NUMBER
JMP SUM ;RELOOP
INCPTR INX H ;INCREMENT POINTER
JMP LOOP1 ;BEGIN AGAIN WITH NEXT NUMBER
CLOSE LXI H, 1B01H ;PUT REGISTERS IN MEMORY
MOV M, D ;MIN
INX H
MOV M, E ;MAX
INX H
MOV M, B ;HI SUM
INX H
MOV M, C ;LO SUM
DIVINIT LDA 1B00H ;PUT COUNTER IN A
MOV D, A
MVI E, 00H
ORA A ;IS COUNTER ZERO?
JZ BYE
DIV1 MOV A, B ;MOVE HI SUM
ORA A
JZ DBIGC ;IF HI SUM ZERO, SEE IF DIVISOR>LO SUM
DIV2 INR E ;OTHERWISE, INCREMENT ANSWER
MOV A, C ;\ AND
SUB D ; > SUB DIVISOR FROM LO SUM
MOV C, A ;/
JNC DIV1 ; BORROW?
DCR B
JMP DIV1 ; END OF DIVISION LOOP
DBIGC MOV A, C ; DIVISOR BIGGER THAN LO SUM?
CMP D
JC CARRY1 ; YES.
JMP DIV2 ; NO
CARRY1 ADD A ; ROUND UP OR DOWN?
JC CARRY2
CMP D
JC BYE
CARRY2 INR E
MOV M, E
BYE STOP
.ORG 1B00
.END


  3 Responses to “Category : Assembly Language Source Code
Archive   : ZAD.ZIP
Filename : LAB2.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/