>Daniel's Homepage

Posts

My posts about programming and things.
Date format is day/month/year because I'm sane.

8085 assembly #4: Task #3

9/1/2018

Excercise 3 is a simple yet important one. Jumping around code like a 'goto' statement in C isn't always the best way to go about doing things. The difference between jumping and calling is when you jump, the program never returns to the instruction after the jump, instead it flows on from that memory location. With a call to a subroutine you are able to 'RET' (return) either on condition or unconditionally. This is very similar to a function call in C. This program is a simple counter that utlises a subroutine call.

; CALL ACTS LIKE A FUNCTION CALL IN C, A SUBROUTINE
; CALL COUNT AND COUNT TO C FROM B
JMP START

START:	MVI B,00H	; COUNT FROM 0
	MVI C,05H	; COUNT TO 5
	MOV A,B		; COUNT FROM B
	CALL CNT	; CALL COUNT SUBROUTINE
	HLT		; HALT
CNT:	CMP C		; COMPARE C TO A
	RZ		; RETURN IF C==A
	INR A		; A++
	JMP CNT		; LOOP




RSS feed
FSF member

page generated 1/12/2024 using websitegenerator in C