-
Notifications
You must be signed in to change notification settings - Fork 0
/
lc4_stdio.asm
62 lines (48 loc) · 1.7 KB
/
lc4_stdio.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; file name : lc4_stdio.asm ;
; author :
; description : LC4 Assembly subroutines that call ;
; call the TRAPs in os.asm (the wrappers);
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; WRAPPER SUBROUTINES FOLLOW ;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.CODE
.ADDR x0010 ;; this code should be loaded after line 10
;; this is done to preserve "USER_START"
;; subroutine that calls "main()"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; TRAP_PUTC Wrapper ;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.FALIGN
lc4_putc
;; PROLOGUE ;;
; CIT 593 TODO: write prologue code here
;; FUNCTION BODY ;;
; CIT 593 TODO: write code to get arguments to the trap from the stack
; and copy them to the register file for the TRAP call
TRAP x01 ; R0 must be set before TRAP_PUTC is called
;; EPILOGUE ;;
; TRAP_PUTC has no return value, so nothing to copy back to stack
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; TRAP_GETC Wrapper ;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.FALIGN
lc4_getc
;; PROLOGUE ;;
; !!!! TODO: write prologue code here
;; FUNCTION BODY ;;
; !!!!TODO: TRAP_GETC doesn't require arguments!
TRAP x00 ; Call's TRAP_GETC
; R0 will contain ascii character from keyboard
; you must copy this back to the stack
;; EPILOGUE ;;
; TRAP_GETC has a return value, so make certain to copy it back to stack
RET