-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsystem.asm
executable file
·69 lines (62 loc) · 1.04 KB
/
system.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
63
64
65
66
67
68
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; System Macros for Mac OS X
;;
;; © 2012 David J Goehrig <dave@dloh.org>
;;
%include "syscall.asm"
; displays the counted string on the top of the stack
; len str -- len
%macro show 0
arg2
arg3
literal 1
arg1
literal write
os
%endmacro
; displays a counted string ( addr -- written )
%macro cshow 0
dupe
fetchraw
andnum 0xff ; low byte
arg3 ; count
addnum 1
arg2 ; addr + 1
literal 1
arg1
literal write
os
%endmacro
; key --
%macro type 0
dupe ; key -- key key
stack ; nos address key -- key stack
arg2 ; key stack -- key
literal 1 ; key -- key stdout
arg1 ; key -- key
literal 1 ; key -- key 1 byte
arg3 ; key 1 -- key
literal write ; key -- key write
os ; key -- key count
drop ; key -- key
drop
%endmacro
; --
%macro quit 0
literal 0
arg1
literal exit ; 0x2000001 exit
os
%endmacro
; -- key
%macro key 0
stack ; nos pointer
arg2
literal 1
arg3 ; read 1 byte
literal 0 ; stdin
arg1
literal read
os
drop
%endmacro